mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Ladybird: Add configuration option to build without Qt
This should open the door for adding more GUI chromes to the repository
This commit is contained in:
parent
1d78e07f6b
commit
79108f615d
Notes:
sideshowbarker
2024-07-16 20:05:14 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/79108f615d Pull-request: https://github.com/SerenityOS/serenity/pull/20417 Reviewed-by: https://github.com/awesomekling ✅ Reviewed-by: https://github.com/trflynn89
3 changed files with 101 additions and 57 deletions
|
@ -70,10 +70,18 @@ add_compile_options(-DAK_DONT_REPLACE_STD)
|
|||
add_compile_options(-Wno-expansion-to-defined)
|
||||
add_compile_options(-Wno-user-defined-literals)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network Multimedia)
|
||||
serenity_option(ENABLE_QT ON CACHE BOOL "Build ladybird application using Qt GUI")
|
||||
|
||||
if (APPLE AND NOT ENABLE_QT)
|
||||
message(FATAL_ERROR "Non-Qt builds not supported on macOS yet!")
|
||||
endif()
|
||||
|
||||
if (ENABLE_QT)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network Multimedia)
|
||||
endif()
|
||||
|
||||
set(BROWSER_SOURCE_DIR ${SERENITY_SOURCE_DIR}/Userland/Applications/Browser/)
|
||||
|
||||
|
@ -83,25 +91,45 @@ set(SOURCES
|
|||
${BROWSER_SOURCE_DIR}/History.cpp
|
||||
HelperProcess.cpp
|
||||
Utilities.cpp
|
||||
Qt/BrowserWindow.cpp
|
||||
Qt/ConsoleWidget.cpp
|
||||
Qt/EventLoopImplementationQt.cpp
|
||||
Qt/EventLoopImplementationQtEventTarget.cpp
|
||||
Qt/InspectorWidget.cpp
|
||||
Qt/LocationEdit.cpp
|
||||
Qt/ModelTranslator.cpp
|
||||
Qt/Settings.cpp
|
||||
Qt/SettingsDialog.cpp
|
||||
Qt/Tab.cpp
|
||||
Qt/TVGIconEngine.cpp
|
||||
Qt/StringUtils.cpp
|
||||
Qt/WebContentView.cpp
|
||||
Qt/ladybird.qrc
|
||||
Qt/main.cpp
|
||||
)
|
||||
|
||||
qt_add_executable(ladybird ${SOURCES})
|
||||
target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Network Qt::Widgets LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibWeb LibWebView LibSQL LibProtocol)
|
||||
if (ENABLE_QT)
|
||||
qt_add_executable(ladybird ${SOURCES})
|
||||
target_sources(ladybird PRIVATE
|
||||
Qt/BrowserWindow.cpp
|
||||
Qt/ConsoleWidget.cpp
|
||||
Qt/EventLoopImplementationQt.cpp
|
||||
Qt/EventLoopImplementationQtEventTarget.cpp
|
||||
Qt/InspectorWidget.cpp
|
||||
Qt/LocationEdit.cpp
|
||||
Qt/ModelTranslator.cpp
|
||||
Qt/Settings.cpp
|
||||
Qt/SettingsDialog.cpp
|
||||
Qt/Tab.cpp
|
||||
Qt/TVGIconEngine.cpp
|
||||
Qt/StringUtils.cpp
|
||||
Qt/WebContentView.cpp
|
||||
Qt/ladybird.qrc
|
||||
Qt/main.cpp
|
||||
)
|
||||
target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Network Qt::Widgets)
|
||||
|
||||
# FIXME: Set these for non-qt executables as well, when those exist
|
||||
set_target_properties(ladybird PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER org.SerenityOS.Ladybird
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
|
||||
MACOSX_BUNDLE TRUE
|
||||
WIN32_EXECUTABLE TRUE
|
||||
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER org.SerenityOS.Ladybird
|
||||
)
|
||||
else()
|
||||
# TODO: Check for other GUI frameworks here when we move them in-tree
|
||||
# For now, we can export a static library of common files for chromes to link to
|
||||
add_library(ladybird STATIC ${SOURCES})
|
||||
endif()
|
||||
target_link_libraries(ladybird PRIVATE LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibWeb LibWebView LibSQL LibProtocol)
|
||||
|
||||
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/)
|
||||
|
@ -117,16 +145,6 @@ add_executable(headless-browser
|
|||
target_include_directories(headless-browser PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(headless-browser PRIVATE LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibGemini LibHTTP LibJS LibGfx LibMain LibTLS LibIPC LibDiff LibProtocol)
|
||||
|
||||
set_target_properties(ladybird PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER org.SerenityOS.Ladybird
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
|
||||
MACOSX_BUNDLE TRUE
|
||||
WIN32_EXECUTABLE TRUE
|
||||
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER org.SerenityOS.Ladybird
|
||||
)
|
||||
|
||||
if (ANDROID)
|
||||
include(cmake/AndroidExtras.cmake)
|
||||
link_android_libs(headless-browser)
|
||||
|
|
|
@ -10,23 +10,31 @@ set(WEBCONTENT_SOURCES
|
|||
../HelperProcess.cpp
|
||||
../ImageCodecPlugin.cpp
|
||||
../Utilities.cpp
|
||||
../Qt/AudioCodecPluginQt.cpp
|
||||
../Qt/AudioThread.cpp
|
||||
../Qt/EventLoopImplementationQt.cpp
|
||||
../Qt/EventLoopImplementationQtEventTarget.cpp
|
||||
../Qt/RequestManagerQt.cpp
|
||||
../Qt/StringUtils.cpp
|
||||
../Qt/WebSocketClientManagerQt.cpp
|
||||
../Qt/WebSocketQt.cpp
|
||||
../Qt/WebSocketImplQt.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_add_executable(WebContent ${WEBCONTENT_SOURCES})
|
||||
if (ENABLE_QT)
|
||||
qt_add_executable(WebContent ${WEBCONTENT_SOURCES})
|
||||
target_sources(WebContent PRIVATE
|
||||
../Qt/AudioCodecPluginQt.cpp
|
||||
../Qt/AudioThread.cpp
|
||||
../Qt/EventLoopImplementationQt.cpp
|
||||
../Qt/EventLoopImplementationQtEventTarget.cpp
|
||||
../Qt/RequestManagerQt.cpp
|
||||
../Qt/StringUtils.cpp
|
||||
../Qt/WebSocketClientManagerQt.cpp
|
||||
../Qt/WebSocketQt.cpp
|
||||
../Qt/WebSocketImplQt.cpp
|
||||
)
|
||||
target_link_libraries(WebContent PRIVATE Qt::Core Qt::Network Qt::Multimedia)
|
||||
target_compile_definitions(WebContent PRIVATE HAVE_QT=1)
|
||||
else()
|
||||
add_executable(WebContent ${WEBCONTENT_SOURCES})
|
||||
endif()
|
||||
|
||||
target_include_directories(WebContent PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/)
|
||||
target_include_directories(WebContent PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..)
|
||||
target_link_libraries(WebContent PRIVATE Qt::Core Qt::Network Qt::Multimedia LibAudio LibCore LibFileSystem LibGfx LibIPC LibJS LibMain LibWeb LibWebSocket LibProtocol LibSQL LibWebView)
|
||||
target_link_libraries(WebContent PRIVATE LibAudio LibCore LibFileSystem LibGfx LibIPC LibJS LibMain LibWeb LibWebSocket LibProtocol LibSQL LibWebView)
|
||||
if (ANDROID)
|
||||
link_android_libs(WebContent)
|
||||
endif()
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
#include <Ladybird/FontPlugin.h>
|
||||
#include <Ladybird/HelperProcess.h>
|
||||
#include <Ladybird/ImageCodecPlugin.h>
|
||||
#include <Ladybird/Qt/AudioCodecPluginQt.h>
|
||||
#include <Ladybird/Qt/EventLoopImplementationQt.h>
|
||||
#include <Ladybird/Qt/RequestManagerQt.h>
|
||||
#include <Ladybird/Qt/WebSocketClientManagerQt.h>
|
||||
#include <Ladybird/Utilities.h>
|
||||
#include <LibAudio/Loader.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
|
@ -33,19 +29,29 @@
|
|||
#include <LibWeb/WebSockets/WebSocket.h>
|
||||
#include <LibWebView/RequestServerAdapter.h>
|
||||
#include <LibWebView/WebSocketClientAdapter.h>
|
||||
#include <QCoreApplication>
|
||||
#include <WebContent/ConnectionFromClient.h>
|
||||
#include <WebContent/PageHost.h>
|
||||
#include <WebContent/WebDriverConnection.h>
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
# include <Ladybird/Qt/AudioCodecPluginQt.h>
|
||||
# include <Ladybird/Qt/EventLoopImplementationQt.h>
|
||||
# include <Ladybird/Qt/RequestManagerQt.h>
|
||||
# include <Ladybird/Qt/WebSocketClientManagerQt.h>
|
||||
# include <QCoreApplication>
|
||||
#endif
|
||||
|
||||
static ErrorOr<void> load_content_filters();
|
||||
static ErrorOr<void> load_autoplay_allowlist();
|
||||
static ErrorOr<void> initialize_lagom_networking();
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
#if defined(HAVE_QT)
|
||||
QCoreApplication app(arguments.argc, arguments.argv);
|
||||
|
||||
Core::EventLoopManager::install(*new Ladybird::EventLoopManagerQt);
|
||||
#endif
|
||||
Core::EventLoop event_loop;
|
||||
|
||||
platform_init();
|
||||
|
@ -56,8 +62,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
Web::Platform::AudioCodecPlugin::install_creation_hook([](auto loader) {
|
||||
#if defined(HAVE_PULSEAUDIO)
|
||||
return Web::Platform::AudioCodecPluginAgnostic::create(move(loader));
|
||||
#else
|
||||
#elif defined(HAVE_QT)
|
||||
return Ladybird::AudioCodecPluginQt::create(move(loader));
|
||||
#else
|
||||
# error "Don't know how to initialize audio in this configuration!"
|
||||
#endif
|
||||
});
|
||||
|
||||
|
@ -73,17 +81,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_option(use_lagom_networking, "Enable Lagom servers for networking", "use-lagom-networking", 0);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
if (use_lagom_networking) {
|
||||
auto candidate_request_server_paths = TRY(get_paths_for_helper_process("RequestServer"sv));
|
||||
auto request_server_client = TRY(launch_request_server_process(candidate_request_server_paths, s_serenity_resource_root));
|
||||
Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create(move(request_server_client))));
|
||||
|
||||
auto candidate_web_socket_paths = TRY(get_paths_for_helper_process("WebSocket"sv));
|
||||
auto web_socket_client = TRY(launch_web_socket_process(candidate_web_socket_paths, s_serenity_resource_root));
|
||||
Web::WebSockets::WebSocketClientManager::initialize(TRY(WebView::WebSocketClientManagerAdapter::try_create(move(web_socket_client))));
|
||||
} else {
|
||||
#if defined(HAVE_QT)
|
||||
if (!use_lagom_networking) {
|
||||
Web::ResourceLoader::initialize(Ladybird::RequestManagerQt::create());
|
||||
Web::WebSockets::WebSocketClientManager::initialize(Ladybird::WebSocketClientManagerQt::create());
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
TRY(initialize_lagom_networking());
|
||||
}
|
||||
|
||||
Web::HTML::Window::set_internals_object_exposed(is_layout_test_mode);
|
||||
|
@ -168,3 +173,16 @@ static ErrorOr<void> load_autoplay_allowlist()
|
|||
|
||||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> initialize_lagom_networking()
|
||||
{
|
||||
auto candidate_request_server_paths = TRY(get_paths_for_helper_process("RequestServer"sv));
|
||||
auto request_server_client = TRY(launch_request_server_process(candidate_request_server_paths, s_serenity_resource_root));
|
||||
Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create(move(request_server_client))));
|
||||
|
||||
auto candidate_web_socket_paths = TRY(get_paths_for_helper_process("WebSocket"sv));
|
||||
auto web_socket_client = TRY(launch_web_socket_process(candidate_web_socket_paths, s_serenity_resource_root));
|
||||
Web::WebSockets::WebSocketClientManager::initialize(TRY(WebView::WebSocketClientManagerAdapter::try_create(move(web_socket_client))));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue