efl
79 строк · 2.7 Кб
1# macro to create a eolian generated c source file
2#
3# macro adds a generate rule, which depends on the original file the rule will output file.x
4#
5# The passed include snippet will just be added to the command
6
7macro(_rule_eox file include deps)
8add_custom_command(
9OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${file}.x
10COMMAND eolian_gen ${include} -g c -o c:${CMAKE_CURRENT_SOURCE_DIR}/${file}.x ${CMAKE_CURRENT_SOURCE_DIR}/${file}
11DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
12DEPENDS ${deps}
13)
14endmacro()
15
16# macro to create a eolian generated header file
17#
18# other details are like the eox rule
19macro(_rule_eoh file include deps)
20add_custom_command(
21OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${file}.h
22COMMAND eolian_gen ${include} -g h -o h:${CMAKE_CURRENT_SOURCE_DIR}/${file}.h ${CMAKE_CURRENT_SOURCE_DIR}/${file}
23DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
24DEPENDS ${deps}
25)
26endmacro()
27
28# Can be used to create .eo.x , .eo.h, .eot.h generator rules.
29# <file>.eo files are generated into <file>.eo.x and <file>.eo.h files
30# <file>.eot files are generated into <file>.eot.h files
31# The standard include path of efl eolian files is automatically added to the includes
32#
33# build_files - A list of files
34# relative_include_dirs - A list of dirs to include
35#
36# If one of the included files is changed the file will be rebuilded at the next
37# make call
38#
39# The macro scans for .eo files, hey have to be in the build_files.
40# The generator rules are just executed if the file is a dependecy of some lib/executable.
41
42function(eo_rule_create build_files relative_include_dirs)
43string(REPLACE "\n" "" EOLIAN_EO_DIR_WITHOUT_NEWLINE "${EOLIAN_EO_DIR}")
44
45# add std includes
46list(APPEND include_dirs
47${EOLIAN_EO_DIR_WITHOUT_NEWLINE}
48)
49
50# convert relative to absolute
51foreach(relative_include_dir ${relative_include_dirs})
52list(APPEND include_dirs
53${CMAKE_CURRENT_SOURCE_DIR}/${relative_include_dir}
54)
55endforeach()
56
57# work with the absolute paths
58foreach(include_cmd ${include_dirs})
59# build include cmd
60string(CONCAT includes "${includes}" " -I${include_cmd}")
61# fetch dep files
62file(GLOB_RECURSE files "${include_cmd}/*.eo")
63foreach(file ${files})
64list(APPEND dep_files ${file})
65endforeach()
66endforeach()
67
68string(REPLACE " " ";" includes "${includes}")
69foreach(file ${build_files})
70get_filename_component(ext ${file} EXT)
71if (ext MATCHES "^\\.eo$")
72_rule_eoh("${file}" "${includes}" "${dep_files}")
73_rule_eox("${file}" "${includes}" "${dep_files}")
74endif()
75if (ext MATCHES "^\\.eot$")
76_rule_eoh("${file}" "${includes}" "${dep_files}")
77endif()
78endforeach()
79endfunction()
80