mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Meta: Prefer SerenityOS_SOURCE_DIR to CMAKE_SOURCE_DIR
By using SerenityOS_SOURCE_DIR we can make custom targets and commands agnostic to the actual location of the root CMakeLists directory. All we care about is the root of the SerenityOS project.
This commit is contained in:
parent
20e904d87c
commit
47471c0ec2
Notes:
sideshowbarker
2024-07-18 05:10:50 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/47471c0ec22 Pull-request: https://github.com/SerenityOS/serenity/pull/9281 Reviewed-by: https://github.com/BenWiederhake
3 changed files with 26 additions and 25 deletions
|
@ -48,7 +48,7 @@ option(USE_CLANG_TOOLCHAIN "Build the kernel with the experimental Clang toolcha
|
|||
include(Meta/CMake/wasm_spec_tests.cmake)
|
||||
|
||||
add_custom_target(run
|
||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_ARCH=${SERENITY_ARCH}" ${CMAKE_SOURCE_DIR}/Meta/run.sh
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_ARCH=${SERENITY_ARCH}" "${SerenityOS_SOURCE_DIR}/Meta/run.sh"
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
|
@ -72,40 +72,40 @@ set(GCC_VERSION 11.2.0)
|
|||
set(LLVM_VERSION 12.0.1)
|
||||
|
||||
add_custom_target(qemu-image
|
||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" ${CMAKE_SOURCE_DIR}/Meta/build-image-qemu.sh
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/_disk_image
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-qemu.sh"
|
||||
BYPRODUCTS "${CMAKE_BINARY_DIR}/_disk_image"
|
||||
USES_TERMINAL
|
||||
)
|
||||
add_custom_target(grub-image
|
||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" ${CMAKE_SOURCE_DIR}/Meta/build-image-grub.sh
|
||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-grub.sh"
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/grub_disk_image
|
||||
USES_TERMINAL
|
||||
)
|
||||
add_custom_target(extlinux-image
|
||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" ${CMAKE_SOURCE_DIR}/Meta/build-image-extlinux.sh
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/extlinux_disk_image
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-extlinux.sh"
|
||||
BYPRODUCTS "${CMAKE_BINARY_DIR}/extlinux_disk_image"
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
add_custom_target(lint-shell-scripts
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/Meta/lint-shell-scripts.sh
|
||||
COMMAND "${SerenityOS_SOURCE_DIR}/Meta/lint-shell-scripts.sh"
|
||||
USES_TERMINAL
|
||||
)
|
||||
add_custom_target(check-style
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/Meta/check-style.sh
|
||||
COMMAND "${SerenityOS_SOURCE_DIR}/Meta/check-style.sh"
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
add_custom_target(install-ports
|
||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" ${CMAKE_SOURCE_DIR}/Meta/install-ports-tree.sh
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "${SerenityOS_SOURCE_DIR}/Meta/install-ports-tree.sh"
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
add_custom_target(configure-components
|
||||
COMMAND ConfigureComponents
|
||||
DEPENDS ConfigureComponents
|
||||
COMMAND "$<TARGET_FILE:ConfigureComponents>"
|
||||
USES_TERMINAL
|
||||
)
|
||||
add_dependencies(configure-components ConfigureComponents)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
@ -137,7 +137,7 @@ if (ENABLE_ALL_DEBUG_FACILITIES)
|
|||
endif()
|
||||
|
||||
if (ENABLE_ALL_THE_DEBUG_MACROS)
|
||||
include(${CMAKE_SOURCE_DIR}/Meta/CMake/all_the_debug_macros.cmake)
|
||||
include("${SerenityOS_SOURCE_DIR}/Meta/CMake/all_the_debug_macros.cmake")
|
||||
endif(ENABLE_ALL_THE_DEBUG_MACROS)
|
||||
|
||||
configure_file(AK/Debug.h.in AK/Debug.h @ONLY)
|
||||
|
@ -189,7 +189,7 @@ elseif(USE_CLANG_TOOLCHAIN)
|
|||
# FIXME: Persuade LLVM maintainers to add `--update-section` to llvm-objcopy, as it's required for the kernel symbol map.
|
||||
set(CMAKE_OBJCOPY ${TOOLCHAIN_ROOT}/binutils/bin/${SERENITY_ARCH}-pc-serenity-objcopy)
|
||||
else()
|
||||
set(TOOLCHAIN_ROOT ${CMAKE_SOURCE_DIR}/Toolchain/Local/${SERENITY_ARCH}/)
|
||||
set(TOOLCHAIN_ROOT ${SerenityOS_SOURCE_DIR}/Toolchain/Local/${SERENITY_ARCH}/)
|
||||
set(TOOLCHAIN_PATH ${TOOLCHAIN_ROOT}/bin)
|
||||
set(TOOLCHAIN_PREFIX ${TOOLCHAIN_PATH}/${SERENITY_ARCH}-pc-serenity-)
|
||||
|
||||
|
@ -263,7 +263,7 @@ add_compile_options(-Wno-unused-command-line-argument)
|
|||
add_compile_options(-Wwrite-strings)
|
||||
add_compile_options(-Wno-maybe-uninitialized)
|
||||
|
||||
add_compile_options(-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.)
|
||||
add_compile_options(-ffile-prefix-map=${SerenityOS_SOURCE_DIR}=.)
|
||||
add_compile_options(-fno-exceptions)
|
||||
add_compile_options(-ftls-model=initial-exec)
|
||||
add_compile_options(-fno-semantic-interposition)
|
||||
|
@ -342,7 +342,7 @@ endif()
|
|||
add_custom_target(components ALL)
|
||||
option(BUILD_EVERYTHING "Build all optional components" ON)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/Meta/CMake/utils.cmake)
|
||||
include(Meta/CMake/utils.cmake)
|
||||
|
||||
serenity_component(
|
||||
Tests
|
||||
|
|
|
@ -81,7 +81,7 @@ function(serenity_bin target_name)
|
|||
endfunction()
|
||||
|
||||
function(serenity_test test_src sub_dir)
|
||||
cmake_parse_arguments(SERENITY_TEST "MAIN_ALREADY_DEFINED" "CUSTOM_MAIN" "LIBS" ${ARGN})
|
||||
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "MAIN_ALREADY_DEFINED" "CUSTOM_MAIN" "LIBS")
|
||||
set(TEST_SOURCES ${test_src})
|
||||
if ("${SERENITY_TEST_CUSTOM_MAIN}" STREQUAL "")
|
||||
set(SERENITY_TEST_CUSTOM_MAIN "$<TARGET_OBJECTS:LibTestMain>")
|
||||
|
@ -102,7 +102,7 @@ endfunction()
|
|||
|
||||
|
||||
function(serenity_testjs_test test_src sub_dir)
|
||||
cmake_parse_arguments(SERENITY_TEST "" "CUSTOM_MAIN" "LIBS" ${ARGN})
|
||||
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "" "CUSTOM_MAIN" "LIBS")
|
||||
if ("${SERENITY_TEST_CUSTOM_MAIN}" STREQUAL "")
|
||||
set(SERENITY_TEST_CUSTOM_MAIN "$<TARGET_OBJECTS:JavaScriptTestRunnerMain>")
|
||||
endif()
|
||||
|
@ -113,11 +113,11 @@ function(serenity_testjs_test test_src sub_dir)
|
|||
endfunction()
|
||||
|
||||
function(serenity_app target_name)
|
||||
cmake_parse_arguments(SERENITY_APP "" "ICON" "" ${ARGN})
|
||||
cmake_parse_arguments(PARSE_ARGV 1 SERENITY_APP "" "ICON" "")
|
||||
|
||||
serenity_bin("${target_name}")
|
||||
set(small_icon "${CMAKE_SOURCE_DIR}/Base/res/icons/16x16/${SERENITY_APP_ICON}.png")
|
||||
set(medium_icon "${CMAKE_SOURCE_DIR}/Base/res/icons/32x32/${SERENITY_APP_ICON}.png")
|
||||
set(small_icon "${SerenityOS_SOURCE_DIR}/Base/res/icons/16x16/${SERENITY_APP_ICON}.png")
|
||||
set(medium_icon "${SerenityOS_SOURCE_DIR}/Base/res/icons/32x32/${SERENITY_APP_ICON}.png")
|
||||
|
||||
if (EXISTS "${small_icon}")
|
||||
embed_resource("${target_name}" serenity_icon_s "${small_icon}")
|
||||
|
@ -145,8 +145,8 @@ function(embed_resource target section file)
|
|||
file(SIZE "${input_file}" file_size)
|
||||
add_custom_command(
|
||||
OUTPUT "${asm_file}"
|
||||
COMMAND "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh" "${asm_file}" "${section}" "${input_file}" "${file_size}"
|
||||
DEPENDS "${input_file}" "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh"
|
||||
COMMAND "${SerenityOS_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh" "${asm_file}" "${section}" "${input_file}" "${file_size}"
|
||||
DEPENDS "${input_file}" "${SerenityOS_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh"
|
||||
COMMENT "Generating ${asm_file}"
|
||||
)
|
||||
target_sources("${target}" PRIVATE "${asm_file}")
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
option(INCLUDE_WASM_SPEC_TESTS "Download and include the WebAssembly spec testsuite" OFF)
|
||||
|
||||
if(INCLUDE_WASM_SPEC_TESTS)
|
||||
set(SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||||
if (CMAKE_SOURCE_DIR MATCHES ".*/Lagom")
|
||||
set(SOURCE_DIR ${SOURCE_DIR}/../..)
|
||||
if (CMAKE_PROJECT_NAME STREQUAL "SerenityOS")
|
||||
set(SOURCE_DIR "${SerenityOS_SOURCE_DIR}")
|
||||
else()
|
||||
set(SOURCE_DIR "${SERENITY_PROJECT_ROOT}")
|
||||
endif()
|
||||
set(WASM_SPEC_TEST_GZ_URL https://github.com/WebAssembly/testsuite/archive/refs/heads/master.tar.gz)
|
||||
set(WASM_SPEC_TEST_GZ_PATH ${CMAKE_BINARY_DIR}/wasm-spec-testsuite.tar.gz)
|
||||
|
|
Loading…
Reference in a new issue