mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
Ladybird: Remove $SERENITY_SOURCE_DIR from resource root candidates
Now we will only load resources from $build/share/Lagom. On macOS, we load from the bundle directory Contents/Resources instead. This simplifies the commands and environment variables needed to execute Ladybird from the build directory, and makes our install setup less awkward for distributions and packagers.
This commit is contained in:
parent
21ac431fac
commit
68402bec12
8 changed files with 38 additions and 80 deletions
|
@ -23,14 +23,9 @@
|
||||||
// FIXME: Share b/w RequestServer and WebSocket
|
// FIXME: Share b/w RequestServer and WebSocket
|
||||||
ErrorOr<ByteString> find_certificates(StringView serenity_resource_root)
|
ErrorOr<ByteString> find_certificates(StringView serenity_resource_root)
|
||||||
{
|
{
|
||||||
auto cert_path = ByteString::formatted("{}/res/ladybird/cacert.pem", serenity_resource_root);
|
auto cert_path = ByteString::formatted("{}/ladybird/cacert.pem", serenity_resource_root);
|
||||||
if (!FileSystem::exists(cert_path)) {
|
|
||||||
auto app_dir = LexicalPath::dirname(TRY(Core::System::current_executable_path()));
|
|
||||||
|
|
||||||
cert_path = ByteString::formatted("{}/cacert.pem", LexicalPath(app_dir).parent());
|
|
||||||
if (!FileSystem::exists(cert_path))
|
if (!FileSystem::exists(cert_path))
|
||||||
return Error::from_string_view("Don't know how to load certs!"sv);
|
return Error::from_string_view("Don't know how to load certs!"sv);
|
||||||
}
|
|
||||||
return cert_path;
|
return cert_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,9 @@
|
||||||
// FIXME: Share b/w RequestServer and WebSocket
|
// FIXME: Share b/w RequestServer and WebSocket
|
||||||
ErrorOr<ByteString> find_certificates(StringView serenity_resource_root)
|
ErrorOr<ByteString> find_certificates(StringView serenity_resource_root)
|
||||||
{
|
{
|
||||||
auto cert_path = ByteString::formatted("{}/res/ladybird/cacert.pem", serenity_resource_root);
|
auto cert_path = ByteString::formatted("{}/ladybird/cacert.pem", serenity_resource_root);
|
||||||
if (!FileSystem::exists(cert_path)) {
|
|
||||||
auto app_dir = LexicalPath::dirname(TRY(Core::System::current_executable_path()));
|
|
||||||
|
|
||||||
cert_path = ByteString::formatted("{}/cacert.pem", LexicalPath(app_dir).parent());
|
|
||||||
if (!FileSystem::exists(cert_path))
|
if (!FileSystem::exists(cert_path))
|
||||||
return Error::from_string_view("Don't know how to load certs!"sv);
|
return Error::from_string_view("Don't know how to load certs!"sv);
|
||||||
}
|
|
||||||
return cert_path;
|
return cert_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,9 @@
|
||||||
// FIXME: Share b/w RequestServer and WebSocket
|
// FIXME: Share b/w RequestServer and WebSocket
|
||||||
ErrorOr<ByteString> find_certificates(StringView serenity_resource_root)
|
ErrorOr<ByteString> find_certificates(StringView serenity_resource_root)
|
||||||
{
|
{
|
||||||
auto cert_path = ByteString::formatted("{}/res/ladybird/cacert.pem", serenity_resource_root);
|
auto cert_path = ByteString::formatted("{}/ladybird/cacert.pem", serenity_resource_root);
|
||||||
if (!FileSystem::exists(cert_path)) {
|
|
||||||
auto app_dir = LexicalPath::dirname(TRY(Core::System::current_executable_path()));
|
|
||||||
|
|
||||||
cert_path = ByteString::formatted("{}/cacert.pem", LexicalPath(app_dir).parent());
|
|
||||||
if (!FileSystem::exists(cert_path))
|
if (!FileSystem::exists(cert_path))
|
||||||
return Error::from_string_view("Don't know how to load certs!"sv);
|
return Error::from_string_view("Don't know how to load certs!"sv);
|
||||||
}
|
|
||||||
return cert_path;
|
return cert_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,6 @@ ErrorOr<ByteString> application_directory()
|
||||||
void platform_init()
|
void platform_init()
|
||||||
{
|
{
|
||||||
s_serenity_resource_root = [] {
|
s_serenity_resource_root = [] {
|
||||||
auto const* source_dir = getenv("SERENITY_SOURCE_DIR");
|
|
||||||
if (source_dir) {
|
|
||||||
return ByteString::formatted("{}/Base", source_dir);
|
|
||||||
}
|
|
||||||
auto* home = getenv("XDG_CONFIG_HOME") ?: getenv("HOME");
|
auto* home = getenv("XDG_CONFIG_HOME") ?: getenv("HOME");
|
||||||
VERIFY(home);
|
VERIFY(home);
|
||||||
auto home_lagom = ByteString::formatted("{}/.lagom", home);
|
auto home_lagom = ByteString::formatted("{}/.lagom", home);
|
||||||
|
@ -36,11 +32,11 @@ void platform_init()
|
||||||
#ifdef AK_OS_MACOS
|
#ifdef AK_OS_MACOS
|
||||||
return LexicalPath(app_dir).parent().append("Resources"sv).string();
|
return LexicalPath(app_dir).parent().append("Resources"sv).string();
|
||||||
#else
|
#else
|
||||||
return LexicalPath(app_dir).parent().append("share"sv).string();
|
return LexicalPath(app_dir).parent().append("share/Lagom"sv).string();
|
||||||
#endif
|
#endif
|
||||||
}();
|
}();
|
||||||
|
|
||||||
Core::ResourceImplementation::install(make<Core::ResourceImplementationFile>(MUST(String::formatted("{}/res", s_serenity_resource_root))));
|
Core::ResourceImplementation::install(make<Core::ResourceImplementationFile>(MUST(String::from_byte_string(s_serenity_resource_root))));
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<Vector<ByteString>> get_paths_for_helper_process(StringView process_name)
|
ErrorOr<Vector<ByteString>> get_paths_for_helper_process(StringView process_name)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
#include <LibCore/LocalServer.h>
|
#include <LibCore/LocalServer.h>
|
||||||
#include <LibCore/Process.h>
|
#include <LibCore/Process.h>
|
||||||
|
#include <LibCore/Resource.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibCore/SystemServerTakeover.h>
|
#include <LibCore/SystemServerTakeover.h>
|
||||||
#include <LibIPC/ConnectionFromClient.h>
|
#include <LibIPC/ConnectionFromClient.h>
|
||||||
|
@ -142,16 +143,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
static ErrorOr<void> load_content_filters()
|
static ErrorOr<void> load_content_filters()
|
||||||
{
|
{
|
||||||
auto file_or_error = Core::File::open(ByteString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read);
|
|
||||||
if (file_or_error.is_error())
|
|
||||||
file_or_error = Core::File::open(ByteString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read);
|
|
||||||
if (file_or_error.is_error())
|
|
||||||
return file_or_error.release_error();
|
|
||||||
|
|
||||||
auto file = file_or_error.release_value();
|
|
||||||
auto ad_filter_list = TRY(Core::InputBufferedFile::create(move(file)));
|
|
||||||
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
|
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
|
||||||
|
|
||||||
|
auto resource = TRY(Core::Resource::load_from_uri("resource://ladybird/BrowserContentFilters.txt"sv));
|
||||||
|
auto ad_filter_list = TRY(InputBufferedSeekable<FixedMemoryStream>::create(make<FixedMemoryStream>(resource->data())));
|
||||||
|
|
||||||
Vector<String> patterns;
|
Vector<String> patterns;
|
||||||
|
|
||||||
while (TRY(ad_filter_list->can_read_line())) {
|
while (TRY(ad_filter_list->can_read_line())) {
|
||||||
|
@ -171,16 +167,11 @@ static ErrorOr<void> load_content_filters()
|
||||||
|
|
||||||
static ErrorOr<void> load_autoplay_allowlist()
|
static ErrorOr<void> load_autoplay_allowlist()
|
||||||
{
|
{
|
||||||
auto file_or_error = Core::File::open(TRY(String::formatted("{}/home/anon/.config/BrowserAutoplayAllowlist.txt", s_serenity_resource_root)), Core::File::OpenMode::Read);
|
|
||||||
if (file_or_error.is_error())
|
|
||||||
file_or_error = Core::File::open(TRY(String::formatted("{}/res/ladybird/BrowserAutoplayAllowlist.txt", s_serenity_resource_root)), Core::File::OpenMode::Read);
|
|
||||||
if (file_or_error.is_error())
|
|
||||||
return file_or_error.release_error();
|
|
||||||
|
|
||||||
auto file = file_or_error.release_value();
|
|
||||||
auto allowlist = TRY(Core::InputBufferedFile::create(move(file)));
|
|
||||||
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
|
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
|
||||||
|
|
||||||
|
auto resource = TRY(Core::Resource::load_from_uri("resource://ladybird/BrowserAutoplayAllowlist.txt"sv));
|
||||||
|
auto allowlist = TRY(InputBufferedSeekable<FixedMemoryStream>::create(make<FixedMemoryStream>(resource->data())));
|
||||||
|
|
||||||
Vector<String> origins;
|
Vector<String> origins;
|
||||||
|
|
||||||
while (TRY(allowlist->can_read_line())) {
|
while (TRY(allowlist->can_read_line())) {
|
||||||
|
|
|
@ -19,14 +19,9 @@
|
||||||
// FIXME: Share b/w RequestServer and WebSocket
|
// FIXME: Share b/w RequestServer and WebSocket
|
||||||
ErrorOr<ByteString> find_certificates(StringView serenity_resource_root)
|
ErrorOr<ByteString> find_certificates(StringView serenity_resource_root)
|
||||||
{
|
{
|
||||||
auto cert_path = ByteString::formatted("{}/res/ladybird/cacert.pem", serenity_resource_root);
|
auto cert_path = ByteString::formatted("{}/ladybird/cacert.pem", serenity_resource_root);
|
||||||
if (!FileSystem::exists(cert_path)) {
|
|
||||||
auto app_dir = LexicalPath::dirname(TRY(Core::System::current_executable_path()));
|
|
||||||
|
|
||||||
cert_path = ByteString::formatted("{}/cacert.pem", LexicalPath(app_dir).parent());
|
|
||||||
if (!FileSystem::exists(cert_path))
|
if (!FileSystem::exists(cert_path))
|
||||||
return Error::from_string_view("Don't know how to load certs!"sv);
|
return Error::from_string_view("Don't know how to load certs!"sv);
|
||||||
}
|
|
||||||
return cert_path;
|
return cert_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
set(package ladybird)
|
set(package Ladybird)
|
||||||
|
|
||||||
set(ladybird_applications ladybird ${ladybird_helper_processes})
|
set(ladybird_applications ladybird ${ladybird_helper_processes})
|
||||||
|
|
||||||
|
@ -94,42 +94,21 @@ install(
|
||||||
COMPONENT ladybird_Development
|
COMPONENT ladybird_Development
|
||||||
)
|
)
|
||||||
|
|
||||||
install(DIRECTORY
|
if (NOT APPLE)
|
||||||
"${SERENITY_SOURCE_DIR}/Base/res/fonts"
|
# On macOS the resources are handled via the MACOSX_PACKAGE_LOCATION property on each resource file
|
||||||
"${SERENITY_SOURCE_DIR}/Base/res/icons"
|
install_ladybird_resources("${CMAKE_INSTALL_DATADIR}/Lagom" ladybird_Runtime)
|
||||||
"${SERENITY_SOURCE_DIR}/Base/res/ladybird"
|
endif()
|
||||||
"${SERENITY_SOURCE_DIR}/Base/res/themes"
|
|
||||||
"${SERENITY_SOURCE_DIR}/Base/res/color-palettes"
|
|
||||||
"${SERENITY_SOURCE_DIR}/Base/res/cursor-themes"
|
|
||||||
DESTINATION "${CMAKE_INSTALL_DATADIR}/res"
|
|
||||||
USE_SOURCE_PERMISSIONS MESSAGE_NEVER
|
|
||||||
COMPONENT ladybird_Runtime
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES
|
|
||||||
"${SERENITY_SOURCE_DIR}/Base/home/anon/.config/BrowserAutoplayAllowlist.txt"
|
|
||||||
"${SERENITY_SOURCE_DIR}/Base/home/anon/.config/BrowserContentFilters.txt"
|
|
||||||
"${Lagom_BINARY_DIR}/cacert.pem"
|
|
||||||
DESTINATION "${CMAKE_INSTALL_DATADIR}/res/ladybird"
|
|
||||||
COMPONENT ladybird_Runtime
|
|
||||||
)
|
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
# Fixup the app bundle and copy:
|
# Fixup the app bundle and copy:
|
||||||
# - Libraries from lib/ to Ladybird.app/Contents/lib
|
# - Libraries from lib/ to Ladybird.app/Contents/lib
|
||||||
# - Resources from share/res/ to Ladybird.app/Contents/Resources/res
|
|
||||||
install(CODE "
|
install(CODE "
|
||||||
set(res_dir \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/res)
|
|
||||||
if (IS_ABSOLUTE ${CMAKE_INSTALL_DATADIR})
|
|
||||||
set(res_dir ${CMAKE_INSTALL_DATADIR}/res)
|
|
||||||
endif()
|
|
||||||
set(lib_dir \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
|
set(lib_dir \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
|
||||||
if (IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
|
if (IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
|
||||||
set(lib_dir ${CMAKE_INSTALL_LIBDIR})
|
set(lib_dir ${CMAKE_INSTALL_LIBDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(contents_dir \${CMAKE_INSTALL_PREFIX}/bundle/Ladybird.app/Contents)
|
set(contents_dir \${CMAKE_INSTALL_PREFIX}/bundle/Ladybird.app/Contents)
|
||||||
file(COPY \${res_dir} DESTINATION \${contents_dir}/Resources)
|
|
||||||
file(COPY \${lib_dir} DESTINATION \${contents_dir})
|
file(COPY \${lib_dir} DESTINATION \${contents_dir})
|
||||||
"
|
"
|
||||||
COMPONENT ladybird_Runtime)
|
COMPONENT ladybird_Runtime)
|
||||||
|
|
|
@ -163,3 +163,15 @@ function(copy_resources_to_build base_directory bundle_target)
|
||||||
|
|
||||||
add_dependencies(${bundle_target} "${bundle_target}_build_resource_files")
|
add_dependencies(${bundle_target} "${bundle_target}_build_resource_files")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(install_ladybird_resources destination component)
|
||||||
|
install(FILES ${FONTS} DESTINATION "${destination}/fonts" COMPONENT ${component})
|
||||||
|
install(FILES ${16x16_ICONS} DESTINATION "${destination}/icons/16x16" COMPONENT ${component})
|
||||||
|
install(FILES ${32x32_ICONS} DESTINATION "${destination}/icons/32x32" COMPONENT ${component})
|
||||||
|
install(FILES ${BROWSER_ICONS} DESTINATION "${destination}/icons/browser" COMPONENT ${component})
|
||||||
|
install(FILES ${THEMES} DESTINATION "${destination}/themes" COMPONENT ${component})
|
||||||
|
install(FILES ${WEB_RESOURCES} DESTINATION "${destination}/ladybird" COMPONENT ${component})
|
||||||
|
install(FILES ${WEB_TEMPLATES} DESTINATION "${destination}/ladybird/templates" COMPONENT ${component})
|
||||||
|
install(FILES ${CONFIG_RESOURCES} DESTINATION "${destination}/ladybird" COMPONENT ${component})
|
||||||
|
install(FILES ${DOWNLOADED_RESOURCES} DESTINATION "${destination}/ladybird" COMPONENT ${component})
|
||||||
|
endfunction()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue