[PlayStation] Add initialization for JSC shell for PlayStation port
authorstephan.szabo@sony.com <stephan.szabo@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Apr 2019 18:25:11 +0000 (18:25 +0000)
committerstephan.szabo@sony.com <stephan.szabo@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Apr 2019 18:25:11 +0000 (18:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195411

Reviewed by Ross Kirsling.

.:

Add functions for doing the automatic libc, floating point
initializations, signing of binaries and libraries and
wrapping of libc functions on PlayStation port.

* Source/cmake/OptionsPlayStation.cmake:

Source/JavaScriptCore:

Add ps options

* shell/PlatformPlayStation.cmake: Added.
* shell/playstation/Initializer.cpp: Added.
(initializer):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243700 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/shell/PlatformPlayStation.cmake [new file with mode: 0644]
Source/JavaScriptCore/shell/playstation/Initializer.cpp [new file with mode: 0644]
Source/cmake/OptionsPlayStation.cmake

index e5d16c6..1a72946 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2019-04-01  Stephan Szabo  <stephan.szabo@sony.com>
+
+        [PlayStation] Add initialization for JSC shell for PlayStation port
+        https://bugs.webkit.org/show_bug.cgi?id=195411
+
+        Reviewed by Ross Kirsling.
+
+        Add functions for doing the automatic libc, floating point
+        initializations, signing of binaries and libraries and 
+        wrapping of libc functions on PlayStation port.
+
+        * Source/cmake/OptionsPlayStation.cmake:
+
 2019-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Delete WebMetal implementation in favor of WebGPU
index d1018cd..4e2b24f 100644 (file)
@@ -1,3 +1,16 @@
+2019-04-01  Stephan Szabo  <stephan.szabo@sony.com>
+
+        [PlayStation] Add initialization for JSC shell for PlayStation port
+        https://bugs.webkit.org/show_bug.cgi?id=195411
+
+        Reviewed by Ross Kirsling.
+
+        Add ps options
+
+        * shell/PlatformPlayStation.cmake: Added.
+        * shell/playstation/Initializer.cpp: Added.
+        (initializer):
+
 2019-04-01  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Stop trying to support building JSC with clang 3.8
diff --git a/Source/JavaScriptCore/shell/PlatformPlayStation.cmake b/Source/JavaScriptCore/shell/PlatformPlayStation.cmake
new file mode 100644 (file)
index 0000000..0937f93
--- /dev/null
@@ -0,0 +1,11 @@
+
+list(APPEND JSC_SOURCES
+    ${JAVASCRIPTCORE_DIR}/shell/playstation/Initializer.cpp
+)
+
+find_library(LIBTESTWRAPPERS testwrappers PATHS ${WEBKIT_LIBRARIES_DIR}/lib)
+
+set(PLAYSTATION_jsc_PROCESS_NAME "JSCShell")
+set(PLAYSTATION_jsc_MAIN_THREAD_NAME "JSCShell")
+set(PLAYSTATION_jsc_WRAP fopen getcwd main)
+list(APPEND JSC_LIBRARIES ${LIBTESTWRAPPERS})
diff --git a/Source/JavaScriptCore/shell/playstation/Initializer.cpp b/Source/JavaScriptCore/shell/playstation/Initializer.cpp
new file mode 100644 (file)
index 0000000..9852c91
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2019 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <dlfcn.h>
+
+__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("libJavaScriptCore", RTLD_NOW);
+    if (!handle)
+        exit(1);
+}
index 51dce30..161f7af 100644 (file)
@@ -1,5 +1,7 @@
 set(PORT PlayStation)
 
+include(Sign)
+
 add_definitions(-DWTF_PLATFORM_PLAYSTATION=1)
 
 WEBKIT_OPTION_BEGIN()
@@ -131,3 +133,33 @@ set(ENABLE_WEBKIT_LEGACY OFF)
 if (NOT ${CMAKE_GENERATOR} MATCHES "Ninja")
     add_definitions(/MP)
 endif ()
+
+find_library(DL_LIBRARY NAMES dl PATHS ${WEBKIT_LIBRARIES_DIR}/lib)
+if (DL_LIBRARY)
+    add_link_options("$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${DL_LIBRARY}>")
+    add_link_options("$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--wrap=dlopen>")
+    add_link_options("$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--wrap=dlclose>")
+    add_link_options("$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--wrap=dlerror>")
+    add_link_options("$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--wrap=dlsym>")
+endif ()
+
+function(add_library target type)
+    _add_library(${ARGV})
+    if ("${type}" STREQUAL "SHARED")
+        sign(${target})
+    endif ()
+endfunction()
+
+function(add_executable target)
+    _add_executable(${ARGV})
+    playstation_setup_libc(${target})
+    playstation_setup_fp(${target})
+    if (NOT ${target} MATCHES "^LLInt")
+        sign(${target})
+    endif ()
+    if (PLAYSTATION_${target}_WRAP)
+        foreach (WRAP ${PLAYSTATION_${target}_WRAP})
+            target_link_options(${target} PRIVATE -Wl,--wrap=${WRAP})
+        endforeach ()
+    endif ()
+endfunction()