CMake+CI: Remove BUILD_LAGOM=OFF option in favor of LAGOM_TOOLS_ONLY=ON

The far more common configuration for Ladybird is to always build the
Lagom libraries.
This commit is contained in:
Andrew Kaster 2024-06-07 15:41:53 -06:00 committed by Andreas Kling
parent 1af9e44130
commit 9f25dc6b09
Notes: sideshowbarker 2024-07-17 00:57:24 +09:00
8 changed files with 245 additions and 246 deletions

View File

@ -98,7 +98,7 @@ jobs:
set -e set -e
cmake -GNinja -S Meta/Lagom -B ${{ github.workspace }}/tools-build \ cmake -GNinja -S Meta/Lagom -B ${{ github.workspace }}/tools-build \
-DBUILD_LAGOM=OFF \ -DLAGOM_TOOLS_ONLY=ON \
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/tool-install \ -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/tool-install \
-DSERENITY_CACHE_DIR=${{ github.workspace }}/Build/caches \ -DSERENITY_CACHE_DIR=${{ github.workspace }}/Build/caches \
-DCMAKE_C_COMPILER=gcc-13 \ -DCMAKE_C_COMPILER=gcc-13 \

View File

@ -50,7 +50,7 @@ jobs:
cmake -GNinja \ cmake -GNinja \
-B ${{ github.workspace }}/Build/lagom-tools \ -B ${{ github.workspace }}/Build/lagom-tools \
-S ${{ github.workspace }}/Meta/Lagom \ -S ${{ github.workspace }}/Meta/Lagom \
-DBUILD_LAGOM=OFF \ -DLAGOM_TOOLS_ONLY=ON
-DSERENITY_CACHE_DIR=${{ github.workspace }}/Build/caches \ -DSERENITY_CACHE_DIR=${{ github.workspace }}/Build/caches \
-DCMAKE_C_COMPILER=gcc-13 \ -DCMAKE_C_COMPILER=gcc-13 \
-DCMAKE_CXX_COMPILER=g++-13 \ -DCMAKE_CXX_COMPILER=g++-13 \
@ -66,7 +66,6 @@ jobs:
-B ${{ github.workspace }}/Build/wasm \ -B ${{ github.workspace }}/Build/wasm \
-S ${{ github.workspace }}/Meta/Lagom \ -S ${{ github.workspace }}/Meta/Lagom \
-DLagomTools_DIR=${{ github.workspace }}/Build/lagom-tools/share/LagomTools \ -DLagomTools_DIR=${{ github.workspace }}/Build/lagom-tools/share/LagomTools \
-DBUILD_LAGOM=ON \
-DSERENITY_CACHE_DIR=${{ github.workspace }}/Build/caches \ -DSERENITY_CACHE_DIR=${{ github.workspace }}/Build/caches \
-DBUILD_SHARED_LIBS=OFF -DBUILD_SHARED_LIBS=OFF
env: env:

View File

@ -25,11 +25,10 @@ There are some optional features that can be enabled during compilation that are
- `ENABLE_FUZZERS_OSSFUZZ`: builds OSS-Fuzz compatible [fuzzers](../Meta/Lagom/ReadMe.md#fuzzing) for various parts of the system. - `ENABLE_FUZZERS_OSSFUZZ`: builds OSS-Fuzz compatible [fuzzers](../Meta/Lagom/ReadMe.md#fuzzing) for various parts of the system.
- `ENABLE_ALL_THE_DEBUG_MACROS`: used for checking whether debug code compiles on CI. This should not be set normally, as it clutters the console output and makes the system run very slowly. Instead, enable only the needed debug macros, as described below. - `ENABLE_ALL_THE_DEBUG_MACROS`: used for checking whether debug code compiles on CI. This should not be set normally, as it clutters the console output and makes the system run very slowly. Instead, enable only the needed debug macros, as described below.
- `ENABLE_COMPILETIME_FORMAT_CHECK`: checks for the validity of `std::format`-style format string during compilation. Enabled by default. - `ENABLE_COMPILETIME_FORMAT_CHECK`: checks for the validity of `std::format`-style format string during compilation. Enabled by default.
- `BUILD_LAGOM`: builds [Lagom](../Meta/Lagom/ReadMe.md), which makes various SerenityOS libraries and programs available on the host system. - `LAGOM_TOOLS_ONLY`: Skips building libraries, utiltis and tests for [Lagom](../Meta/Lagom/ReadMe.md). Mostly only useful for cross-compilation.
- `ENABLE_MOLD_LINKER`: builds the userland with the [`mold` linker](https://github.com/rui314/mold). `mold` can be built by running `Toolchain/BuildMold.sh`.
- `INCLUDE_WASM_SPEC_TESTS`: downloads and includes the WebAssembly spec testsuite tests. In order to use this option, you will need to install `prettier` and `wabt`. wabt version 1.0.23 or higher is required to pre-process the WebAssembly spec testsuite. - `INCLUDE_WASM_SPEC_TESTS`: downloads and includes the WebAssembly spec testsuite tests. In order to use this option, you will need to install `prettier` and `wabt`. wabt version 1.0.23 or higher is required to pre-process the WebAssembly spec testsuite.
- `INCLUDE_FLAC_SPEC_TESTS`: downloads and includes the xiph.org FLAC test suite. - `INCLUDE_FLAC_SPEC_TESTS`: downloads and includes the xiph.org FLAC test suite.
- `SERENITY_CACHE_DIR`: sets the location of a shared cache of downloaded files. Should not need to be set unless managing a distribution package. - `SERENITY_CACHE_DIR`: sets the location of a shared cache of downloaded files. Should not need to be set manually unless managing a distribution package.
- `ENABLE_NETWORK_DOWNLOADS`: allows downloading files from the internet during the build. Default on, turning off enables offline builds. For offline builds, the structure of the SERENITY_CACHE_DIR must be set up the way that the build expects. - `ENABLE_NETWORK_DOWNLOADS`: allows downloading files from the internet during the build. Default on, turning off enables offline builds. For offline builds, the structure of the SERENITY_CACHE_DIR must be set up the way that the build expects.
- `ENABLE_ACCELERATED_GRAPHICS`: builds features that use accelerated graphics APIs to speed up painting and drawing using native graphics libraries. - `ENABLE_ACCELERATED_GRAPHICS`: builds features that use accelerated graphics APIs to speed up painting and drawing using native graphics libraries.

View File

@ -11,10 +11,9 @@ ctest --preset default
``` ```
If you want to avoid building and running LibWeb tests, you can use a Lagom-only build. If you want to avoid building and running LibWeb tests, you can use a Lagom-only build.
For a Lagom-only build, pass the Lagom source directory to CMake. The `BUILD_LAGOM` CMake option is required.
```sh ```sh
cmake -GNinja -S Meta/Lagom -B Build/lagom -DBUILD_LAGOM=ON cmake -GNinja -S Meta/Lagom -B Build/lagom
``` ```
The tests can be run via ninja after doing a build. Note that `test-js` requires the `LADYBIRD_SOURCE_DIR` environment variable to be set The tests can be run via ninja after doing a build. Note that `test-js` requires the `LADYBIRD_SOURCE_DIR` environment variable to be set
@ -63,7 +62,7 @@ The Sanitizer test preset already sets these environment variables.
```sh ```sh
export ASAN_OPTIONS='strict_string_checks=1:check_initialization_order=1:strict_init_order=1:detect_stack_use_after_return=1:allocator_may_return_null=1' export ASAN_OPTIONS='strict_string_checks=1:check_initialization_order=1:strict_init_order=1:detect_stack_use_after_return=1:allocator_may_return_null=1'
export UBSAN_OPTIONS='print_stacktrace=1:print_summary=1:halt_on_error=1' export UBSAN_OPTIONS='print_stacktrace=1:print_summary=1:halt_on_error=1'
cmake -GNinja -S Meta/Lagom -B Build/lagom -DBUILD_LAGOM=ON -DENABLE_ADDRESS_SANITIZER=ON -DENABLE_UNDEFINED_SANITIZER=ON cmake -GNinja -S Meta/Lagom -B Build/lagom -DENABLE_ADDRESS_SANITIZER=ON -DENABLE_UNDEFINED_SANITIZER=ON
cd Build/lagom cd Build/lagom
ninja ninja
CTEST_OUTPUT_ON_FAILURE=1 LADYBIRD_SOURCE_DIR=${PWD}/../.. ninja test CTEST_OUTPUT_ON_FAILURE=1 LADYBIRD_SOURCE_DIR=${PWD}/../.. ninja test

View File

@ -2,8 +2,6 @@
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
set(BUILD_LAGOM ON CACHE INTERNAL "Build all Lagom targets")
set(LAGOM_SOURCE_DIR "${LADYBIRD_SOURCE_DIR}/Meta/Lagom") set(LAGOM_SOURCE_DIR "${LADYBIRD_SOURCE_DIR}/Meta/Lagom")
set(LAGOM_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/Lagom") set(LAGOM_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/Lagom")

View File

@ -10,7 +10,7 @@ serenity_option(ENABLE_MEMORY_SANITIZER OFF CACHE BOOL "Enable memory sanitizer
serenity_option(ENABLE_FUZZERS OFF CACHE BOOL "Build fuzzing targets") serenity_option(ENABLE_FUZZERS OFF CACHE BOOL "Build fuzzing targets")
serenity_option(ENABLE_FUZZERS_LIBFUZZER OFF CACHE BOOL "Build fuzzers using Clang's libFuzzer") serenity_option(ENABLE_FUZZERS_LIBFUZZER OFF CACHE BOOL "Build fuzzers using Clang's libFuzzer")
serenity_option(ENABLE_FUZZERS_OSSFUZZ OFF CACHE BOOL "Build OSS-Fuzz compatible fuzzers") serenity_option(ENABLE_FUZZERS_OSSFUZZ OFF CACHE BOOL "Build OSS-Fuzz compatible fuzzers")
serenity_option(BUILD_LAGOM OFF CACHE BOOL "Build parts of the system targeting the host OS for fuzzing/testing") serenity_option(LAGOM_TOOLS_ONLY OFF CACHE BOOL "Don't build libraries, utilities and tests, only host build tools")
serenity_option(ENABLE_LAGOM_CCACHE ON CACHE BOOL "Enable ccache for Lagom builds") serenity_option(ENABLE_LAGOM_CCACHE ON CACHE BOOL "Enable ccache for Lagom builds")
serenity_option(LAGOM_USE_LINKER "" CACHE STRING "The linker to use (e.g. lld, mold) instead of the system default") serenity_option(LAGOM_USE_LINKER "" CACHE STRING "The linker to use (e.g. lld, mold) instead of the system default")
serenity_option(ENABLE_LAGOM_COVERAGE_COLLECTION OFF CACHE STRING "Enable code coverage instrumentation for lagom binaries in clang") serenity_option(ENABLE_LAGOM_COVERAGE_COLLECTION OFF CACHE STRING "Enable code coverage instrumentation for lagom binaries in clang")

View File

@ -53,7 +53,7 @@ fi
# FIXME: Replace these CMake invocations with a CMake superbuild? # FIXME: Replace these CMake invocations with a CMake superbuild?
echo "Building Lagom Tools..." echo "Building Lagom Tools..."
cmake -GNinja -B Build/tools \ cmake -GNinja -B Build/tools \
-DBUILD_LAGOM=OFF \ -DLAGOM_TOOLS_ONLY=ON \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \ -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_INSTALL_PREFIX=Build/tool-install \ -DCMAKE_INSTALL_PREFIX=Build/tool-install \
-Dpackage=LagomTools -Dpackage=LagomTools
@ -69,7 +69,6 @@ echo "Building Lagom Fuzzers..."
if [ "$#" -gt "0" ] && [ "--oss-fuzz" = "$1" ] ; then if [ "$#" -gt "0" ] && [ "--oss-fuzz" = "$1" ] ; then
echo "Building for oss-fuzz configuration..." echo "Building for oss-fuzz configuration..."
cmake -GNinja -B Build/fuzzers \ cmake -GNinja -B Build/fuzzers \
-DBUILD_LAGOM=ON \
-DBUILD_SHARED_LIBS=OFF \ -DBUILD_SHARED_LIBS=OFF \
-DENABLE_FUZZERS_OSSFUZZ=ON \ -DENABLE_FUZZERS_OSSFUZZ=ON \
-DFUZZER_DICTIONARY_DIRECTORY="$OUT" \ -DFUZZER_DICTIONARY_DIRECTORY="$OUT" \
@ -83,7 +82,6 @@ if [ "$#" -gt "0" ] && [ "--oss-fuzz" = "$1" ] ; then
elif [ "$#" -gt "0" ] && [ "--standalone" = "$1" ] ; then elif [ "$#" -gt "0" ] && [ "--standalone" = "$1" ] ; then
echo "Building for standalone fuzz configuration..." echo "Building for standalone fuzz configuration..."
cmake -GNinja -B Build/lagom-fuzzers-standalone \ cmake -GNinja -B Build/lagom-fuzzers-standalone \
-DBUILD_LAGOM=ON \
-DENABLE_FUZZERS=ON \ -DENABLE_FUZZERS=ON \
-DCMAKE_PREFIX_PATH=Build/tool-install -DCMAKE_PREFIX_PATH=Build/tool-install
ninja -C Build/lagom-fuzzers-standalone ninja -C Build/lagom-fuzzers-standalone
@ -91,7 +89,6 @@ else
echo "Building for local fuzz configuration..." echo "Building for local fuzz configuration..."
pick_clang pick_clang
cmake -GNinja -B Build/lagom-fuzzers \ cmake -GNinja -B Build/lagom-fuzzers \
-DBUILD_LAGOM=ON \
-DENABLE_FUZZERS_LIBFUZZER=ON \ -DENABLE_FUZZERS_LIBFUZZER=ON \
-DENABLE_ADDRESS_SANITIZER=ON \ -DENABLE_ADDRESS_SANITIZER=ON \
-DENABLE_UNDEFINED_SANITIZER=ON \ -DENABLE_UNDEFINED_SANITIZER=ON \

View File

@ -390,7 +390,10 @@ if (BUILD_LAGOM_TOOLS)
add_subdirectory(Tools) add_subdirectory(Tools)
endif() endif()
if (BUILD_LAGOM) if (LAGOM_TOOLS_ONLY)
return()
endif()
# Lagom Libraries # Lagom Libraries
set(lagom_standard_libraries set(lagom_standard_libraries
AccelGfx AccelGfx
@ -435,7 +438,15 @@ if (BUILD_LAGOM)
# FIXME: Why is this not in LibLocale/CMakeLists.txt? # FIXME: Why is this not in LibLocale/CMakeLists.txt?
target_link_libraries(LibLocale PRIVATE LibTimeZone) target_link_libraries(LibLocale PRIVATE LibTimeZone)
if (NOT ENABLE_FUZZERS AND NOT ENABLE_COMPILER_EXPLORER_BUILD AND NOT ANDROID AND NOT IOS) if (ENABLE_FUZZERS)
add_subdirectory(Fuzzers)
endif()
# No utilities or tests in these configs
if (ENABLE_FUZZERS OR ENABLE_COMPILER_EXPLORER_BUILD OR ANDROID OR IOS)
return()
endif()
# Lagom Utilities # Lagom Utilities
lagom_utility(abench SOURCES ../../Userland/Utilities/abench.cpp LIBS LibMain LibFileSystem LibAudio) lagom_utility(abench SOURCES ../../Userland/Utilities/abench.cpp LIBS LibMain LibFileSystem LibAudio)
lagom_utility(aconv SOURCES ../../Userland/Utilities/aconv.cpp LIBS LibMain LibFileSystem LibAudio) lagom_utility(aconv SOURCES ../../Userland/Utilities/aconv.cpp LIBS LibMain LibFileSystem LibAudio)
@ -490,7 +501,8 @@ if (BUILD_LAGOM)
lagom_utility(xml SOURCES ../../Userland/Utilities/xml.cpp LIBS LibFileSystem LibMain LibXML LibURL) lagom_utility(xml SOURCES ../../Userland/Utilities/xml.cpp LIBS LibFileSystem LibMain LibXML LibURL)
lagom_utility(xzcat SOURCES ../../Userland/Utilities/xzcat.cpp LIBS LibCompress LibMain) lagom_utility(xzcat SOURCES ../../Userland/Utilities/xzcat.cpp LIBS LibCompress LibMain)
enable_testing() include(CTest)
if (BUILD_TESTING)
# LibTest # LibTest
file(GLOB LIBTEST_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibTest/*.cpp") file(GLOB LIBTEST_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibTest/*.cpp")
list(FILTER LIBTEST_SOURCES EXCLUDE REGEX ".*Main.cpp$") list(FILTER LIBTEST_SOURCES EXCLUDE REGEX ".*Main.cpp$")
@ -594,6 +606,7 @@ if (BUILD_LAGOM)
SKIP_RETURN_CODE 1 SKIP_RETURN_CODE 1
ENVIRONMENT LADYBIRD_SOURCE_DIR=${SERENITY_PROJECT_ROOT} ENVIRONMENT LADYBIRD_SOURCE_DIR=${SERENITY_PROJECT_ROOT}
) )
endif()
# FIXME: When we are using CMake >= 3.21, the library installations can be replaced with RUNTIME_DEPENDENCIES. # FIXME: When we are using CMake >= 3.21, the library installations can be replaced with RUNTIME_DEPENDENCIES.
# https://cmake.org/cmake/help/latest/command/install.html # https://cmake.org/cmake/help/latest/command/install.html
@ -619,9 +632,3 @@ if (BUILD_LAGOM)
set(CPACK_ARCHIVE_JS_FILE_NAME "serenity-js-${CPACK_SYSTEM_NAME}") set(CPACK_ARCHIVE_JS_FILE_NAME "serenity-js-${CPACK_SYSTEM_NAME}")
set(CPACK_PACKAGE_FILE_NAME "serenity-js-${CPACK_SYSTEM_NAME}") set(CPACK_PACKAGE_FILE_NAME "serenity-js-${CPACK_SYSTEM_NAME}")
include(CPack) include(CPack)
endif()
endif()
if (ENABLE_FUZZERS)
add_subdirectory(Fuzzers)
endif()