summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--cmakeconfig/EolianHelper.cmake80
2 files changed, 82 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index c1d0a84300..235cdc009f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -297,7 +297,8 @@ cmakeconfig/EoConfigVersion.cmake
297eolian_cmakeconfigdir = $(libdir)/cmake/Eolian/ 297eolian_cmakeconfigdir = $(libdir)/cmake/Eolian/
298eolian_cmakeconfig_DATA = \ 298eolian_cmakeconfig_DATA = \
299cmakeconfig/EolianConfig.cmake \ 299cmakeconfig/EolianConfig.cmake \
300cmakeconfig/EolianConfigVersion.cmake 300cmakeconfig/EolianConfigVersion.cmake \
301cmakeconfig/EolianHelper.cmake
301 302
302eolian_cxx_cmakeconfigdir = $(libdir)/cmake/EolianCxx/ 303eolian_cxx_cmakeconfigdir = $(libdir)/cmake/EolianCxx/
303eolian_cxx_cmakeconfig_DATA = \ 304eolian_cxx_cmakeconfig_DATA = \
diff --git a/cmakeconfig/EolianHelper.cmake b/cmakeconfig/EolianHelper.cmake
new file mode 100644
index 0000000000..9b0397327e
--- /dev/null
+++ b/cmakeconfig/EolianHelper.cmake
@@ -0,0 +1,80 @@
1find_package(Eolian 1.16 REQUIRED)
2# macro to create a eolian generated c source file
3#
4# macro adds a generate rule, which depends on the original file the rule will output file.x
5#
6# The passed include snippet will just be added to the command
7
8macro(_rule_eox file include deps)
9 add_custom_command(
10 OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${file}.x
11 COMMAND eolian_gen ${include} --gc -o ${CMAKE_CURRENT_SOURCE_DIR}/${file}.x ${CMAKE_CURRENT_SOURCE_DIR}/${file}
12 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
13 DEPENDS ${deps}
14 )
15endmacro()
16
17# macro to create a eolian generated header file
18#
19# other details are like the eox rule
20macro(_rule_eoh file include deps)
21 add_custom_command(
22 OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${file}.h
23 COMMAND eolian_gen ${include} --gh -o ${CMAKE_CURRENT_SOURCE_DIR}/${file}.h ${CMAKE_CURRENT_SOURCE_DIR}/${file}
24 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
25 DEPENDS ${deps}
26 )
27endmacro()
28
29# Can be used to create .eo.x , .eo.h, .eot.h generator rules.
30# <file>.eo files are generated into <file>.eo.x and <file>.eo.h files
31# <file>.eot files are generated into <file>.eot.h files
32# The standard include path of efl eolian files is automatically added to the includes
33#
34# build_files - A list of files
35# relative_include_dirs - A list of dirs to include
36#
37# If one of the included files is changed the file will be rebuilded at the next
38# make call
39#
40# The macro scans for .eo files, hey have to be in the build_files.
41# The generator rules are just executed if the file is a dependecy of some lib/executable.
42
43function(eo_rule_create build_files relative_include_dirs)
44 string(REPLACE "\n" "" EOLIAN_EO_DIR_WITHOUT_NEWLINE "${EOLIAN_EO_DIR}")
45
46 # add std includes
47 list(APPEND include_dirs
48 ${EOLIAN_EO_DIR_WITHOUT_NEWLINE}
49 )
50
51 # convert relative to absolut
52 foreach(relative_include_dir ${relative_include_dirs})
53 list(APPEND include_dirs
54 ${CMAKE_CURRENT_SOURCE_DIR}/${relative_include_dir}
55 )
56 endforeach()
57
58 # work with the absolut paths
59 foreach(include_cmd ${include_dirs})
60 # build include cmd
61 string(CONCAT includes "${includes}" " -I${include_cmd}")
62 # fetch dep files
63 file(GLOB_RECURSE files "${include_cmd}/*.eo")
64 foreach(file ${files})
65 list(APPEND dep_files ${file})
66 endforeach()
67 endforeach()
68
69 string(REPLACE " " ";" includes "${includes}")
70 foreach(file ${build_files})
71 get_filename_component(ext ${file} EXT)
72 if (ext MATCHES "^\\.eo$")
73 _rule_eoh("${file}" "${includes}" "${dep_files}")
74 _rule_eox("${file}" "${includes}" "${dep_files}")
75 endif()
76 if (ext MATCHES "^\\.eot$")
77 _rule_eoh("${file}" "${includes}" "${dep_files}")
78 endif()
79 endforeach()
80endfunction()