From 86c1d97e3c3041c9a5e96f12e4cf7bc183cb5187 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Wed, 21 Feb 2024 16:16:15 -0700 Subject: [PATCH] Ladybird: Always place helper processes in bundle directory on macOS Don't put them in bin/ and then copy them to the bundle dir later, as this means that they only get updated in the bundle directory if the Ladybird binary itself needs updated. Which is not a fun workflow if you are working on WPT and want to hack on the WebDriver binary. --- Ladybird/CMakeLists.txt | 29 +++++++++++++---------------- Ladybird/cmake/InstallRules.cmake | 2 +- Tests/LibWeb/WPT/run.sh | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index 7258d7d06b7..d53c8b68959 100644 --- a/Ladybird/CMakeLists.txt +++ b/Ladybird/CMakeLists.txt @@ -182,6 +182,13 @@ target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/) target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Applications/) target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/) +function(set_ladybird_helper_output_directory target_name) + if (APPLE) + # Store helper processes in the same bundle directory as the main application + set_target_properties(${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$") + endif() +endfunction() + add_executable(headless-browser ${SERENITY_SOURCE_DIR}/Userland/Utilities/headless-browser.cpp ${SERENITY_SOURCE_DIR}/Userland/Services/WebContent/WebDriverConnection.cpp @@ -213,7 +220,9 @@ add_subdirectory(WebContent) add_subdirectory(WebDriver) add_subdirectory(WebSocket) add_subdirectory(WebWorker) -add_dependencies(ladybird ImageDecoder RequestServer SQLServer WebContent WebDriver WebSocketServer WebWorker headless-browser) + +set(ladybird_helper_processes ImageDecoder RequestServer SQLServer WebContent WebDriver WebSocketServer WebWorker headless-browser) +add_dependencies(ladybird ${ladybird_helper_processes}) function(create_ladybird_bundle target_name) set_target_properties(${target_name} PROPERTIES @@ -228,18 +237,8 @@ function(create_ladybird_bundle target_name) ) if (APPLE) - # FIXME: Create a proper app bundle for each helper process - set(app_dir "$") set(bundle_dir "$") add_custom_command(TARGET ${target_name} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "${app_dir}" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "${app_dir}" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "${app_dir}" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "${app_dir}" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "${app_dir}" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "${app_dir}" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "${app_dir}" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "${app_dir}" COMMAND "mkdir" -p "${bundle_dir}/Contents/Resources" COMMAND "iconutil" --convert icns "${SERENITY_SOURCE_DIR}/Ladybird/Icons/macos/app_icon.iconset" --output "${bundle_dir}/Contents/Resources/app_icon.icns" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${Lagom_BINARY_DIR}/cacert.pem" "${bundle_dir}/Contents" @@ -248,6 +247,9 @@ function(create_ladybird_bundle target_name) endfunction() create_ladybird_bundle(ladybird) +foreach(helper_process IN LISTS ladybird_helper_processes) + set_ladybird_helper_output_directory(${helper_process}) +endforeach() if(NOT CMAKE_SKIP_INSTALL_RULES) include(cmake/InstallRules.cmake) @@ -269,9 +271,4 @@ if (BUILD_TESTING) ENVIRONMENT QT_QPA_PLATFORM=offscreen ENVIRONMENT "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}" ) - if (APPLE) - set_tests_properties(LibWeb WPT PROPERTIES - ENVIRONMENT "WEBDRIVER_BINARY=$/$" - ) - endif() endif() diff --git a/Ladybird/cmake/InstallRules.cmake b/Ladybird/cmake/InstallRules.cmake index f20dca357db..1903adbd757 100644 --- a/Ladybird/cmake/InstallRules.cmake +++ b/Ladybird/cmake/InstallRules.cmake @@ -4,7 +4,7 @@ include(GNUInstallDirs) set(package ladybird) -set(ladybird_applications ladybird SQLServer WebContent WebDriver WebSocketServer RequestServer ImageDecoder WebWorker headless-browser) +set(ladybird_applications ladybird ${ladybird_helper_processes}) set(app_install_targets ${ladybird_applications}) diff --git a/Tests/LibWeb/WPT/run.sh b/Tests/LibWeb/WPT/run.sh index 072dff006bf..ddcad99936e 100755 --- a/Tests/LibWeb/WPT/run.sh +++ b/Tests/LibWeb/WPT/run.sh @@ -11,7 +11,7 @@ then fi -: "${WEBDRIVER_BINARY:=$(env PATH="${SERENITY_SOURCE_DIR}/Build/lagom/bin:${SERENITY_SOURCE_DIR}/Meta/Lagom/Build/bin:${PATH}" \ +: "${WEBDRIVER_BINARY:=$(env PATH="${SERENITY_SOURCE_DIR}/Build/lagom/bin/Ladybird.app/Contents/MacOS:${SERENITY_SOURCE_DIR}/Build/lagom/bin:${SERENITY_SOURCE_DIR}/Meta/Lagom/Build/bin:${PATH}" \ which WebDriver)}" update_expectations_metadata=false