From 79365c9519dfd2a99375676742bf2ed48fa205dc Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 10 Oct 2024 11:05:10 -0400 Subject: [PATCH] UI: Migrate headless-browser to be alongside other Ladybird chromes The headless-browser source is getting a bit unwieldy. The ordering of class and method definitions is fragile; e.g. the application and web view classes each require full definitions of each other. So it has reached the point where it makes sense to give headless-browser some better file structure. To prepare for that, this patch simply moves its source to live along- side the other browser chromes. This location is a bit better prepared for creating more files, as the Utilities folder doesn't even have its own CMakeLists.txt. --- Ladybird/CMakeLists.txt | 19 +++---------------- Ladybird/Headless/CMakeLists.txt | 16 ++++++++++++++++ .../Headless/main.cpp | 2 +- 3 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 Ladybird/Headless/CMakeLists.txt rename Userland/Utilities/headless-browser.cpp => Ladybird/Headless/main.cpp (99%) diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index 308cd9423e1..77d5b51c284 100644 --- a/Ladybird/CMakeLists.txt +++ b/Ladybird/CMakeLists.txt @@ -90,7 +90,8 @@ else() set(LADYBIRD_TARGET ladybird PRIVATE) endif() -target_link_libraries(${LADYBIRD_TARGET} AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebView LibRequests LibURL) +set(LADYBIRD_LIBS AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebView LibRequests LibURL) +target_link_libraries(${LADYBIRD_TARGET} PRIVATE ${LADYBIRD_LIBS}) target_include_directories(${LADYBIRD_TARGET} ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(${LADYBIRD_TARGET} ${LADYBIRD_SOURCE_DIR}/Userland/) @@ -112,14 +113,6 @@ function(set_helper_process_properties) endif() endfunction() -add_executable(headless-browser - ${LADYBIRD_SOURCE_DIR}/Userland/Utilities/headless-browser.cpp - ${LADYBIRD_SOURCES}) - -target_include_directories(headless-browser PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_include_directories(headless-browser PRIVATE ${LADYBIRD_SOURCE_DIR}/Userland/) -target_link_libraries(headless-browser PRIVATE AK LibCore LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibHTTP LibImageDecoderClient LibJS LibGfx LibMain LibTLS LibIPC LibDiff LibRequests LibURL) - add_custom_target(run COMMAND "${CMAKE_COMMAND}" -E env "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}" "$" $ENV{LAGOM_ARGS} USES_TERMINAL @@ -138,6 +131,7 @@ else() ) endif() +add_subdirectory(Headless) add_subdirectory(ImageDecoder) add_subdirectory(RequestServer) add_subdirectory(WebContent) @@ -158,10 +152,3 @@ endif() if(NOT CMAKE_SKIP_INSTALL_RULES) include(cmake/InstallRules.cmake) endif() - -if (BUILD_TESTING) - add_test( - NAME LibWeb - COMMAND $ --run-tests ${LADYBIRD_SOURCE_DIR}/Tests/LibWeb --dump-failed-ref-tests --force-fontconfig - ) -endif() diff --git a/Ladybird/Headless/CMakeLists.txt b/Ladybird/Headless/CMakeLists.txt new file mode 100644 index 00000000000..337d17fec5b --- /dev/null +++ b/Ladybird/Headless/CMakeLists.txt @@ -0,0 +1,16 @@ +set(SOURCES + ${LADYBIRD_SOURCES} + main.cpp +) + +add_executable(headless-browser ${SOURCES}) +target_include_directories(headless-browser PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(headless-browser PRIVATE ${LADYBIRD_SOURCE_DIR}/Userland/) +target_link_libraries(headless-browser PRIVATE ${LADYBIRD_LIBS} LibDiff) + +if (BUILD_TESTING) + add_test( + NAME LibWeb + COMMAND $ --run-tests ${LADYBIRD_SOURCE_DIR}/Tests/LibWeb --dump-failed-ref-tests --force-fontconfig + ) +endif() diff --git a/Userland/Utilities/headless-browser.cpp b/Ladybird/Headless/main.cpp similarity index 99% rename from Userland/Utilities/headless-browser.cpp rename to Ladybird/Headless/main.cpp index 4610f7db533..fef52063a69 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Ladybird/Headless/main.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, Dex♪ - * Copyright (c) 2023, Tim Flynn + * Copyright (c) 2023-2024, Tim Flynn * Copyright (c) 2023, Andreas Kling * Copyright (c) 2023-2024, Sam Atkins *