summaryrefslogtreecommitdiff
path: root/cmakeconfig/EolianHelper.cmake.in
diff options
context:
space:
mode:
Diffstat (limited to 'cmakeconfig/EolianHelper.cmake.in')
-rw-r--r--cmakeconfig/EolianHelper.cmake.in79
1 files changed, 79 insertions, 0 deletions
diff --git a/cmakeconfig/EolianHelper.cmake.in b/cmakeconfig/EolianHelper.cmake.in
new file mode 100644
index 0000000000..56eca6ffc8
--- /dev/null
+++ b/cmakeconfig/EolianHelper.cmake.in
@@ -0,0 +1,79 @@
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)
8 add_custom_command(
9 OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${file}.x
10 COMMAND eolian_gen ${include} --gc -o ${CMAKE_CURRENT_SOURCE_DIR}/${file}.x ${CMAKE_CURRENT_SOURCE_DIR}/${file}
11 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
12 DEPENDS ${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)
20 add_custom_command(
21 OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${file}.h
22 COMMAND eolian_gen ${include} --gh -o ${CMAKE_CURRENT_SOURCE_DIR}/${file}.h ${CMAKE_CURRENT_SOURCE_DIR}/${file}
23 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
24 DEPENDS ${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)
43 string(REPLACE "\n" "" EOLIAN_EO_DIR_WITHOUT_NEWLINE "${EOLIAN_EO_DIR}")
44
45 # add std includes
46 list(APPEND include_dirs
47 ${EOLIAN_EO_DIR_WITHOUT_NEWLINE}
48 )
49
50 # convert relative to absolut
51 foreach(relative_include_dir ${relative_include_dirs})
52 list(APPEND include_dirs
53 ${CMAKE_CURRENT_SOURCE_DIR}/${relative_include_dir}
54 )
55 endforeach()
56
57 # work with the absolut paths
58 foreach(include_cmd ${include_dirs})
59 # build include cmd
60 string(CONCAT includes "${includes}" " -I${include_cmd}")
61 # fetch dep files
62 file(GLOB_RECURSE files "${include_cmd}/*.eo")
63 foreach(file ${files})
64 list(APPEND dep_files ${file})
65 endforeach()
66 endforeach()
67
68 string(REPLACE " " ";" includes "${includes}")
69 foreach(file ${build_files})
70 get_filename_component(ext ${file} EXT)
71 if (ext MATCHES "^\\.eo$")
72 _rule_eoh("${file}" "${includes}" "${dep_files}")
73 _rule_eox("${file}" "${includes}" "${dep_files}")
74 endif()
75 if (ext MATCHES "^\\.eot$")
76 _rule_eoh("${file}" "${includes}" "${dep_files}")
77 endif()
78 endforeach()
79endfunction()