summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Meta/CMake/code_generators.cmake55
-rw-r--r--Meta/CMake/utils.cmake48
2 files changed, 56 insertions, 47 deletions
diff --git a/Meta/CMake/code_generators.cmake b/Meta/CMake/code_generators.cmake
new file mode 100644
index 0000000000..24a4f0f390
--- /dev/null
+++ b/Meta/CMake/code_generators.cmake
@@ -0,0 +1,55 @@
+#
+# Functions for generating sources using host tools
+#
+
+function(compile_gml source output string_name)
+ set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
+ add_custom_command(
+ OUTPUT ${output}
+ COMMAND ${SerenityOS_SOURCE_DIR}/Meta/text-to-cpp-string.sh ${string_name} ${source} > ${output}.tmp
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${output}.tmp ${output}
+ COMMAND "${CMAKE_COMMAND}" -E remove ${output}.tmp
+ VERBATIM
+ DEPENDS ${SerenityOS_SOURCE_DIR}/Meta/text-to-cpp-string.sh
+ MAIN_DEPENDENCY ${source}
+ )
+ get_filename_component(output_name ${output} NAME)
+ add_custom_target(generate_${output_name} DEPENDS ${output})
+endfunction()
+
+function(compile_ipc source output)
+ set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
+ add_custom_command(
+ OUTPUT ${output}
+ COMMAND $<TARGET_FILE:IPCCompiler> ${source} > ${output}.tmp
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${output}.tmp ${output}
+ COMMAND "${CMAKE_COMMAND}" -E remove ${output}.tmp
+ VERBATIM
+ DEPENDS IPCCompiler
+ MAIN_DEPENDENCY ${source}
+ )
+ get_filename_component(output_name ${output} NAME)
+ add_custom_target(generate_${output_name} DEPENDS ${output})
+endfunction()
+
+function(generate_state_machine source header)
+ get_filename_component(header_name ${header} NAME)
+ set(target_name "generate_${header_name}")
+ # Note: This function is called twice with the same header, once in the kernel
+ # and once in Userland/LibVT, this check makes sure that only one target
+ # is generated for that header.
+ if(NOT TARGET ${target_name})
+ set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
+ set(output ${CMAKE_CURRENT_BINARY_DIR}/${header})
+ add_custom_command(
+ OUTPUT ${output}
+ COMMAND $<TARGET_FILE:StateMachineGenerator> ${source} > ${output}.tmp
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${output}.tmp ${output}
+ COMMAND "${CMAKE_COMMAND}" -E remove ${output}.tmp
+ VERBATIM
+ DEPENDS StateMachineGenerator
+ MAIN_DEPENDENCY ${source}
+ )
+ add_custom_target(${target_name} DEPENDS ${output})
+ endif()
+endfunction()
diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake
index e2a88b2375..7d1ef03552 100644
--- a/Meta/CMake/utils.cmake
+++ b/Meta/CMake/utils.cmake
@@ -1,5 +1,6 @@
include(${CMAKE_CURRENT_LIST_DIR}/serenity_components.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/code_generators.cmake)
function(serenity_install_headers target_name)
file(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
@@ -137,33 +138,6 @@ function(serenity_app target_name)
endif()
endfunction()
-function(compile_gml source output string_name)
- set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
- add_custom_command(
- OUTPUT ${output}
- COMMAND ${write_if_different} ${output} ${CMAKE_SOURCE_DIR}/Meta/text-to-cpp-string.sh ${string_name} ${source}
- VERBATIM
- DEPENDS ${CMAKE_SOURCE_DIR}/Meta/text-to-cpp-string.sh
- MAIN_DEPENDENCY ${source}
- )
- get_filename_component(output_name ${output} NAME)
- add_custom_target(generate_${output_name} DEPENDS ${output})
-endfunction()
-
-
-function(compile_ipc source output)
- set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
- add_custom_command(
- OUTPUT ${output}
- COMMAND ${write_if_different} ${output} ${CMAKE_BINARY_DIR}/Userland/DevTools/IPCCompiler/IPCCompiler ${source}
- VERBATIM
- DEPENDS IPCCompiler
- MAIN_DEPENDENCY ${source}
- )
- get_filename_component(output_name ${output} NAME)
- add_custom_target(generate_${output_name} DEPENDS ${output})
-endfunction()
-
function(embed_resource target section file)
get_filename_component(asm_file "${file}" NAME)
set(asm_file "${CMAKE_CURRENT_BINARY_DIR}/${target}-${section}.s")
@@ -177,23 +151,3 @@ function(embed_resource target section file)
)
target_sources("${target}" PRIVATE "${asm_file}")
endfunction()
-
-function(generate_state_machine source header)
- get_filename_component(header_name ${header} NAME)
- set(target_name "generate_${header_name}")
- # Note: This function is called twice with the same header, once in the kernel
- # and once in Userland/LibVT, this check makes sure that only one target
- # is generated for that header.
- if(NOT TARGET ${target_name})
- set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
- set(output ${CMAKE_CURRENT_BINARY_DIR}/${header})
- add_custom_command(
- OUTPUT ${output}
- COMMAND ${write_if_different} ${output} ${CMAKE_BINARY_DIR}/Userland/DevTools/StateMachineGenerator/StateMachineGenerator ${source}
- VERBATIM
- DEPENDS StateMachineGenerator
- MAIN_DEPENDENCY ${source}
- )
- add_custom_target(${target_name} DEPENDS ${output})
- endif()
-endfunction()