Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec-tests / regression_tests / lustre_files / success / Simulink / CMakeLists.txt @ 6c3ea955

History | View | Annotate | Download (3.3 KB)

1
cmake_minimum_required(VERSION 2.8.4)
2

    
3

    
4

    
5

    
6
#find_package(Lustre)
7

    
8
if(LUSTRE_COMPILER)
9
  message(STATUS "Found lustrec: ${LUSTRE_COMPILER} ")
10
else(LUSTRE_COMPILER)
11
  message(FATAL_ERROR "lustrec not found")
12
endif(LUSTRE_COMPILER)
13

    
14
#proceed all subdirectories
15
SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}  "src_")
16

    
17
#take all lustre files
18
set(GLOBAL_LUSTRE_FILES "")
19
FOREACH(subdir ${SUBDIRS})
20
  #message("${subdir}")
21
  LUSTREFILES(LFILE ${subdir} )
22
  list(APPEND GLOBAL_LUSTRE_FILES ${LFILE})
23
  get_filename_component(L ${LFILE} NAME_WE)
24
  set(LUSTRE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${L}")
25
  file(COPY ${LFILE} "${subdir}/input_values" "${subdir}/outputs_values" DESTINATION  ${LUSTRE_OUTPUT_DIR})
26
ENDFOREACH()
27

    
28
#first combination :no option
29
set(LUSTRE_OPTIONS_OPT "")
30
set(GENERATION_RESULTS "")
31
set(REPORT_PATH  "${CMAKE_CURRENT_BINARY_DIR}/report")
32
file(WRITE ${REPORT_PATH}  "")
33
FOREACH(lus_file ${GLOBAL_LUSTRE_FILES})
34
	get_filename_component(L ${lus_file} NAME_WE)
35
	set(LUSTRE_NODE_OPT  "${L}")
36
	set(LUSTRE_OPTIONS_OPT  "" )
37
	
38
	# First command generate C files from Lustre file
39
	Lustre_Compile(LUS_FILE ${lus_file}
40
					NODE ${LUSTRE_NODE_OPT}
41
					OPTS ${LUSTRE_OPTIONS_OPT})
42

    
43
	if(NOT ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}_RESULT} STREQUAL "0" )
44
		message("****************${LUSTRE_GENERATED_FILES_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}: Failed********")
45
	else(NOT ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}_RESULT} STREQUAL "0")
46
		#second command : generate C binary from C files generated before		
47
		#third step : compare binary outputs with the reference.
48
		add_custom_command(
49
			OUTPUT ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}/report
50
			DEPENDS ${LUSTRE_GENERATED_FILES_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}
51
			COMMAND make 
52
			ARGS  -f ${L}.makefile
53
			COMMAND ./${L}_${LUSTRE_NODE_OPT} 
54
			ARGS < ../input_values > ${L}_${LUSTRE_NODE_OPT}_outputs
55
			COMMAND diff
56
			ARGS -s ${L}_${LUSTRE_NODE_OPT}_outputs ../outputs_values > report
57
			WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}
58
			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"
59
		)
60
		add_test(NAME Stateflow_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}
61
				WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}
62
				COMMAND diff -s  ${L}_${LUSTRE_NODE_OPT}_outputs ../outputs_values)
63
		set_tests_properties(Stateflow_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}
64
				PROPERTIES PASS_REGULAR_EXPRESSION "are identical")
65
				
66
				
67
		set(GENERATION_RESULTS ${GENERATION_RESULTS} ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}/report)
68
		
69
		if(EXISTS ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}/report )
70
			file(READ ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}}/report REPORT)
71
			file(APPEND ${REPORT_PATH}.in  "${REPORT}")
72
			# Copy the temporary file to the final location
73
			configure_file(${REPORT_PATH}.in ${REPORT_PATH} COPYONLY)
74
		endif()
75
	endif(NOT ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUSTRE_OPTIONS_OPT}_RESULT} STREQUAL "0")
76

    
77
ENDFOREACH()
78

    
79

    
80
add_custom_target (Simulink_GENERATE_FILES ALL
81
	DEPENDS ${GENERATION_RESULTS})