Meta+CMake: Remove unused CMake functions and features

Goodbye, serenity_components and Jakt.
This commit is contained in:
Andrew Kaster 2024-06-04 15:03:02 -06:00 committed by Tim Flynn
parent ec6072e7cd
commit 90af26e309
Notes: sideshowbarker 2024-07-17 00:16:31 +09:00
18 changed files with 37 additions and 331 deletions

View file

@ -74,3 +74,13 @@ endif()
include(CTest) # for BUILD_TESTING option, default ON
add_subdirectory(Ladybird)
add_custom_target(lint-shell-scripts
COMMAND "${ladybird_SOURCE_DIR}/Meta/lint-shell-scripts.sh"
USES_TERMINAL
)
add_custom_target(check-style
COMMAND "${ladybird_SOURCE_DIR}/Meta/check-style.sh"
USES_TERMINAL
)

View file

@ -23,12 +23,6 @@ function(embed_as_string_view name source_file output source_variable_name)
add_dependencies(all_generated "generate_${name}")
endfunction()
function(stringify_gml source output string_name)
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
get_filename_component(output_name ${output} NAME)
embed_as_string_view(${output_name} ${source} ${output} ${string_name})
endfunction()
function(compile_ipc source output)
if (NOT IS_ABSOLUTE ${source})
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
@ -50,25 +44,3 @@ function(compile_ipc source output)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${current_source_dir_relative}" OPTIONAL)
endfunction()
function(generate_state_machine source header)
get_filename_component(header_name ${header} NAME)
set(target_name "generate_${header_name}")
# Note: This function is called twice with the same header, once in the kernel
# and once in Userland/LibVT, this check makes sure that only one target
# is generated for that header.
if(NOT TARGET ${target_name})
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
set(output ${CMAKE_CURRENT_BINARY_DIR}/${header})
add_custom_command(
OUTPUT ${output}
COMMAND $<TARGET_FILE:Lagom::StateMachineGenerator> ${source} -o ${output}.tmp
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${output}.tmp ${output}
COMMAND "${CMAKE_COMMAND}" -E remove ${output}.tmp
VERBATIM
DEPENDS Lagom::StateMachineGenerator
MAIN_DEPENDENCY ${source}
)
add_custom_target(${target_name} DEPENDS ${output})
add_dependencies(all_generated ${target_name})
endif()
endfunction()

View file

@ -24,11 +24,6 @@ serenity_option(INCLUDE_FLAC_SPEC_TESTS OFF CACHE BOOL "Download and include the
serenity_option(ENABLE_CACERT_DOWNLOAD ON CACHE BOOL "Enable download of cacert.pem at build time")
serenity_option(ENABLE_ACCELERATED_GRAPHICS ON CACHE BOOL "Enable use of accelerated graphics APIs")
serenity_option(HACKSTUDIO_BUILD OFF CACHE BOOL "Automatically enabled when building from HackStudio")
serenity_option(ENABLE_JAKT OFF CACHE BOOL "Enable building jakt files")
serenity_option(JAKT_SOURCE_DIR "" CACHE STRING "Pre-existing jakt language source directory")
serenity_option(SERENITY_CACHE_DIR "${PROJECT_BINARY_DIR}/../caches" CACHE PATH "Location of shared cache of downloaded files")
serenity_option(ENABLE_NETWORK_DOWNLOADS ON CACHE BOOL "Allow downloads of required files. If OFF, required files must already be present in SERENITY_CACHE_DIR")

View file

@ -1,20 +0,0 @@
#
# Builds the jakt bootstrap compiler as a host tool for Lagom to compile files written in jakt
#
include(FetchContent)
FetchContent_Declare(jakt
GIT_REPOSITORY https://github.com/SerenityOS/jakt.git
GIT_TAG main
GIT_SHALLOW TRUE
)
# Allow developers to skip download/update steps with local checkout
if (JAKT_SOURCE_DIR)
set(FETCHCONTENT_SOURCE_DIR_JAKT ${JAKT_SOURCE_DIR} CACHE PATH "Developer's pre-existing jakt source directory" FORCE)
message(STATUS "Using pre-existing JAKT_SOURCE_DIR: ${JAKT_SOURCE_DIR}")
endif()
set(JAKT_BUILD_TESTING OFF)
FetchContent_MakeAvailable(jakt)

View file

@ -1,90 +0,0 @@
#
# Target properties and functions for optionally building libraries and applications
#
define_property(TARGET PROPERTY SERENITY_COMPONENT_NAME BRIEF_DOCS "SerenityOS component name" FULL_DOCS "-")
define_property(TARGET PROPERTY SERENITY_COMPONENT_DESCRIPTION BRIEF_DOCS "SerenityOS component description" FULL_DOCS "-")
define_property(TARGET PROPERTY SERENITY_COMPONENT_RECOMMENDED BRIEF_DOCS "SerenityOS component recommended (flag)" FULL_DOCS "-")
define_property(TARGET PROPERTY SERENITY_COMPONENT_REQUIRED BRIEF_DOCS "SerenityOS component required (flag)" FULL_DOCS "-")
define_property(TARGET PROPERTY SERENITY_COMPONENT_DEPENDS BRIEF_DOCS "SerenityOS component dependencies" FULL_DOCS "-")
function(serenity_component name)
cmake_parse_arguments(PARSE_ARGV 1 SERENITY_COMPONENT "RECOMMENDED;REQUIRED" "DESCRIPTION" "TARGETS;DEPENDS")
string(TOUPPER "${name}" NAME_UPPER)
option("BUILD_${NAME_UPPER}" "Build ${name}" "${SERENITY_COMPONENT_RECOMMENDED}")
add_custom_target("Component${name}")
set_target_properties(
"Component${name}" PROPERTIES
SERENITY_COMPONENT_NAME "${name}"
SERENITY_COMPONENT_DESCRIPTION "${SERENITY_COMPONENT_DESCRIPTION}"
SERENITY_COMPONENT_RECOMMENDED "${SERENITY_COMPONENT_RECOMMENDED}"
SERENITY_COMPONENT_REQUIRED "${SERENITY_COMPONENT_REQUIRED}"
SERENITY_COMPONENT_DEPENDS "${SERENITY_COMPONENT_DEPENDS}"
)
if(NOT "${SERENITY_COMPONENT_TARGETS}" STREQUAL "") # note: one component is /bin/false, which makes this tricky
foreach(target IN LISTS SERENITY_COMPONENT_TARGETS)
add_dependencies("Component${name}" "${target}")
endforeach()
endif()
if(BUILD_EVERYTHING OR "${BUILD_${NAME_UPPER}}" OR SERENITY_COMPONENT_REQUIRED)
add_dependencies(components "Component${name}")
endif()
foreach(dependency IN LISTS SERENITY_COMPONENT_DEPENDS)
add_dependencies("Component${name}" "Component${dependency}")
endforeach()
endfunction()
function(export_components_helper file_name current_dir)
get_property(sub_dirs DIRECTORY "${current_dir}" PROPERTY SUBDIRECTORIES)
foreach(sub_dir IN LISTS sub_dirs)
export_components_helper("${file_name}" "${sub_dir}")
endforeach()
get_property(targets DIRECTORY "${current_dir}" PROPERTY BUILDSYSTEM_TARGETS)
foreach(target IN LISTS targets)
get_target_property(type "${target}" TYPE)
if (type STREQUAL "INTERFACE_LIBRARY")
continue() # Custom properties are not allowed to be set on INTERFACE libraries
endif()
get_target_property(component_name "${target}" SERENITY_COMPONENT_NAME)
if(NOT "${component_name}" STREQUAL "" AND NOT "${component_name}" STREQUAL "component_name-NOTFOUND")
get_target_property(component_name "${target}" SERENITY_COMPONENT_NAME)
get_target_property(component_description "${target}" SERENITY_COMPONENT_DESCRIPTION)
get_target_property(component_recommended "${target}" SERENITY_COMPONENT_RECOMMENDED)
get_target_property(component_required "${target}" SERENITY_COMPONENT_REQUIRED)
get_target_property(component_depends "${target}" SERENITY_COMPONENT_DEPENDS)
file(APPEND "${file_name}" "[${component_name}]\n")
file(APPEND "${file_name}" "description=${component_description}\n")
if(component_recommended)
file(APPEND "${file_name}" "recommended=1\n")
else()
file(APPEND "${file_name}" "recommended=0\n")
endif()
if(component_required)
file(APPEND "${file_name}" "required=1\n")
else()
file(APPEND "${file_name}" "required=0\n")
endif()
string(TOUPPER "${component_name}" component_name_upper)
if("${BUILD_${component_name_upper}}")
file(APPEND "${file_name}" "user_selected=1\n")
else()
file(APPEND "${file_name}" "user_selected=0\n")
endif()
file(APPEND "${file_name}" "depends=${component_depends}\n")
file(APPEND "${file_name}" "\n")
endif()
endforeach()
endfunction()
function(export_components file_name)
file(WRITE "${file_name}" "[Global]\n")
if(BUILD_EVERYTHING)
file(APPEND "${file_name}" "build_everything=1\n")
else()
file(APPEND "${file_name}" "build_everything=0\n")
endif()
file(APPEND "${file_name}" "\n")
export_components_helper("${file_name}" "${CMAKE_CURRENT_SOURCE_DIR}")
endfunction()

View file

@ -1,5 +1,4 @@
include(${CMAKE_CURRENT_LIST_DIR}/serenity_components.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/code_generators.cmake)
function(serenity_set_implicit_links target_name)
@ -149,20 +148,6 @@ function(serenity_app target_name)
endif()
endfunction()
function(embed_resource target section file)
get_filename_component(asm_file "${file}" NAME)
set(asm_file "${CMAKE_CURRENT_BINARY_DIR}/${target}-${section}.s")
get_filename_component(input_file "${file}" ABSOLUTE)
file(SIZE "${input_file}" file_size)
add_custom_command(
OUTPUT "${asm_file}"
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}")
endfunction()
function(remove_path_if_version_changed version version_file cache_path)
set(version_differs YES)

View file

@ -311,9 +311,6 @@ macro(add_serenity_subdirectory path)
add_subdirectory("${SERENITY_PROJECT_ROOT}/${path}" "${CMAKE_CURRENT_BINARY_DIR}/${path}")
endmacro()
add_custom_target(components ALL)
option(BUILD_EVERYTHING "Build all optional components" ON)
if (NOT TARGET all_generated)
# Meta target to run all code-gen steps in the build.
add_custom_target(all_generated)
@ -670,8 +667,6 @@ endif()
if (ENABLE_FUZZERS)
add_subdirectory(Fuzzers)
else()
export_components("${CMAKE_BINARY_DIR}/components.ini")
endif()
include(ca_certificates_data)

View file

@ -14,7 +14,3 @@ endfunction()
add_subdirectory(CodeGenerators)
add_subdirectory(ConfigureComponents)
add_subdirectory(IPCMagicLinter)
if (ENABLE_JAKT)
include(jakt)
endif()

View file

@ -1,40 +0,0 @@
#!/usr/bin/env bash
set -e
if [ -z "$1" ]; then
echo "ERROR: No output file specified"
exit 1
fi
OUTPUT_FILE="$1"
shift
rm -f "${OUTPUT_FILE}"
while (( "$#" >= 3 )); do
SECTION_NAME="$1"
INPUT_FILE="$2"
FILE_SIZE="$3"
{
printf ' .file "%s"\n' "${OUTPUT_FILE}"
printf ' .data\n'
printf ' .section %s, "a", @progbits\n' "${SECTION_NAME}"
printf ' .align 4\n'
printf ' .globl %s\n' "${SECTION_NAME}_start"
printf ' .type %s, @object\n' "${SECTION_NAME}_start"
printf ' .size %s, 4\n' "${SECTION_NAME}_start"
printf '%s:\n' "${SECTION_NAME}_start"
printf ' .incbin "%s"\n' "${INPUT_FILE}"
printf ' .section serenity_embedded_resource_info, "a", @progbits\n'
printf ' .align 4\n'
printf ' .globl %s\n' "${SECTION_NAME}_size"
printf ' .type %s, @object\n' "${SECTION_NAME}_size"
printf ' .size %s, 4\n' "${SECTION_NAME}_size"
printf '%s:\n' "${SECTION_NAME}_size"
printf ' .long %s\n' "${FILE_SIZE}"
printf '\n'
} >> "${OUTPUT_FILE}"
shift 3
done

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
SERENITY_PORTS_DIR="${LADYBIRD_SOURCE_DIR}/Build/${SERENITY_ARCH}/Root/usr/Ports"
for file in $(git ls-files "${LADYBIRD_SOURCE_DIR}/Ports"); do
if [ "$(basename "$file")" != ".hosted_defs.sh" ]; then
target=${SERENITY_PORTS_DIR}/$(realpath --relative-to="${LADYBIRD_SOURCE_DIR}/Ports" "$file")
mkdir -p "$(dirname "$target")" && cp "$file" "$target"
fi
done

View file

@ -6,19 +6,11 @@ serenity_test(test-invalid-unicode-js.cpp LibJS LIBS LibJS LibLocale)
serenity_test(test-value-js.cpp LibJS LIBS LibJS LibLocale)
serenity_component(
test262-runner
TARGETS test262-runner
)
add_executable(test262-runner test262-runner.cpp)
target_link_libraries(test262-runner PRIVATE LibJS LibCore LibLocale)
serenity_set_implicit_links(test262-runner)
install(TARGETS test262-runner RUNTIME DESTINATION bin OPTIONAL)
serenity_component(
test-test262
TARGETS test-test262
)
add_executable(test-test262 test-test262.cpp)
target_link_libraries(test-test262 PRIVATE LibMain LibCore LibFileSystem)
serenity_set_implicit_links(test-test262)

View file

@ -1,8 +1,3 @@
serenity_component(
ImageDecoder
TARGETS ImageDecoder
)
compile_ipc(ImageDecoderServer.ipc ImageDecoderServerEndpoint.h)
compile_ipc(ImageDecoderClient.ipc ImageDecoderClientEndpoint.h)

View file

@ -1,8 +1,3 @@
serenity_component(
RequestServer
TARGETS RequestServer
)
compile_ipc(RequestServer.ipc RequestServerEndpoint.h)
compile_ipc(RequestClient.ipc RequestClientEndpoint.h)

View file

@ -1,9 +1,3 @@
serenity_component(
SQLServer
REQUIRED
TARGETS SQLServer
)
compile_ipc(SQLServer.ipc SQLServerEndpoint.h)
compile_ipc(SQLClient.ipc SQLClientEndpoint.h)

View file

@ -1,11 +1,5 @@
include(accelerated_graphics)
serenity_component(
WebContent
TARGETS WebContent
DEPENDS ImageDecoder RequestServer
)
compile_ipc(WebContentServer.ipc WebContentServerEndpoint.h)
compile_ipc(WebContentClient.ipc WebContentClientEndpoint.h)

View file

@ -1,9 +1,3 @@
serenity_component(
WebDriver
TARGETS WebDriver
DEPENDS WebContent
)
set(SOURCES
Client.cpp
Session.cpp

View file

@ -1,9 +1,3 @@
serenity_component(
WebWorker
TARGETS WebWorker
DEPENDS WebContent
)
set(SOURCES
ConnectionFromClient.cpp
DedicatedWorkerHost.cpp

View file

@ -1,73 +1,38 @@
file(GLOB CMD_SOURCES CONFIGURE_DEPENDS "*.cpp")
list(APPEND REQUIRED_TARGETS
file
)
list(APPEND RECOMMENDED_TARGETS
aconv abench gzip lzcat tar unzip xzcat zip
set(CMD_SOURCES
abench.cpp
aconv.cpp
animation.cpp
gzip.cpp
headless-browser.cpp
icc.cpp
image.cpp
isobmff.cpp
js.cpp
lzcat.cpp
shred.cpp
sql.cpp
tar.cpp
test-jpeg-roundtrip.cpp
ttfdisasm.cpp
unzip.cpp
wasm.cpp
xml.cpp
xzcat.cpp
zip.cpp
)
# FIXME: Support specifying component dependencies for utilities (e.g. WebSocket for telws)
foreach(CMD_SRC ${CMD_SOURCES})
foreach(CMD_SRC IN LISTS CMD_SOURCES)
get_filename_component(CMD_NAME ${CMD_SRC} NAME_WLE)
if (CMD_NAME IN_LIST SPECIAL_TARGETS)
set(TARGET_NAME "${CMD_NAME}-bin")
else()
set(TARGET_NAME "${CMD_NAME}")
endif()
if(CMD_NAME IN_LIST REQUIRED_TARGETS)
serenity_component(
${CMD_NAME}
REQUIRED
TARGETS ${TARGET_NAME}
)
elseif(CMD_NAME IN_LIST RECOMMENDED_TARGETS)
serenity_component(
${CMD_NAME}
RECOMMENDED
TARGETS ${TARGET_NAME}
)
else()
serenity_component(
${CMD_NAME}
TARGETS ${TARGET_NAME}
)
endif()
add_executable(${TARGET_NAME} ${CMD_SRC})
target_link_libraries(${TARGET_NAME} PRIVATE LibCore LibMain)
serenity_set_implicit_links(${TARGET_NAME})
set_target_properties(${TARGET_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE)
install(TARGETS ${TARGET_NAME} RUNTIME DESTINATION bin OPTIONAL)
if (CMD_NAME IN_LIST SPECIAL_TARGETS)
install(CODE
"if (EXISTS ${CMAKE_INSTALL_PREFIX}/bin/${CMD_NAME}-bin)
file(RENAME ${CMAKE_INSTALL_PREFIX}/bin/${CMD_NAME}-bin ${CMAKE_INSTALL_PREFIX}/bin/${CMD_NAME})
endif()")
endif()
add_executable(${CMD_NAME} ${CMD_SRC})
target_link_libraries(${CMD_NAME} PRIVATE LibCore LibMain)
serenity_set_implicit_links(${CMD_NAME})
set_target_properties(${CMD_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE)
install(TARGETS ${CMD_NAME} RUNTIME DESTINATION bin OPTIONAL)
endforeach()
if (ENABLE_JAKT)
add_jakt_executable(hello-jakt
MAIN_SOURCE hello-world.jakt
)
target_link_libraries(hello-jakt PRIVATE LibC)
set_target_properties(hello-jakt PROPERTIES EXCLUDE_FROM_ALL TRUE)
install(TARGETS hello-jakt RUNTIME DESTINATION bin OPTIONAL)
serenity_component(
hello-jakt
RECOMMENDED
TARGETS hello-jakt
)
endif()
install(CODE "file(CREATE_LINK grep ${CMAKE_INSTALL_PREFIX}/bin/egrep SYMBOLIC)")
install(CODE "file(CREATE_LINK grep ${CMAKE_INSTALL_PREFIX}/bin/fgrep SYMBOLIC)")
install(CODE "file(CREATE_LINK grep ${CMAKE_INSTALL_PREFIX}/bin/rgrep SYMBOLIC)")
install(CODE "file(CREATE_LINK gzip ${CMAKE_INSTALL_PREFIX}/bin/gunzip SYMBOLIC)")
install(CODE "file(CREATE_LINK gzip ${CMAKE_INSTALL_PREFIX}/bin/zcat SYMBOLIC)")
install(CODE "file(CREATE_LINK /usr/lib/Loader.so ${CMAKE_INSTALL_PREFIX}/bin/ldd SYMBOLIC)")
target_link_libraries(abench PRIVATE LibAudio LibFileSystem)
target_link_libraries(aconv PRIVATE LibAudio LibFileSystem)
@ -91,13 +56,3 @@ target_link_libraries(zip PRIVATE LibArchive LibFileSystem)
# FIXME: Link this file into headless-browser without compiling it again.
target_sources(headless-browser PRIVATE "${SerenityOS_SOURCE_DIR}/Userland/Services/WebContent/WebDriverConnection.cpp")
include("${SerenityOS_SOURCE_DIR}/Meta/Lagom/Fuzzers/fuzzers.cmake")
foreach(name IN LISTS FUZZER_TARGETS)
set(fuzz_source_file "${SerenityOS_SOURCE_DIR}/Meta/Lagom/Fuzzers/Fuzz${name}.cpp")
target_sources(test-fuzz PRIVATE "${fuzz_source_file}")
set_source_files_properties("${fuzz_source_file}" PROPERTIES COMPILE_DEFINITIONS "LLVMFuzzerTestOneInput=Test${name}")
set_source_files_properties("${fuzz_source_file}" PROPERTIES COMPILE_OPTIONS "-Wno-missing-declarations")
target_link_libraries(test-fuzz PRIVATE "${FUZZER_DEPENDENCIES_${name}}")
endforeach()