Skip to content

Commit cf4c773

Browse files
committed
Add JavaScriptCore as overlay port
1 parent 6cbed91 commit cf4c773

File tree

9 files changed

+260
-7
lines changed

9 files changed

+260
-7
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/Source/cmake/OptionsJSCOnly.cmake b/Source/cmake/OptionsJSCOnly.cmake
2+
index 4c7b6cca2249..579904baeeb2 100644
3+
--- a/Source/cmake/OptionsJSCOnly.cmake
4+
+++ b/Source/cmake/OptionsJSCOnly.cmake
5+
@@ -45,11 +45,7 @@ set(ENABLE_WEBKIT OFF)
6+
set(ENABLE_WEBINSPECTORUI OFF)
7+
set(ENABLE_WEBGL OFF)
8+
9+
-if (WIN32)
10+
- set(ENABLE_API_TESTS OFF)
11+
-else ()
12+
- set(ENABLE_API_TESTS ON)
13+
-endif ()
14+
+set(ENABLE_API_TESTS OFF)
15+
16+
if (WTF_CPU_ARM OR WTF_CPU_MIPS)
17+
SET_AND_EXPOSE_TO_BUILD(USE_CAPSTONE TRUE)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index aa99898dc4f1..17db4640001e 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -6,7 +6,7 @@
6+
# latter in particular handles loading a bunch of shared CMake definitions
7+
# and loading the cross-compilation settings from CMAKE_TOOLCHAIN_FILE.
8+
9+
-cmake_minimum_required(VERSION 3.16)
10+
+cmake_minimum_required(VERSION 3.23)
11+
project(WebKit)
12+
13+
# Remove this cmake_policy() after upgrading cmake_minimum_required() to 3.20.
14+
diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt
15+
index a64c09b5d470..80c45bd91c17 100644
16+
--- a/Source/JavaScriptCore/CMakeLists.txt
17+
+++ b/Source/JavaScriptCore/CMakeLists.txt
18+
@@ -1490,6 +1490,13 @@ WEBKIT_COPY_FILES(JavaScriptCore_CopyHeaders
19+
FLATTENED
20+
)
21+
22+
+target_sources(JavaScriptCore PUBLIC
23+
+ FILE_SET install_headers
24+
+ TYPE HEADERS
25+
+ BASE_DIRS API
26+
+ FILES ${JavaScriptCore_PUBLIC_FRAMEWORK_HEADERS}
27+
+)
28+
+
29+
WEBKIT_COPY_FILES(JavaScriptCore_CopyPrivateHeaders
30+
DESTINATION ${JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS_DIR}/JavaScriptCore
31+
FILES ${JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS}
32+
@@ -1548,9 +1555,15 @@ if (NOT "${PORT}" STREQUAL "Mac")
33+
if (${JavaScriptCore_LIBRARY_TYPE} STREQUAL "SHARED")
34+
WEBKIT_POPULATE_LIBRARY_VERSION(JAVASCRIPTCORE)
35+
set_target_properties(JavaScriptCore PROPERTIES VERSION ${JAVASCRIPTCORE_VERSION} SOVERSION ${JAVASCRIPTCORE_VERSION_MAJOR})
36+
- install(TARGETS JavaScriptCore DESTINATION "${LIB_INSTALL_DIR}")
37+
endif ()
38+
endif ()
39+
+install(
40+
+ TARGETS JavaScriptCore
41+
+ ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
42+
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
43+
+ RUNTIME DESTINATION "${LIBEXEC_INSTALL_DIR}"
44+
+ FILE_SET install_headers DESTINATION "${CMAKE_INSTALL_PREFIX}/include/JavaScriptCore"
45+
+)
46+
47+
# Force staging of shared scripts, even if they aren't directly used to build JavaScriptCore.
48+
49+
@@ -1565,4 +1578,4 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio")
50+
add_dependencies(JavaScriptCoreSharedScripts JSCBuiltins)
51+
endif ()
52+
53+
-add_subdirectory(shell)
54+
+# add_subdirectory(shell)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
vcpkg_from_github(
2+
OUT_SOURCE_PATH SOURCE_PATH
3+
REPO webkit/webkit
4+
REF WebKit-7616.1.27.211.1
5+
SHA512 aea5feb085f9adaa6efbbb840b2bdbc677c69c82c53c611ef9b527ae4ea2490a983dfdc55eb8aa471ab9975b748ea51d2cf9f2c853454904018ab8bb0ec77ad0
6+
HEAD_REF main
7+
PATCHES
8+
remove_webkit_find_package.patch
9+
tune_jsconly_port_for_windows.patch
10+
tune_wtf.patch
11+
modify_install_rules.patch
12+
disable_api_tests.patch
13+
)
14+
15+
vcpkg_find_acquire_program(RUBY)
16+
get_filename_component(RUBY_PATH "${RUBY}" DIRECTORY)
17+
vcpkg_add_to_path("${RUBY_PATH}")
18+
19+
vcpkg_find_acquire_program(PYTHON3)
20+
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
21+
vcpkg_add_to_path("${PYTHON3_DIR}")
22+
23+
vcpkg_find_acquire_program(PERL)
24+
get_filename_component(PERL_DIR "${PERL}" DIRECTORY)
25+
vcpkg_add_to_path("${PERL_DIR}")
26+
27+
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
28+
set(ENABLE_STATIC_JSC ON)
29+
else()
30+
set(ENABLE_STATIC_JSC ON)
31+
endif()
32+
33+
vcpkg_cmake_configure(
34+
SOURCE_PATH ${SOURCE_PATH}
35+
OPTIONS
36+
-DPORT=JSCOnly
37+
-DENABLE_STATIC_JSC=${ENABLE_STATIC_JSC}
38+
-DUSE_APPLE_ICU=OFF
39+
)
40+
41+
vcpkg_cmake_install()
42+
vcpkg_copy_pdbs()
43+
44+
vcpkg_install_copyright(
45+
FILE_LIST
46+
"${SOURCE_PATH}/Source/WebCore/LICENSE-APPLE"
47+
"${SOURCE_PATH}/Source/WebCore/LICENSE-LGPL-2.1"
48+
)
49+
50+
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
51+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/Source/cmake/WebKitCommon.cmake b/Source/cmake/WebKitCommon.cmake
2+
index d85ee1813b4b..1670ea855ebf 100644
3+
--- a/Source/cmake/WebKitCommon.cmake
4+
+++ b/Source/cmake/WebKitCommon.cmake
5+
@@ -222,7 +222,7 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
6+
include(WebKitCompilerFlags)
7+
include(WebKitStaticAnalysis)
8+
include(WebKitFeatures)
9+
- include(WebKitFindPackage)
10+
+ # include(WebKitFindPackage)
11+
12+
include(OptionsCommon)
13+
include(Options${PORT})
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
diff --git a/Source/cmake/OptionsJSCOnly.cmake b/Source/cmake/OptionsJSCOnly.cmake
2+
index ff391d7e0849..e05f2a3adeef 100644
3+
--- a/Source/cmake/OptionsJSCOnly.cmake
4+
+++ b/Source/cmake/OptionsJSCOnly.cmake
5+
@@ -1,4 +1,6 @@
6+
-find_package(Threads REQUIRED)
7+
+if (NOT WIN32)
8+
+ find_package(Threads REQUIRED)
9+
+endif ()
10+
11+
if (MSVC)
12+
include(OptionsMSVC)
13+
@@ -55,10 +57,15 @@ endif ()
14+
15+
# FIXME: JSCOnly on WIN32 seems to only work with fully static build
16+
# https://bugs.webkit.org/show_bug.cgi?id=172862
17+
-if (NOT ENABLE_STATIC_JSC AND NOT WIN32)
18+
- set(JavaScriptCore_LIBRARY_TYPE SHARED)
19+
- set(bmalloc_LIBRARY_TYPE OBJECT)
20+
- set(WTF_LIBRARY_TYPE OBJECT)
21+
+if (NOT ENABLE_STATIC_JSC)
22+
+ if (NOT WIN32)
23+
+ set(JavaScriptCore_LIBRARY_TYPE SHARED)
24+
+ set(bmalloc_LIBRARY_TYPE OBJECT)
25+
+ set(WTF_LIBRARY_TYPE OBJECT)
26+
+ else ()
27+
+ set(JavaScriptCore_LIBRARY_TYPE SHARED)
28+
+ set(WTF_LIBRARY_TYPE SHARED)
29+
+ endif ()
30+
endif ()
31+
32+
if (WIN32)
33+
@@ -74,7 +81,7 @@ if (WIN32)
34+
endif ()
35+
endif ()
36+
37+
- set(CMAKE_PREFIX_PATH ${WEBKIT_LIBRARIES_DIR})
38+
+ list(APPEND CMAKE_PREFIX_PATH ${WEBKIT_LIBRARIES_DIR})
39+
40+
if (WTF_CPU_X86_64)
41+
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS OFF)
42+
@@ -94,7 +101,10 @@ if (WIN32)
43+
endif ()
44+
45+
string(TOLOWER ${EVENT_LOOP_TYPE} LOWERCASE_EVENT_LOOP_TYPE)
46+
-if (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib")
47+
+if (WIN32)
48+
+ SET_AND_EXPOSE_TO_BUILD(USE_GENERIC_EVENT_LOOP 0)
49+
+ SET_AND_EXPOSE_TO_BUILD(WTF_DEFAULT_EVENT_LOOP 1)
50+
+elseif (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib")
51+
find_package(GLIB 2.36 REQUIRED COMPONENTS gio gio-unix gobject)
52+
SET_AND_EXPOSE_TO_BUILD(USE_GLIB 1)
53+
SET_AND_EXPOSE_TO_BUILD(USE_GLIB_EVENT_LOOP 1)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
diff --git a/Source/WTF/wtf/PlatformJSCOnly.cmake b/Source/WTF/wtf/PlatformJSCOnly.cmake
2+
index 21eb0e276916..cb869e6da35f 100644
3+
--- a/Source/WTF/wtf/PlatformJSCOnly.cmake
4+
+++ b/Source/WTF/wtf/PlatformJSCOnly.cmake
5+
@@ -1,3 +1,15 @@
6+
+if (WTF_CPU_X86_64)
7+
+ if (MSVC)
8+
+ add_custom_command(
9+
+ OUTPUT ${WTF_DERIVED_SOURCES_DIR}/AsmStubsMSVC64.obj
10+
+ MAIN_DEPENDENCY ${WTF_DIR}/wtf/win/AsmStubsMSVC64.asm
11+
+ COMMAND ml64 -nologo -c -Fo ${WTF_DERIVED_SOURCES_DIR}/AsmStubsMSVC64.obj ${WTF_DIR}/wtf/win/AsmStubsMSVC64.asm
12+
+ VERBATIM)
13+
+
14+
+ list(APPEND WTF_SOURCES ${WTF_DERIVED_SOURCES_DIR}/AsmStubsMSVC64.obj)
15+
+ endif ()
16+
+endif ()
17+
+
18+
list(APPEND WTF_SOURCES
19+
generic/WorkQueueGeneric.cpp
20+
)
21+
@@ -122,7 +134,12 @@ else ()
22+
)
23+
endif ()
24+
25+
-if (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib")
26+
+if (WIN32)
27+
+ list(APPEND WTF_SOURCES
28+
+ win/RunLoopWin.cpp
29+
+ win/Win32Handle.cpp
30+
+ )
31+
+elseif (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib")
32+
list(APPEND WTF_SOURCES
33+
glib/GRefPtr.cpp
34+
glib/RunLoopGLib.cpp
35+
@@ -161,6 +178,8 @@ else ()
36+
)
37+
endif ()
38+
39+
-list(APPEND WTF_LIBRARIES
40+
- Threads::Threads
41+
-)
42+
+if (NOT WIN32)
43+
+ list(APPEND WTF_LIBRARIES
44+
+ Threads::Threads
45+
+ )
46+
+endif ()

overlay-ports/javascriptcore/usage

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
javascriptcore provides CMake targets:
2+
3+
find_package(JavaScriptCore REQUIRED)
4+
target_link_libraries(main PRIVATE JavaScriptCore)
5+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "javascriptcore",
3+
"version": "2023-09-15",
4+
"description": "JavaScriptCore is the built-in JavaScript engine for WebKit, which implements ECMAScript as in ECMA-262 specification.",
5+
"homepage": "https://webkit.org/",
6+
"license": null,
7+
"supports": "!uwp & windows & x64",
8+
"dependencies": [
9+
"icu",
10+
{
11+
"name": "vcpkg-cmake",
12+
"host": true
13+
},
14+
{
15+
"name": "vcpkg-cmake-config",
16+
"host": true
17+
}
18+
]
19+
}

vcpkg-configuration.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
"baseline": "c3b8b7aed2dad1c83cc3069753ab1fc0318b70de",
55
"repository": "https://github.com/microsoft/vcpkg"
66
},
7-
"registries": [
8-
{
9-
"kind": "git",
10-
"repository": "https://github.com/bavulapati/vcpkg",
11-
"baseline": "c3b8b7aed2dad1c83cc3069753ab1fc0318b70de",
12-
"packages": ["javascriptcore"]
13-
}
7+
"overlay-ports": [
8+
"./overlay-ports"
149
]
1510
}

0 commit comments

Comments
 (0)