Title: [295294] trunk
Revision
295294
Author
[email protected]
Date
2022-06-06 13:24:52 -0700 (Mon, 06 Jun 2022)

Log Message

[CMake] Use playstation_module for shared libs
https://bugs.webkit.org/show_bug.cgi?id=241049

Reviewed by Ross Kirsling.

The playstation_module function determines how to properly load a shared library. It figures out
if a shared library is being used and if so will create a target to copy it to the directory it
will load from. Additionally it exposes a `${target}_LOAD_AT` variable that can be used with
dlopen.

* Source/_javascript_Core/shell/playstation/Initializer.cpp:
* Source/WTF/wtf/PlatformPlayStation.cmake:
* Source/WebCore/PlatformPlayStation.cmake:
* Source/WebKit/NetworkProcess/EntryPoint/playstation/NetworkProcessMain.cpp:
* Source/WebKit/WebProcess/EntryPoint/playstation/WebProcessMain.cpp:
* Source/cmake/OptionsPlayStation.cmake:
* Tools/MiniBrowser/playstation/CMakeLists.txt:
* Tools/MiniBrowser/playstation/main.cpp:
* Tools/TestWebKitAPI/PlatformPlayStation.cmake:
* Tools/TestWebKitAPI/playstation/main.cpp:

Canonical link: https://commits.webkit.org/251340@main

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/shell/playstation/Initializer.cpp (295293 => 295294)


--- trunk/Source/_javascript_Core/shell/playstation/Initializer.cpp	2022-06-06 20:13:32 UTC (rev 295293)
+++ trunk/Source/_javascript_Core/shell/playstation/Initializer.cpp	2022-06-06 20:24:52 UTC (rev 295294)
@@ -46,5 +46,5 @@
 #if !ENABLE(STATIC_JSC)
     loadLibraryOrExit("libJavaScriptCore");
 #endif
-    loadLibraryOrExit("libicu");
+    loadLibraryOrExit(ICU_LOAD_AT);
 }

Modified: trunk/Source/WTF/wtf/PlatformPlayStation.cmake (295293 => 295294)


--- trunk/Source/WTF/wtf/PlatformPlayStation.cmake	2022-06-06 20:13:32 UTC (rev 295293)
+++ trunk/Source/WTF/wtf/PlatformPlayStation.cmake	2022-06-06 20:24:52 UTC (rev 295294)
@@ -28,7 +28,7 @@
     Threads::Threads
 )
 
-PLAYSTATION_COPY_REQUIREMENTS(WTF_CopySharedLibs
-    FILES
-        ${ICU_LIBRARIES}
+PLAYSTATION_COPY_MODULES(WTF
+    TARGETS
+        ICU
 )

Modified: trunk/Source/WebCore/PlatformPlayStation.cmake (295293 => 295294)


--- trunk/Source/WebCore/PlatformPlayStation.cmake	2022-06-06 20:13:32 UTC (rev 295293)
+++ trunk/Source/WebCore/PlatformPlayStation.cmake	2022-06-06 20:24:52 UTC (rev 295294)
@@ -84,22 +84,37 @@
 foreach (EGL_EXTRA_NAME ${EGL_EXTRA_NAMES})
     find_file(${EGL_EXTRA_NAME}_FOUND ${EGL_EXTRA_NAME} PATH_SUFFIXES bin)
     if (${EGL_EXTRA_NAME}_FOUND)
-        list(APPEND EGL_EXTRAS ${${EGL_EXTRA_NAME}_FOUND})
+        set(_src ${${EGL_EXTRA_NAME}_FOUND})
+        get_filename_component(_filename ${_src} NAME)
+        set(_dst "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_filename}")
+
+        add_custom_command(OUTPUT ${_dst}
+            COMMAND ${CMAKE_COMMAND} -E copy ${_src} ${_dst}
+            MAIN_DEPENDENCY ${_src}
+            VERBATIM
+        )
+
+        list(APPEND EGL_EXTRAS ${_dst})
     endif ()
 endforeach ()
 
-PLAYSTATION_COPY_REQUIREMENTS(WebCore_CopySharedLibs
-    FILES
-        ${CURL_LIBRARIES}
-        ${Cairo_LIBRARIES}
-        ${EGL_LIBRARIES}
-        ${EGL_EXTRAS}
-        ${FREETYPE_LIBRARIES}
-        ${Fontconfig_LIBRARIES}
-        ${HarfBuzz_LIBRARIES}
-        ${JPEG_LIBRARIES}
-        ${OPENSSL_LIBRARIES}
-        ${PNG_LIBRARIES}
-        ${WebKitRequirements_LIBRARY}
-        ${WebP_LIBRARIES}
+if (EGL_EXTRAS)
+    add_custom_target(EGLExtras_Copy ALL DEPENDS ${EGL_EXTRAS})
+    set_target_properties(EGLExtras_Copy PROPERTIES FOLDER "PlayStation")
+    list(APPEND WebCore_INTERFACE_DEPENDENCIES EGLExtras_Copy)
+endif ()
+
+PLAYSTATION_COPY_MODULES(WebCore
+    TARGETS
+        CURL
+        Cairo
+        EGL
+        Fontconfig
+        Freetype
+        HarfBuzz
+        JPEG
+        OpenSSL
+        PNG
+        WebKitRequirements
+        WebP
 )

Modified: trunk/Source/WebKit/NetworkProcess/EntryPoint/playstation/NetworkProcessMain.cpp (295293 => 295294)


--- trunk/Source/WebKit/NetworkProcess/EntryPoint/playstation/NetworkProcessMain.cpp	2022-06-06 20:13:32 UTC (rev 295293)
+++ trunk/Source/WebKit/NetworkProcess/EntryPoint/playstation/NetworkProcessMain.cpp	2022-06-06 20:24:52 UTC (rev 295294)
@@ -51,9 +51,9 @@
         fprintf(stderr, "Failed to load SSL library.\n");
         exit(EXIT_FAILURE);
     }
-    loadLibraryOrExit("libcurl");
-    loadLibraryOrExit("libicu");
-    loadLibraryOrExit("libSceNKWebKitRequirements");
+    loadLibraryOrExit(CURL_LOAD_AT);
+    loadLibraryOrExit(ICU_LOAD_AT);
+    loadLibraryOrExit(WebKitRequirements_LOAD_AT);
 #if !ENABLE(STATIC_JSC)
     loadLibraryOrExit("libJavaScriptCore");
 #endif

Modified: trunk/Source/WebKit/WebProcess/EntryPoint/playstation/WebProcessMain.cpp (295293 => 295294)


--- trunk/Source/WebKit/WebProcess/EntryPoint/playstation/WebProcessMain.cpp	2022-06-06 20:13:32 UTC (rev 295293)
+++ trunk/Source/WebKit/WebProcess/EntryPoint/playstation/WebProcessMain.cpp	2022-06-06 20:24:52 UTC (rev 295294)
@@ -47,13 +47,13 @@
         exit(EXIT_FAILURE);
     }
 
-    loadLibraryOrExit("libpng16");
-    loadLibraryOrExit("libicu");
-    loadLibraryOrExit("libfreetype");
-    loadLibraryOrExit("libfontconfig");
-    loadLibraryOrExit("libharfbuzz");
-    loadLibraryOrExit("libcairo");
-    loadLibraryOrExit("libSceNKWebKitRequirements");
+    loadLibraryOrExit(PNG_LOAD_AT);
+    loadLibraryOrExit(ICU_LOAD_AT);
+    loadLibraryOrExit(Freetype_LOAD_AT);
+    loadLibraryOrExit(Fontconfig_LOAD_AT);
+    loadLibraryOrExit(HarfBuzz_LOAD_AT);
+    loadLibraryOrExit(Cairo_LOAD_AT);
+    loadLibraryOrExit(WebKitRequirements_LOAD_AT);
 #if !ENABLE(STATIC_JSC)
     loadLibraryOrExit("libJavaScriptCore");
 #endif

Modified: trunk/Source/cmake/OptionsPlayStation.cmake (295293 => 295294)


--- trunk/Source/cmake/OptionsPlayStation.cmake	2022-06-06 20:13:32 UTC (rev 295293)
+++ trunk/Source/cmake/OptionsPlayStation.cmake	2022-06-06 20:24:52 UTC (rev 295294)
@@ -6,6 +6,7 @@
 string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g")
 set(CMAKE_CONFIGURATION_TYPES "Debug" "Release")
 
+include(PlayStationModule)
 include(Sign)
 
 add_definitions(-DWTF_PLATFORM_PLAYSTATION=1)
@@ -40,6 +41,7 @@
 find_package(ICU 61.2 REQUIRED COMPONENTS data i18n uc)
 
 set(USE_WPE_BACKEND_PLAYSTATION OFF)
+set(PlayStationModule_TARGETS ICU::uc)
 
 if (ENABLE_WEBCORE)
     set(WebKitRequirements_COMPONENTS
@@ -48,6 +50,7 @@
         LibXml2
         ProcessLauncher
         SQLite3
+        WebKitResources
         ZLIB
     )
 
@@ -58,6 +61,8 @@
         find_package(WPE REQUIRED)
 
         SET_AND_EXPOSE_TO_BUILD(USE_WPE_BACKEND_PLAYSTATION ON)
+
+        list(APPEND PlayStationModule_TARGETS WPE::PlayStation)
     else ()
         list(APPEND WebKitRequirements_COMPONENTS libwpe)
     endif ()
@@ -78,6 +83,18 @@
     find_package(PNG REQUIRED)
     find_package(Threads REQUIRED)
     find_package(WebP REQUIRED COMPONENTS demux)
+
+    list(APPEND PlayStationModule_TARGETS
+        CURL::libcurl
+        Cairo::Cairo
+        Fontconfig::Fontconfig
+        Freetype::Freetype
+        HarfBuzz::HarfBuzz
+        ICU::uc
+        OpenSSL::SSL
+        PNG::PNG
+        WebKitRequirements::WebKitResources
+    )
 endif ()
 
 WEBKIT_OPTION_BEGIN()
@@ -205,6 +222,13 @@
     SET_AND_EXPOSE_TO_BUILD(ENABLE_WEBDRIVER_WHEEL_INTERACTIONS ON)
 endif ()
 
+if (ENABLE_MINIBROWSER)
+    find_library(TOOLKIT_LIBRARY ToolKitten)
+    if (NOT TOOLKIT_LIBRARY)
+        message(FATAL_ERROR "ToolKit library required to run MiniBrowser")
+    endif ()
+endif ()
+
 # Create a shared _javascript_Core with WTF and bmalloc exposed through it.
 #
 # Use OBJECT libraries for bmalloc and WTF. This is the modern CMake way to emulate
@@ -252,6 +276,7 @@
     COMMAND ${CMAKE_COMMAND} -E touch
         ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ebootparam.ini
 )
+set_target_properties(playstation_tools_copy PROPERTIES FOLDER "PlayStation")
 
 macro(WEBKIT_EXECUTABLE _target)
     _WEBKIT_EXECUTABLE(${_target})
@@ -268,64 +293,50 @@
     add_dependencies(${_target} playstation_tools_copy)
 endmacro()
 
-set_property(GLOBAL PROPERTY playstation_copied_requirements)
+macro(PLAYSTATION_MODULES)
+    set(oneValueArgs DESTINATION)
+    set(multiValueArgs TARGETS)
+    cmake_parse_arguments(opt "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
 
-function(PLAYSTATION_COPY_REQUIREMENTS target_name)
-    set(oneValueArgs PREFIX DESTINATION)
-    set(multiValueArgs FILES)
-    cmake_parse_arguments(opt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-    if (opt_PREFIX)
-        set(prefix ${opt_PREFIX})
-    else ()
-        set(prefix ${WEBKIT_LIBRARIES_DIR})
-    endif ()
-    if (opt_DESTINATION)
-        set(destination ${opt_DESTINATION})
-    else ()
-        set(destination ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-    endif ()
+    foreach (_target IN LISTS opt_TARGETS)
+        string(REGEX MATCH "^(.+)::(.+)$" _is_stub "${_target}")
+        set(_target_name ${CMAKE_MATCH_1})
+        playstation_module(${_target_name} TARGET ${_target} FOLDER "PlayStation")
 
-    set(files_to_copy)
-    list(REMOVE_DUPLICATES opt_FILES)
-    foreach (file IN LISTS opt_FILES)
-        if (NOT (${file} MATCHES ".*_stub_weak\.a" OR
-                 ${file} MATCHES ".*\.sprx" OR
-                 ${file} MATCHES ".*\.elf" OR
-                 ${file} MATCHES ".*\.self"))
-            continue()
+        if (${_target_name}_LOAD_AT)
+            EXPOSE_STRING_VARIABLE_TO_BUILD(${_target_name}_LOAD_AT)
         endif ()
-        file(RELATIVE_PATH _relative ${prefix} ${file})
-        if (NOT ${_relative} MATCHES "^\.\./.*")
-            get_filename_component(lib ${file} NAME)
-            list(APPEND files_to_copy ${lib})
-        endif ()
     endforeach ()
+endmacro()
 
-    set(dst_requirements)
-    get_property(copied_requirements GLOBAL PROPERTY playstation_copied_requirements)
-    foreach (basefilename IN LISTS files_to_copy)
-        string(REPLACE "_stub_weak.a" ".sprx" filename ${basefilename})
-        set(src_file "${prefix}/bin/${filename}")
-        list(FIND copied_requirements ${src_file} found)
-        if (${found} GREATER_EQUAL 0)
-            continue()
+macro(PLAYSTATION_COPY_MODULES _target_name)
+    set(multiValueArgs TARGETS)
+    cmake_parse_arguments(opt "" "" "${multiValueArgs}" ${ARGN})
+
+    foreach (_target IN LISTS opt_TARGETS)
+        if (TARGET ${_target}_CopyModule)
+            list(APPEND ${_target_name}_INTERFACE_DEPENDENCIES ${_target}_CopyModule)
         endif ()
-        if (NOT EXISTS ${src_file})
-            continue()
-        endif ()
-        list(APPEND copied_requirements ${src_file})
-        set(dst_file "${destination}/${filename}")
-        add_custom_command(OUTPUT ${dst_file}
-            COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dst_file}
-            MAIN_DEPENDENCY ${file}
-            VERBATIM
-        )
-        list(APPEND dst_requirements ${dst_file})
     endforeach ()
-    add_custom_target(${target_name} ALL DEPENDS ${dst_requirements})
-    set_property(GLOBAL PROPERTY playstation_copied_requirements ${copied_requirements} ${dst_requirements})
-endfunction()
+endmacro()
 
+PLAYSTATION_MODULES(TARGETS ${PlayStationModule_TARGETS})
+
+# These should be made into proper CMake targets
+if (EGL_LIBRARIES)
+    playstation_module(EGL TARGET ${EGL_LIBRARIES} FOLDER "PlayStation")
+    if (EGL_LOAD_AT)
+        EXPOSE_STRING_VARIABLE_TO_BUILD(EGL_LOAD_AT)
+    endif ()
+endif ()
+
+if (TOOLKIT_LIBRARY)
+    playstation_module(ToolKitten TARGET ${TOOLKIT_LIBRARY} FOLDER "PlayStation")
+    if (ToolKitten_LOAD_AT)
+        EXPOSE_STRING_VARIABLE_TO_BUILD(ToolKitten_LOAD_AT)
+    endif ()
+endif ()
+
 check_symbol_exists(memmem string.h HAVE_MEMMEM)
 if (HAVE_MEMMEM)
     add_definitions(-DHAVE_MEMMEM=1)

Modified: trunk/Tools/MiniBrowser/playstation/CMakeLists.txt (295293 => 295294)


--- trunk/Tools/MiniBrowser/playstation/CMakeLists.txt	2022-06-06 20:13:32 UTC (rev 295293)
+++ trunk/Tools/MiniBrowser/playstation/CMakeLists.txt	2022-06-06 20:24:52 UTC (rev 295294)
@@ -1,12 +1,8 @@
 find_library(TOOLKIT_LIBRARY ToolKitten)
+set(MiniBrowser_DEPENDENCIES ToolKitten_CopyModule)
 
-PLAYSTATION_COPY_REQUIREMENTS(MiniBrowser_CopySharedLibs
-    FILES ${TOOLKIT_LIBRARY}
-)
-
 set(MiniBrowser_PRIVATE_INCLUDE_DIRECTORIES
     ${CMAKE_BINARY_DIR}
-    "${TOOLS_DIR}/playstation/"
 )
 
 set(MiniBrowser_SOURCES
@@ -22,29 +18,13 @@
 set(MiniBrowser_LIBRARIES
     ${C_STD_LIBRARY}
     ${KERNEL_LIBRARY}
-
     ${TOOLKIT_LIBRARY}
-
-    WebKit::WebKit
 )
+set(MiniBrowser_FRAMEWORKS WebKit)
 
-set(PLAYSTATION_MiniBrowser_REQUIRED_SHARED_LIBRARIES
-    libToolKitten
-    libcairo
-    libfontconfig
-    libfreetype
-    libharfbuzz
-    libicu
-    libpng16
-)
-
-link_directories(${WEBKIT_LIBRARIES_DIR}/lib)
 WEBKIT_EXECUTABLE_DECLARE(MiniBrowser)
 WEBKIT_EXECUTABLE(MiniBrowser)
 
-# MiniBrowser won't work without these processes
-add_dependencies(MiniBrowser WebProcess NetworkProcess)
-
 target_link_options(MiniBrowser PRIVATE -Wl,--no-demangle)
 
 #

Modified: trunk/Tools/MiniBrowser/playstation/main.cpp (295293 => 295294)


--- trunk/Tools/MiniBrowser/playstation/main.cpp	2022-06-06 20:13:32 UTC (rev 295293)
+++ trunk/Tools/MiniBrowser/playstation/main.cpp	2022-06-06 20:24:52 UTC (rev 295294)
@@ -48,14 +48,14 @@
     loadLibraryOrExit("PosixWebKit");
     setenv_np("WebInspectorServerPort", "868", 1);
 
-    loadLibraryOrExit("libpng16");
-    loadLibraryOrExit("libicu");
-    loadLibraryOrExit("libfontconfig");
-    loadLibraryOrExit("libfreetype");
-    loadLibraryOrExit("libharfbuzz");
-    loadLibraryOrExit("libcairo");
-    loadLibraryOrExit("libToolKitten");    
-    loadLibraryOrExit("libSceNKWebKitRequirements");
+    loadLibraryOrExit(PNG_LOAD_AT);
+    loadLibraryOrExit(ICU_LOAD_AT);
+    loadLibraryOrExit(Fontconfig_LOAD_AT);
+    loadLibraryOrExit(Freetype_LOAD_AT);
+    loadLibraryOrExit(HarfBuzz_LOAD_AT);
+    loadLibraryOrExit(Cairo_LOAD_AT);
+    loadLibraryOrExit(ToolKitten_LOAD_AT);
+    loadLibraryOrExit(WebKitRequirements_LOAD_AT);
 #if !(defined(ENABLE_STATIC_JSC) && ENABLE_STATIC_JSC)
     loadLibraryOrExit("libJavaScriptCore");
 #endif

Modified: trunk/Tools/TestWebKitAPI/PlatformPlayStation.cmake (295293 => 295294)


--- trunk/Tools/TestWebKitAPI/PlatformPlayStation.cmake	2022-06-06 20:13:32 UTC (rev 295293)
+++ trunk/Tools/TestWebKitAPI/PlatformPlayStation.cmake	2022-06-06 20:24:52 UTC (rev 295294)
@@ -9,14 +9,23 @@
 
     generic/UtilitiesGeneric.cpp
 )
+list(APPEND TestWTF_PRIVATE_INCLUDE_DIRECTORIES
+    ${WEBKIT_LIBRARIES_DIR}/include
+)
 
 list(APPEND TestJavaScriptCore_SOURCES
     ${test_main_SOURCES}
 )
+list(APPEND TestJavaScriptCore_PRIVATE_INCLUDE_DIRECTORIES
+    ${WEBKIT_LIBRARIES_DIR}/include
+)
 
 list(APPEND TestWebCore_SOURCES
     ${test_main_SOURCES}
 )
+list(APPEND TestWebCore_PRIVATE_INCLUDE_DIRECTORIES
+    ${WEBKIT_LIBRARIES_DIR}/include
+)
 
 # TestWebKit
 if (ENABLE_WEBKIT)
@@ -36,6 +45,9 @@
         playstation/PlatformUtilitiesPlayStation.cpp
         playstation/PlatformWebViewPlayStation.cpp
     )
+    list(APPEND TestWebKit_PRIVATE_INCLUDE_DIRECTORIES
+        ${WEBKIT_LIBRARIES_DIR}/include
+    )
 
     # Exclude tests which don't finish.
     list(REMOVE_ITEM TestWebKit_SOURCES

Modified: trunk/Tools/TestWebKitAPI/playstation/main.cpp (295293 => 295294)


--- trunk/Tools/TestWebKitAPI/playstation/main.cpp	2022-06-06 20:13:32 UTC (rev 295293)
+++ trunk/Tools/TestWebKitAPI/playstation/main.cpp	2022-06-06 20:24:52 UTC (rev 295294)
@@ -25,8 +25,8 @@
 
 #include "config.h"
 #include "TestsController.h"
-#include "process-initialization/nk-testwebkitapi.h"
 #include <dlfcn.h>
+#include <process-initialization/nk-testwebkitapi.h>
 
 static void loadLibraryOrExit(const char* name)
 {
@@ -38,14 +38,14 @@
 
 int main(int argc, char** argv)
 {
-    loadLibraryOrExit("libicu");
+    loadLibraryOrExit(ICU_LOAD_AT);
 #if defined(BUILDING_TestWebCore) || defined(BUILDING_TestWebKit)
-    loadLibraryOrExit("libpng16");
-    loadLibraryOrExit("libfontconfig");
-    loadLibraryOrExit("libfreetype");
-    loadLibraryOrExit("libharfbuzz");
-    loadLibraryOrExit("libcairo");
-    loadLibraryOrExit("libSceNKWebKitRequirements");
+    loadLibraryOrExit(PNG_LOAD_AT);
+    loadLibraryOrExit(Fontconfig_LOAD_AT);
+    loadLibraryOrExit(Freetype_LOAD_AT);
+    loadLibraryOrExit(HarfBuzz_LOAD_AT);
+    loadLibraryOrExit(Cairo_LOAD_AT);
+    loadLibraryOrExit(WebKitRequirements_LOAD_AT);
 #endif
 #if defined(BUILDING_TestWebCore) || defined(BUILDING_TestWebKit) || defined(BUILDING_TestJavaScriptCore)
 #if !ENABLE(STATIC_JSC)
@@ -53,11 +53,8 @@
 #endif
 #endif
 #if defined(BUILDING_TestWebKit)
-    if (!((dlopen("libcrypto", RTLD_NOW) && dlopen("libssl", RTLD_NOW)) || dlopen("LibreSSL", RTLD_NOW))) {
-        fprintf(stderr, "Failed to load SSL library.\n");
-        exit(EXIT_FAILURE);
-    }
-    loadLibraryOrExit("libcurl");
+    loadLibraryOrExit(OpenSSL_LOAD_AT);
+    loadLibraryOrExit(CURL_LOAD_AT);
     loadLibraryOrExit("libWebKit");
 #endif
     return TestWebKitAPI::TestsController::singleton().run(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to