Meta: Update jakt build support for fully bootstrapped compiler

Remove the Corrosion dependency, and use the now-builtin
add_jakt_executable function from the Jakt install rules to build our
example application.

By using find_package(Jakt), we now have to set ENABLE_JAKT manually on
both serenity and Lagom at the same time, so the preferred method to do
this for now is:

    cmake -B Build/superbuild<arch><toolchain> \
          -S Meta/CMake/Superbuild \
          -DENABLE_JAKT=ON \
          -DJAKT_SOURCE_DIR=/path/to/jakt

Where omitting JAKT_SOURCE_DIR will still pull from the main branch of
SerenityOS/jakt. This can be done after runing Meta/serenity.sh run.
This commit is contained in:
Andrew Kaster 2022-08-28 17:47:03 -06:00 committed by Andreas Kling
parent 72ae082ca8
commit 5ab3fcf710
Notes: sideshowbarker 2024-07-17 07:20:08 +09:00
8 changed files with 14 additions and 81 deletions

View file

@ -53,8 +53,11 @@ if (NOT HACKSTUDIO_BUILD)
# Host tools, required to generate files for the build # Host tools, required to generate files for the build
find_package(Lagom CONFIG REQUIRED) find_package(Lagom CONFIG REQUIRED)
if (TARGET Lagom::jakt)
set(ENABLE_JAKT ON) if (ENABLE_JAKT)
find_package(Jakt CONFIG REQUIRED
HINTS "${Lagom_DIR}/.."
)
endif() endif()
endif() endif()

View file

@ -62,25 +62,3 @@ function(generate_state_machine source header)
add_dependencies(all_generated ${target_name}) add_dependencies(all_generated ${target_name})
endif() endif()
endfunction() 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> -S -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}/runtime"
COMPILE_OPTIONS "-Wno-unused-local-typedefs;-Wno-unused-function")
get_filename_component(output_name ${output} NAME)
add_custom_target(generate_${output_name} DEPENDS ${output})
add_dependencies(all_generated generate_${output_name})
endfunction()

View file

@ -4,14 +4,6 @@
include(FetchContent) include(FetchContent)
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.2.1
)
FetchContent_MakeAvailable(Corrosion)
FetchContent_Declare(jakt FetchContent_Declare(jakt
GIT_REPOSITORY https://github.com/SerenityOS/jakt.git GIT_REPOSITORY https://github.com/SerenityOS/jakt.git
GIT_TAG main GIT_TAG main
@ -24,17 +16,5 @@ if (JAKT_SOURCE_DIR)
message(STATUS "Using pre-existing JAKT_SOURCE_DIR: ${JAKT_SOURCE_DIR}") message(STATUS "Using pre-existing JAKT_SOURCE_DIR: ${JAKT_SOURCE_DIR}")
endif() endif()
FetchContent_GetProperties(jakt) set(JAKT_BUILD_TESTING OFF)
if (NOT jakt_POPULATED) FetchContent_MakeAvailable(jakt)
FetchContent_Populate(jakt)
corrosion_import_crate(MANIFEST_PATH "${jakt_SOURCE_DIR}/Cargo.toml")
corrosion_set_hostbuild(jakt)
add_executable(Lagom::jakt ALIAS jakt)
corrosion_install(TARGETS jakt RUNTIME COMPONENT Lagom_Runtime)
# NOTE: See lagom-install-config.cmake for hax required to get Lagom::jakt to show up on install
install(DIRECTORY "${jakt_SOURCE_DIR}/runtime"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/jakt
FILES_MATCHING PATTERN "*.h"
PATTERN "*.cpp"
PATTERN "utility")
endif()

View file

@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/LagomTargets.cmake")

View file

@ -1,31 +0,0 @@
include("${CMAKE_CURRENT_LIST_DIR}/LagomTargets.cmake")
if (@ENABLE_JAKT@)
# FIXME: corrosion does not support corrosion_install(TARGETS <targets>... EXPORT <export-name>)
# Instead, hack up the magic sauce using the imported location of IPCCompiler
# Create imported target Lagom::jakt
add_executable(Lagom::jakt IMPORTED)
# Figure out where the binary directory of the install tree is
get_property(_IMPORTED_BINDIR
TARGET Lagom::IPCCompiler
PROPERTY LOCATION
)
get_filename_component(_IMPORTED_BINDIR "${_IMPORTED_BINDIR}" DIRECTORY)
get_filename_component(_IMPORTED_INCLUDEDIR "${_IMPORTED_BINDIR}" DIRECTORY)
set(_IMPORTED_INCLUDEDIR "${_IMPORTED_INCLUDEDIR}/include")
# Set the imported location of the tool
set_target_properties(Lagom::jakt PROPERTIES
IMPORTED_LOCATION "${_IMPORTED_BINDIR}/jakt"
IMPORTED_INCLUDE_DIRECTORIES "${_IMPORTED_INCLUDEDIR}/jakt"
)
if (NOT EXISTS "${_IMPORTED_BINDIR}/jakt")
message(FATAL_ERROR "The imported target \"jakt\" references the file \"${_IMPORTED_BINDIR}/jakt\" but this file does not exist.")
endif()
unset(_IMPORTED_BINDIR)
unset(_IMPORTED_INCLUDEDIR)
endif()

View file

@ -4,6 +4,7 @@ add_compile_options(-Wno-implicit-const-int-float-conversion)
add_compile_options(-Wno-literal-suffix) add_compile_options(-Wno-literal-suffix)
add_compile_options(-Wno-maybe-uninitialized) add_compile_options(-Wno-maybe-uninitialized)
add_compile_options(-Wno-unknown-warning-option) add_compile_options(-Wno-unknown-warning-option)
add_compile_options(-Wno-unused-command-line-argument)
add_compile_options(-fsigned-char) add_compile_options(-fsigned-char)
add_compile_options(-fno-exceptions) add_compile_options(-fno-exceptions)
add_compile_options(-fdiagnostics-color=always) add_compile_options(-fdiagnostics-color=always)

View file

@ -156,10 +156,10 @@ set(Lagom_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/${package}"
CACHE PATH "CMake package config location relative to the install prefix") CACHE PATH "CMake package config location relative to the install prefix")
mark_as_advanced(Lagom_INSTALL_CMAKEDIR) mark_as_advanced(Lagom_INSTALL_CMAKEDIR)
configure_file("${SERENITY_PROJECT_ROOT}/Meta/CMake/lagom-install-config.cmake.in" "${package}Config.cmake" @ONLY)
install( install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${package}Config.cmake" FILES "${SERENITY_PROJECT_ROOT}/Meta/CMake/lagom-install-config.cmake"
DESTINATION "${Lagom_INSTALL_CMAKEDIR}" DESTINATION "${Lagom_INSTALL_CMAKEDIR}"
RENAME "${package}Config.cmake"
COMPONENT Lagom_Development COMPONENT Lagom_Development
) )

View file

@ -52,8 +52,9 @@ foreach(CMD_SRC ${CMD_SOURCES})
endforeach() endforeach()
if (ENABLE_JAKT) if (ENABLE_JAKT)
add_executable(hello-jakt hello-world.cpp) add_jakt_executable(hello-jakt
compile_jakt(hello-world.jakt) MAIN_SOURCE hello-world.jakt
)
target_link_libraries(hello-jakt LibC) target_link_libraries(hello-jakt LibC)
set_target_properties(hello-jakt PROPERTIES EXCLUDE_FROM_ALL TRUE) set_target_properties(hello-jakt PROPERTIES EXCLUDE_FROM_ALL TRUE)
install(TARGETS hello-jakt RUNTIME DESTINATION bin OPTIONAL) install(TARGETS hello-jakt RUNTIME DESTINATION bin OPTIONAL)