mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Ladybird: Move helper processes to CMAKE_INSTALL_LIBEXECDIR
It aligns better with the Filesystem Heirarchy Standard[1] to put our program-specific helper programs that are not intended to be executed by the user of the application in $prefix/libexec or in whatever the packager sets as the CMake equivalent. Namely, on Debian systems this should be /usr/lib/Ladybird or similar. [1] https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#usrlibexec
This commit is contained in:
parent
c83e50af0b
commit
ea59bfaae7
Notes:
sideshowbarker
2024-07-17 01:21:02 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/ea59bfaae7 Pull-request: https://github.com/SerenityOS/serenity/pull/23304 Reviewed-by: https://github.com/clausecker Reviewed-by: https://github.com/timschumi ✅ Reviewed-by: https://github.com/trflynn89 ✅
12 changed files with 61 additions and 13 deletions
|
@ -182,10 +182,18 @@ 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/Applications/)
|
||||||
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/)
|
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/)
|
||||||
|
|
||||||
function(set_ladybird_helper_output_directory target_name)
|
function(set_helper_process_properties)
|
||||||
|
set(targets ${ARGV})
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
# Store helper processes in the same bundle directory as the main application
|
# Store helper processes in the same bundle directory as the main application
|
||||||
set_target_properties(${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<TARGET_FILE_DIR:ladybird>")
|
set_target_properties(${targets} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<TARGET_FILE_DIR:ladybird>")
|
||||||
|
else()
|
||||||
|
set_target_properties(${targets} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBEXECDIR}")
|
||||||
|
|
||||||
|
if (NOT CMAKE_INSTALL_LIBEXECDIR STREQUAL "libexec")
|
||||||
|
set_source_files_properties(Utilities.cpp PROPERTIES COMPILE_DEFINITIONS LADYBIRD_LIBEXECDIR="${CMAKE_INSTALL_LIBEXECDIR}")
|
||||||
|
set_source_files_properties(Utilities.cpp TARGET_DIRECTORY ${targets} PROPERTIES COMPILE_DEFINITIONS LADYBIRD_LIBEXECDIR="${CMAKE_INSTALL_LIBEXECDIR}")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
@ -246,9 +254,7 @@ function(create_ladybird_bundle target_name)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
create_ladybird_bundle(ladybird)
|
create_ladybird_bundle(ladybird)
|
||||||
foreach(helper_process IN LISTS ladybird_helper_processes)
|
set_helper_process_properties(${ladybird_helper_processes})
|
||||||
set_ladybird_helper_output_directory(${helper_process})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
include(cmake/ResourceFiles.cmake)
|
include(cmake/ResourceFiles.cmake)
|
||||||
set(resource_base_dir "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Lagom")
|
set(resource_base_dir "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Lagom")
|
||||||
|
|
|
@ -12,6 +12,16 @@
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibFileSystem/FileSystem.h>
|
#include <LibFileSystem/FileSystem.h>
|
||||||
|
|
||||||
|
#define TOKENCAT(x, y) x##y
|
||||||
|
#define STRINGIFY(x) TOKENCAT(x, sv)
|
||||||
|
|
||||||
|
// This is expected to be set from the build scripts, if a packager desires
|
||||||
|
#if defined(LADYBIRD_LIBEXECDIR)
|
||||||
|
constexpr auto libexec_path = STRINGIFY(LADYBIRD_LIBEXECDIR);
|
||||||
|
#else
|
||||||
|
constexpr auto libexec_path = "libexec"sv;
|
||||||
|
#endif
|
||||||
|
|
||||||
ByteString s_serenity_resource_root;
|
ByteString s_serenity_resource_root;
|
||||||
|
|
||||||
ErrorOr<ByteString> application_directory()
|
ErrorOr<ByteString> application_directory()
|
||||||
|
@ -20,22 +30,34 @@ ErrorOr<ByteString> application_directory()
|
||||||
return LexicalPath::dirname(current_executable_path);
|
return LexicalPath::dirname(current_executable_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::used]] static LexicalPath find_prefix(LexicalPath const& application_directory);
|
||||||
|
static LexicalPath find_prefix(LexicalPath const& application_directory)
|
||||||
|
{
|
||||||
|
if (application_directory.string().ends_with(libexec_path)) {
|
||||||
|
// Strip libexec_path if it's there
|
||||||
|
return LexicalPath(application_directory.string().substring_view(0, application_directory.string().length() - libexec_path.length()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, we are in $prefix/bin
|
||||||
|
return application_directory.parent();
|
||||||
|
}
|
||||||
|
|
||||||
void platform_init()
|
void platform_init()
|
||||||
{
|
{
|
||||||
s_serenity_resource_root = [] {
|
s_serenity_resource_root = [] {
|
||||||
auto* home = getenv("XDG_CONFIG_HOME") ?: getenv("HOME");
|
auto* home = getenv("XDG_CONFIG_HOME") ?: getenv("HOME");
|
||||||
VERIFY(home);
|
if (home != nullptr) {
|
||||||
auto home_lagom = ByteString::formatted("{}/.lagom", home);
|
auto home_lagom = ByteString::formatted("{}/.lagom", home);
|
||||||
if (FileSystem::is_directory(home_lagom))
|
if (FileSystem::is_directory(home_lagom))
|
||||||
return home_lagom;
|
return home_lagom;
|
||||||
|
}
|
||||||
auto app_dir = MUST(application_directory());
|
auto app_dir = MUST(application_directory());
|
||||||
#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/Lagom"sv).string();
|
return find_prefix(LexicalPath(app_dir)).append("share/Lagom"sv).string();
|
||||||
#endif
|
#endif
|
||||||
}();
|
}();
|
||||||
|
|
||||||
Core::ResourceImplementation::install(make<Core::ResourceImplementationFile>(MUST(String::from_byte_string(s_serenity_resource_root))));
|
Core::ResourceImplementation::install(make<Core::ResourceImplementationFile>(MUST(String::from_byte_string(s_serenity_resource_root))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +66,11 @@ ErrorOr<Vector<ByteString>> get_paths_for_helper_process(StringView process_name
|
||||||
auto application_path = TRY(application_directory());
|
auto application_path = TRY(application_directory());
|
||||||
Vector<ByteString> paths;
|
Vector<ByteString> paths;
|
||||||
|
|
||||||
|
#if !defined(AK_OS_MACOS)
|
||||||
|
auto prefix = find_prefix(LexicalPath(application_path));
|
||||||
|
TRY(paths.try_append(LexicalPath::join(prefix.string(), libexec_path, process_name).string()));
|
||||||
|
TRY(paths.try_append(LexicalPath::join(prefix.string(), "bin"sv, process_name).string()));
|
||||||
|
#endif
|
||||||
TRY(paths.try_append(ByteString::formatted("{}/{}", application_path, process_name)));
|
TRY(paths.try_append(ByteString::formatted("{}/{}", application_path, process_name)));
|
||||||
TRY(paths.try_append(ByteString::formatted("./{}", process_name)));
|
TRY(paths.try_append(ByteString::formatted("./{}", process_name)));
|
||||||
// NOTE: Add platform-specific paths here
|
// NOTE: Add platform-specific paths here
|
||||||
|
|
|
@ -8,7 +8,7 @@ set(ladybird_applications ladybird ${ladybird_helper_processes})
|
||||||
|
|
||||||
set(app_install_targets ${ladybird_applications})
|
set(app_install_targets ${ladybird_applications})
|
||||||
|
|
||||||
install(TARGETS ${app_install_targets}
|
install(TARGETS ladybird
|
||||||
EXPORT ladybirdTargets
|
EXPORT ladybirdTargets
|
||||||
RUNTIME
|
RUNTIME
|
||||||
COMPONENT ladybird_Runtime
|
COMPONENT ladybird_Runtime
|
||||||
|
@ -26,6 +26,13 @@ install(TARGETS ${app_install_targets}
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
install(TARGETS ${ladybird_helper_processes}
|
||||||
|
EXPORT ladybirdTargets
|
||||||
|
RUNTIME
|
||||||
|
COMPONENT ladybird_Runtime
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}
|
||||||
|
)
|
||||||
|
|
||||||
include("${SERENITY_SOURCE_DIR}/Meta/Lagom/get_linked_lagom_libraries.cmake")
|
include("${SERENITY_SOURCE_DIR}/Meta/Lagom/get_linked_lagom_libraries.cmake")
|
||||||
foreach (application IN LISTS ladybird_applications)
|
foreach (application IN LISTS ladybird_applications)
|
||||||
get_linked_lagom_libraries("${application}" "${application}_lagom_libraries")
|
get_linked_lagom_libraries("${application}" "${application}_lagom_libraries")
|
||||||
|
|
|
@ -181,6 +181,7 @@ executable("headless-browser") {
|
||||||
"HelperProcess.cpp",
|
"HelperProcess.cpp",
|
||||||
"Utilities.cpp",
|
"Utilities.cpp",
|
||||||
]
|
]
|
||||||
|
output_dir = "$root_out_dir/libexec"
|
||||||
}
|
}
|
||||||
|
|
||||||
fonts = [
|
fonts = [
|
||||||
|
|
|
@ -16,4 +16,5 @@ executable("ImageDecoder") {
|
||||||
"//Userland/Services/ImageDecoder/ConnectionFromClient.cpp",
|
"//Userland/Services/ImageDecoder/ConnectionFromClient.cpp",
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
]
|
]
|
||||||
|
output_dir = "$root_out_dir/libexec"
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,5 @@ executable("RequestServer") {
|
||||||
"//Userland/Services/RequestServer/Request.cpp",
|
"//Userland/Services/RequestServer/Request.cpp",
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
]
|
]
|
||||||
|
output_dir = "$root_out_dir/libexec"
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,5 @@ executable("SQLServer") {
|
||||||
"//Userland/Services/SQLServer/SQLStatement.cpp",
|
"//Userland/Services/SQLServer/SQLStatement.cpp",
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
]
|
]
|
||||||
|
output_dir = "$root_out_dir/libexec"
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,4 +81,5 @@ executable("WebContent") {
|
||||||
cflags_cc = [ "-DHAS_ACCELERATED_GRAPHICS" ]
|
cflags_cc = [ "-DHAS_ACCELERATED_GRAPHICS" ]
|
||||||
deps += [ "//Userland/Libraries/LibAccelGfx" ]
|
deps += [ "//Userland/Libraries/LibAccelGfx" ]
|
||||||
}
|
}
|
||||||
|
output_dir = "$root_out_dir/libexec"
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,5 @@ executable("WebDriver") {
|
||||||
"//Userland/Services/WebDriver/WebContentConnection.cpp",
|
"//Userland/Services/WebDriver/WebContentConnection.cpp",
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
]
|
]
|
||||||
|
output_dir = "$root_out_dir/libexec"
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,5 @@ executable("WebSocket") {
|
||||||
"//Userland/Services/WebSocket/ConnectionFromClient.cpp",
|
"//Userland/Services/WebSocket/ConnectionFromClient.cpp",
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
]
|
]
|
||||||
|
output_dir = "$root_out_dir/libexec"
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,5 @@ executable("WebWorker") {
|
||||||
"//Userland/Services/WebWorker/PageHost.cpp",
|
"//Userland/Services/WebWorker/PageHost.cpp",
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
]
|
]
|
||||||
|
output_dir = "$root_out_dir/libexec"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
: "${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}" \
|
: "${WEBDRIVER_BINARY:=$(env PATH="${SERENITY_SOURCE_DIR}/Build/lagom/bin/Ladybird.app/Contents/MacOS:${SERENITY_SOURCE_DIR}/Build/lagom/libexec:${SERENITY_SOURCE_DIR}/Meta/Lagom/Build/libexec:${PATH}" \
|
||||||
which WebDriver)}"
|
which WebDriver)}"
|
||||||
update_expectations_metadata=false
|
update_expectations_metadata=false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue