From 5ab3fcf71020ad01d82c765d706cd253429305e8 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sun, 28 Aug 2022 17:47:03 -0600 Subject: [PATCH] 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 \ -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. --- CMakeLists.txt | 7 ++++-- Meta/CMake/code_generators.cmake | 22 ----------------- Meta/CMake/jakt.cmake | 24 ++---------------- Meta/CMake/lagom-install-config.cmake | 1 + Meta/CMake/lagom-install-config.cmake.in | 31 ------------------------ Meta/CMake/lagom_compile_options.cmake | 1 + Meta/Lagom/CMakeLists.txt | 4 +-- Userland/Utilities/CMakeLists.txt | 5 ++-- 8 files changed, 14 insertions(+), 81 deletions(-) create mode 100644 Meta/CMake/lagom-install-config.cmake delete mode 100644 Meta/CMake/lagom-install-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 977403de9e5..3979b027f80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,8 +53,11 @@ if (NOT HACKSTUDIO_BUILD) # Host tools, required to generate files for the build 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() diff --git a/Meta/CMake/code_generators.cmake b/Meta/CMake/code_generators.cmake index e54a4c10238..01f21aae67f 100644 --- a/Meta/CMake/code_generators.cmake +++ b/Meta/CMake/code_generators.cmake @@ -62,25 +62,3 @@ 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 $ -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() diff --git a/Meta/CMake/jakt.cmake b/Meta/CMake/jakt.cmake index 4eed013db66..2f813f278fe 100644 --- a/Meta/CMake/jakt.cmake +++ b/Meta/CMake/jakt.cmake @@ -4,14 +4,6 @@ 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 GIT_REPOSITORY https://github.com/SerenityOS/jakt.git GIT_TAG main @@ -24,17 +16,5 @@ if (JAKT_SOURCE_DIR) message(STATUS "Using pre-existing JAKT_SOURCE_DIR: ${JAKT_SOURCE_DIR}") endif() -FetchContent_GetProperties(jakt) -if (NOT jakt_POPULATED) - 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() +set(JAKT_BUILD_TESTING OFF) +FetchContent_MakeAvailable(jakt) diff --git a/Meta/CMake/lagom-install-config.cmake b/Meta/CMake/lagom-install-config.cmake new file mode 100644 index 00000000000..2805685ec69 --- /dev/null +++ b/Meta/CMake/lagom-install-config.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/LagomTargets.cmake") diff --git a/Meta/CMake/lagom-install-config.cmake.in b/Meta/CMake/lagom-install-config.cmake.in deleted file mode 100644 index 8842161ca9b..00000000000 --- a/Meta/CMake/lagom-install-config.cmake.in +++ /dev/null @@ -1,31 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/LagomTargets.cmake") - -if (@ENABLE_JAKT@) - # FIXME: corrosion does not support corrosion_install(TARGETS ... EXPORT ) - # 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() diff --git a/Meta/CMake/lagom_compile_options.cmake b/Meta/CMake/lagom_compile_options.cmake index 79cc587ff18..140c1f51cac 100644 --- a/Meta/CMake/lagom_compile_options.cmake +++ b/Meta/CMake/lagom_compile_options.cmake @@ -4,6 +4,7 @@ add_compile_options(-Wno-implicit-const-int-float-conversion) add_compile_options(-Wno-literal-suffix) add_compile_options(-Wno-maybe-uninitialized) add_compile_options(-Wno-unknown-warning-option) +add_compile_options(-Wno-unused-command-line-argument) add_compile_options(-fsigned-char) add_compile_options(-fno-exceptions) add_compile_options(-fdiagnostics-color=always) diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index 0a5cafde388..fa782c16dd1 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -156,10 +156,10 @@ set(Lagom_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/${package}" CACHE PATH "CMake package config location relative to the install prefix") mark_as_advanced(Lagom_INSTALL_CMAKEDIR) -configure_file("${SERENITY_PROJECT_ROOT}/Meta/CMake/lagom-install-config.cmake.in" "${package}Config.cmake" @ONLY) install( - FILES "${CMAKE_CURRENT_BINARY_DIR}/${package}Config.cmake" + FILES "${SERENITY_PROJECT_ROOT}/Meta/CMake/lagom-install-config.cmake" DESTINATION "${Lagom_INSTALL_CMAKEDIR}" + RENAME "${package}Config.cmake" COMPONENT Lagom_Development ) diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 131b4e3fc4a..6f9c73f87bf 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -52,8 +52,9 @@ foreach(CMD_SRC ${CMD_SOURCES}) endforeach() if (ENABLE_JAKT) - add_executable(hello-jakt hello-world.cpp) - compile_jakt(hello-world.jakt) + add_jakt_executable(hello-jakt + MAIN_SOURCE hello-world.jakt + ) target_link_libraries(hello-jakt LibC) set_target_properties(hello-jakt PROPERTIES EXCLUDE_FROM_ALL TRUE) install(TARGETS hello-jakt RUNTIME DESTINATION bin OPTIONAL)