[PlayStation] Enable JSC shell to run
https://bugs.webkit.org/show_bug.cgi?id=212294

Reviewed by Ross Kirsling.

.:

* Source/cmake/OptionsPlayStation.cmake:

Source/JavaScriptCore:

* shell/PlatformPlayStation.cmake:
Set working directory for Visual Studio
* shell/playstation/Initializer.cpp:
Load libJavaScriptCore as we now build it as SHARED.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@262096 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/ChangeLog b/ChangeLog
index 39f0e19..6e96aeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-05-22  Yoshiaki JITSUKAWA  <yoshiaki.jitsukawa@sony.com>
+
+        [PlayStation] Enable JSC shell to run
+        https://bugs.webkit.org/show_bug.cgi?id=212294
+
+        Reviewed by Ross Kirsling.
+
+        * Source/cmake/OptionsPlayStation.cmake:
+
 2020-05-21  Yoshiaki Jitsukawa  <yoshiaki.jitsukawa@sony.com>
 
         [PlayStation] Add minimal WKView API to enable TestWebKitAPI
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index e831e7f..9fd1faa 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,15 @@
+2020-05-22  Yoshiaki JITSUKAWA  <yoshiaki.jitsukawa@sony.com>
+
+        [PlayStation] Enable JSC shell to run
+        https://bugs.webkit.org/show_bug.cgi?id=212294
+
+        Reviewed by Ross Kirsling.
+
+        * shell/PlatformPlayStation.cmake:
+        Set working directory for Visual Studio
+        * shell/playstation/Initializer.cpp:
+        Load libJavaScriptCore as we now build it as SHARED.
+
 2020-05-22  Alexey Shvayka  <shvaikalesh@gmail.com>
 
         Array.prototype.splice doesn't set "length" of returned object
diff --git a/Source/JavaScriptCore/shell/PlatformPlayStation.cmake b/Source/JavaScriptCore/shell/PlatformPlayStation.cmake
index ab0096f..6e18ee3 100644
--- a/Source/JavaScriptCore/shell/PlatformPlayStation.cmake
+++ b/Source/JavaScriptCore/shell/PlatformPlayStation.cmake
@@ -19,3 +19,8 @@
 
 set(PLAYSTATION_jsc_PROCESS_NAME "JSCShell")
 set(PLAYSTATION_jsc_MAIN_THREAD_NAME "JSCShell")
+
+# Set the debugger working directory for Visual Studio
+if (${CMAKE_GENERATOR} MATCHES "Visual Studio")
+    set_target_properties(jsc PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
+endif ()
diff --git a/Source/JavaScriptCore/shell/playstation/Initializer.cpp b/Source/JavaScriptCore/shell/playstation/Initializer.cpp
index 8e87144..658e1a9 100644
--- a/Source/JavaScriptCore/shell/playstation/Initializer.cpp
+++ b/Source/JavaScriptCore/shell/playstation/Initializer.cpp
@@ -29,16 +29,19 @@
 #include "config.h"
 #include <dlfcn.h>
 
+static void loadLibraryOrExit(const char* name)
+{
+    if (!dlopen(name, RTLD_NOW)) {
+        fprintf(stderr, "Failed to load %s.\n", name);
+        exit(EXIT_FAILURE);
+    }
+}
+
 __attribute__((constructor(101)))
 static void initializer(void)
 {
-    void* handle = dlopen("SystemServices", RTLD_NOW);
-    if (!handle)
-        exit(1);
-    handle = dlopen("Perf", RTLD_NOW);
-    if (!handle)
-        exit(1);
-    handle = dlopen("PosixWebKit", RTLD_NOW);
-    if (!handle)
-        exit(1);
+    loadLibraryOrExit("SystemServices");
+    loadLibraryOrExit("Perf");
+    loadLibraryOrExit("PosixWebKit");
+    loadLibraryOrExit("libJavaScriptCore");
 }
diff --git a/Source/cmake/OptionsPlayStation.cmake b/Source/cmake/OptionsPlayStation.cmake
index 6ac8055..7313a8b 100644
--- a/Source/cmake/OptionsPlayStation.cmake
+++ b/Source/cmake/OptionsPlayStation.cmake
@@ -232,6 +232,12 @@
             target_link_options(${_target} PRIVATE -Wl,--wrap=${WRAP})
         endforeach ()
     endif ()
+    add_custom_command(TARGET ${_target}
+        POST_BUILD
+        COMMAND ${CMAKE_COMMAND} -E copy_directory
+            ${WEBKIT_LIBRARIES_DIR}/tools/sce_sys/
+            $<TARGET_FILE_DIR:${_target}>/sce_sys/
+    )
 endmacro()
 
 function(PLAYSTATION_COPY_SHARED_LIBRARIES target_name)