Project

General

Profile

Download (3.42 KB) Statistics
| Branch: | Tag: | Revision:
1
cmake_minimum_required(VERSION 2.8.4)
2

    
3

    
4
#helpfull functions and macros
5
MACRO(SUBDIRLIST result curdir)
6
  FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
7
  SET(dirlist "")
8
  FOREACH(child ${children})
9
    IF(IS_DIRECTORY ${curdir}/${child})
10
      LIST(APPEND dirlist ${child})
11
    ENDIF()
12
  ENDFOREACH()
13
  SET(${result} ${dirlist})
14
ENDMACRO()
15

    
16
MACRO(LUSTREFILES result dir)
17
  FILE(GLOB children ${dir} ${dir}/*.lus)
18
  SET(lustreFileslist "")
19
  FOREACH(child ${children})
20
    IF(EXISTS ${child} AND NOT IS_DIRECTORY ${child})
21
      LIST(APPEND lustreFileslist ${child})
22
    ENDIF()
23
  ENDFOREACH()
24
  SET(${result} ${lustreFileslist})
25
ENDMACRO()
26

    
27
#find_package(Lustre)
28

    
29
if(LUSTRE_COMPILER)
30
  message(STATUS "Found lustrec: ${LUSTRE_COMPILER} ")
31
else(LUSTRE_COMPILER)
32
  message(FATAL_ERROR "lustrec not found")
33
endif(LUSTRE_COMPILER)
34

    
35
#proceed all subdirectories
36
SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
37

    
38
#take all lustre files
39
set(GLOBAL_LUSTRE_FILES "")
40
FOREACH(subdir ${SUBDIRS})
41
  LUSTREFILES(LFILE ${subdir} )
42
  list(APPEND GLOBAL_LUSTRE_FILES ${LFILE})
43
  get_filename_component(L ${LFILE} NAME_WE)
44
  set(LUSTRE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${L}")
45
  file(COPY ${LFILE} "${subdir}/input_values" "${subdir}/outputs_values" DESTINATION  ${LUSTRE_OUTPUT_DIR})
46
ENDFOREACH()
47

    
48
#first combination :no option
49
set(LUSTRE_OPTIONS_OPT "")
50
set(GENERATION_RESULTS "")
51
set(REPORT_PATH  "${CMAKE_CURRENT_BINARY_DIR}/report")
52
file(WRITE REPORT_PATH "")
53
FOREACH(lus_file ${GLOBAL_LUSTRE_FILES})
54
	get_filename_component(L ${lus_file} NAME_WE)
55
	set(LUSTRE_NODE_OPT  "${L}")
56
	set(LUSTRE_OPTIONS_OPT  "" )
57
	
58
	# First command generate C files from Lustre file
59
	Lustre_Compile(LUS_FILE ${lus_file}
60
					NODE ${LUSTRE_NODE_OPT}
61
					OPTS ${LUSTRE_OPTIONS_OPT})
62
						
63
	#second command : generate C binary from C files generated before		
64
	#third step : compare binary outputs with the reference.
65
	add_custom_command(
66
		OUTPUT ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}/report
67
		DEPENDS ${LUSTRE_GENERATED_FILES_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}
68
		COMMAND make 
69
		ARGS  -f ${L}.makefile
70
		COMMAND ./${L}_${LUSTRE_NODE_OPT} 
71
		ARGS < ../input_values > ${L}_${LUSTRE_NODE_OPT}_outputs
72
		COMMAND diff
73
		ARGS -s ${L}_${LUSTRE_NODE_OPT}_outputs ../outputs_values > report
74
		WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}
75
		COMMENT " make -f ${L}.makefile \n ./${L}_${LUSTRE_NODE_OPT}  < ../input_values > ${L}_${LUSTRE_NODE_OPT}_outputs \n diff -s ${L}_${LUSTRE_NODE_OPT}_outputs ../outputs_values > report"
76
	)
77
	add_test(NAME Stateflow_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}
78
			WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}
79
			COMMAND diff -s  ${L}_${LUSTRE_NODE_OPT}_outputs ../outputs_values)
80
	set_tests_properties(Stateflow_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}
81
			PROPERTIES PASS_REGULAR_EXPRESSION "are identical")
82
			
83
			
84
	set(GENERATION_RESULTS ${GENERATION_RESULTS} ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}/report)
85
	
86
	if(EXISTS ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}/report )
87
		file(READ ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}/report REPORT)
88
		file(APPEND ${REPORT_PATH}.in  "${REPORT}")
89
		# Copy the temporary file to the final location
90
		configure_file(${REPORT_PATH}.in ${REPORT_PATH} COPYONLY)
91
	endif()
92
	
93
ENDFOREACH()
94

    
95

    
96
add_custom_target (GENERATE_FILES ALL
97
	DEPENDS ${GENERATION_RESULTS})
    (1-1/1)