1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

Meta+Userland: Add jakt as an optional Lagom Tool

We can now use ENABLE_JAKT to pull jakt as a host tool and use it to
pre-process .jakt files into .cpp files for use in serenity applications
This commit is contained in:
Andrew Kaster 2022-05-19 23:46:36 -06:00 committed by Andreas Kling
parent f19aad8336
commit ca42da23c2
11 changed files with 122 additions and 3 deletions

View file

@ -62,3 +62,25 @@ function(generate_state_machine source header)
add_dependencies(all_generated ${target_name})
endif()
endfunction()
function(compile_jakt source)
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
get_filename_component(source_base ${source} NAME_WE)
set(output "${source_base}.cpp")
add_custom_command(
OUTPUT ${output}
COMMAND $<TARGET_FILE:Lagom::jakt> -o "${CMAKE_CURRENT_BINARY_DIR}/jakt_tmp" ${source}
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/jakt_tmp/${output}" ${output}
COMMAND "${CMAKE_COMMAND}" -E remove "${CMAKE_CURRENT_BINARY_DIR}/jakt_tmp/${output}"
VERBATIM
DEPENDS Lagom::jakt
MAIN_DEPENDENCY ${source}
)
get_property(JAKT_INCLUDE_DIR TARGET Lagom::jakt PROPERTY IMPORTED_INCLUDE_DIRECTORIES)
set_source_files_properties("${output}" PROPERTIES
INCLUDE_DIRECTORIES "${JAKT_INCLUDE_DIR};${JAKT_INCLUDE_DIR}/runtime"
COMPILE_FLAGS "-Wno-unused-local-typedefs")
get_filename_component(output_name ${output} NAME)
add_custom_target(generate_${output_name} DEPENDS ${output})
add_dependencies(all_generated generate_${output_name})
endfunction()