Skip to content

Commit

Permalink
update the overlay port
Browse files Browse the repository at this point in the history
  • Loading branch information
bavulapati committed Feb 1, 2024
1 parent c95e0f2 commit 6a38c35
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-javascriptcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
ls vcpkg\scripts\buildsystems\vcpkg.cmake
- name: Build JavaScriptCore
run: |
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE="vcpkg\scripts\buildsystems\vcpkg.cmake"
cmake --preset release -DCMAKE_TOOLCHAIN_FILE="vcpkg\scripts\buildsystems\vcpkg.cmake"
24 changes: 23 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,26 @@ cmake_minimum_required(VERSION 3.18)

project(PublishJavaScriptCore)

find_package(JavaScriptCore REQUIRED)
add_library(JavaScriptCore SHARED IMPORTED)
set_property(TARGET JavaScriptCore PROPERTY
IMPORTED_LOCATION_RELEASE
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/bin/JavaScriptCore.dll)
set_property(TARGET JavaScriptCore PROPERTY
IMPORTED_IMPLIB
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/lib/JavaScriptCore.lib)
set_property(TARGET JavaScriptCore PROPERTY
IMPORTED_LOCATION_DEBUG
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/debug/bin/JavaScriptCore.dll)
set_property(TARGET JavaScriptCore PROPERTY
IMPORTED_IMPLIB_DEBUG
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/debug/lib/JavaScriptCore.lib)
set_property(TARGET JavaScriptCore PROPERTY
INTERFACE_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include)

add_executable(TestJavaScriptCore main.cpp)
target_link_libraries(TestJavaScriptCore JavaScriptCore)

include(GNUInstallDirs)
install(TARGETS TestJavaScriptCore
RUNTIME_DEPENDENCIES)
22 changes: 22 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": 3,
"configurePresets": [
{
"name": "release",
"binaryDir": "build/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": {
"type": "STRING",
"value": "Release"
}
}
}
],
"buildPresets": [
{
"name": "release",
"configurePreset": "release"
}
]
}

14 changes: 14 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <iostream>
#include <JavaScriptCore/JavaScript.h>

int main() {
JSStringRef string = JSStringCreateWithUTF8CString("Hello JSCore!");
int length = JSStringGetLength(string);
std::cout << "Length of the String: " << length << std::endl;
char buffer[20];
JSStringGetUTF8CString(string, buffer, JSStringGetLength(string) + 1);
std::cout << "String: " << buffer << std::endl;
JSStringRelease(string);
return 0;
}

17 changes: 0 additions & 17 deletions overlay-ports/javascriptcore/disable_api_tests.patch

This file was deleted.

43 changes: 15 additions & 28 deletions overlay-ports/javascriptcore/modify_install_rules.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,30 @@ index aa99898dc4f1..17db4640001e 100644

# Remove this cmake_policy() after upgrading cmake_minimum_required() to 3.20.
diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt
index a64c09b5d470..80c45bd91c17 100644
index 5fbb9a3bc110..cab1c6927b41 100644
--- a/Source/JavaScriptCore/CMakeLists.txt
+++ b/Source/JavaScriptCore/CMakeLists.txt
@@ -1490,6 +1490,13 @@ WEBKIT_COPY_FILES(JavaScriptCore_CopyHeaders
FLATTENED
)
@@ -1569,10 +1569,22 @@ if (NOT "${PORT}" STREQUAL "Mac")
if (${JavaScriptCore_LIBRARY_TYPE} STREQUAL "SHARED")
WEBKIT_POPULATE_LIBRARY_VERSION(JAVASCRIPTCORE)
set_target_properties(JavaScriptCore PROPERTIES VERSION ${JAVASCRIPTCORE_VERSION} SOVERSION ${JAVASCRIPTCORE_VERSION_MAJOR})
- install(TARGETS JavaScriptCore DESTINATION "${LIB_INSTALL_DIR}")
endif ()
endif ()

+target_sources(JavaScriptCore PUBLIC
+ FILE_SET install_headers
+ TYPE HEADERS
+ BASE_DIRS API
+ FILES ${JavaScriptCore_PUBLIC_FRAMEWORK_HEADERS}
+)
+
WEBKIT_COPY_FILES(JavaScriptCore_CopyPrivateHeaders
DESTINATION ${JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS_DIR}/JavaScriptCore
FILES ${JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS}
@@ -1548,9 +1555,15 @@ if (NOT "${PORT}" STREQUAL "Mac")
if (${JavaScriptCore_LIBRARY_TYPE} STREQUAL "SHARED")
WEBKIT_POPULATE_LIBRARY_VERSION(JAVASCRIPTCORE)
set_target_properties(JavaScriptCore PROPERTIES VERSION ${JAVASCRIPTCORE_VERSION} SOVERSION ${JAVASCRIPTCORE_VERSION_MAJOR})
- install(TARGETS JavaScriptCore DESTINATION "${LIB_INSTALL_DIR}")
endif ()
endif ()
+install(
+ TARGETS JavaScriptCore
+ ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
+ RUNTIME DESTINATION "${LIBEXEC_INSTALL_DIR}"
+ FILE_SET install_headers DESTINATION "${CMAKE_INSTALL_PREFIX}/include/JavaScriptCore"
+install(TARGETS JavaScriptCore
+ ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
+ RUNTIME DESTINATION "${LIBEXEC_INSTALL_DIR}"
+ FILE_SET install_headers DESTINATION "${CMAKE_INSTALL_PREFIX}/include/JavaScriptCore"
+)
+
# Force staging of shared scripts, even if they aren't directly used to build JavaScriptCore.

@@ -1565,4 +1578,4 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio")
add_dependencies(JavaScriptCoreSharedScripts JSCBuiltins)
endif ()

-add_subdirectory(shell)
+# add_subdirectory(shell)
add_custom_target(JavaScriptCoreSharedScripts DEPENDS ${JavaScriptCore_SCRIPTS})
8 changes: 3 additions & 5 deletions overlay-ports/javascriptcore/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO webkit/webkit
REF WebKit-7616.1.27.211.1
SHA512 aea5feb085f9adaa6efbbb840b2bdbc677c69c82c53c611ef9b527ae4ea2490a983dfdc55eb8aa471ab9975b748ea51d2cf9f2c853454904018ab8bb0ec77ad0
REF a07d3e4e2067578a818215d89f5742b5e9707389
SHA512 f7cfe2e1489e4151311811b9d8f5ee1a9850099d5035e646260fd313816d8d3407517d81b8cb851323d08dcb0915b6cfa783636b91130516e5c4942527d10821
HEAD_REF main
PATCHES
remove_webkit_find_package.patch
tune_jsconly_port_for_windows.patch
tune_wtf.patch
modify_install_rules.patch
disable_api_tests.patch
)

vcpkg_find_acquire_program(RUBY)
Expand All @@ -27,7 +25,7 @@ vcpkg_add_to_path("${PERL_DIR}")
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(ENABLE_STATIC_JSC ON)
else()
set(ENABLE_STATIC_JSC ON)
set(ENABLE_STATIC_JSC OFF)
endif()

vcpkg_cmake_configure(
Expand Down
4 changes: 2 additions & 2 deletions overlay-ports/javascriptcore/remove_webkit_find_package.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/Source/cmake/WebKitCommon.cmake b/Source/cmake/WebKitCommon.cmake
index d85ee1813b4b..1670ea855ebf 100644
index f20a8d06d914..16c7846511ef 100644
--- a/Source/cmake/WebKitCommon.cmake
+++ b/Source/cmake/WebKitCommon.cmake
@@ -222,7 +222,7 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
@@ -231,7 +231,7 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
include(WebKitCompilerFlags)
include(WebKitStaticAnalysis)
include(WebKitFeatures)
Expand Down
56 changes: 15 additions & 41 deletions overlay-ports/javascriptcore/tune_jsconly_port_for_windows.patch
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
diff --git a/Source/cmake/OptionsJSCOnly.cmake b/Source/cmake/OptionsJSCOnly.cmake
index ff391d7e0849..e05f2a3adeef 100644
index 31e353ded188..218c34c24338 100644
--- a/Source/cmake/OptionsJSCOnly.cmake
+++ b/Source/cmake/OptionsJSCOnly.cmake
@@ -1,4 +1,6 @@
-find_package(Threads REQUIRED)
+if (NOT WIN32)
+ find_package(Threads REQUIRED)
+endif ()
@@ -41,12 +41,7 @@ set(ENABLE_WEBKIT_LEGACY OFF)
set(ENABLE_WEBKIT OFF)
set(ENABLE_WEBINSPECTORUI OFF)
set(ENABLE_WEBGL OFF)
-
-if (WIN32)
- set(ENABLE_API_TESTS OFF)
-else ()
- set(ENABLE_API_TESTS ON)
-endif ()
+set(ENABLE_API_TESTS OFF)

if (MSVC)
include(OptionsMSVC)
@@ -55,10 +57,15 @@ endif ()

# FIXME: JSCOnly on WIN32 seems to only work with fully static build
# https://bugs.webkit.org/show_bug.cgi?id=172862
-if (NOT ENABLE_STATIC_JSC AND NOT WIN32)
- set(JavaScriptCore_LIBRARY_TYPE SHARED)
- set(bmalloc_LIBRARY_TYPE OBJECT)
- set(WTF_LIBRARY_TYPE OBJECT)
+if (NOT ENABLE_STATIC_JSC)
+ if (NOT WIN32)
+ set(JavaScriptCore_LIBRARY_TYPE SHARED)
+ set(bmalloc_LIBRARY_TYPE OBJECT)
+ set(WTF_LIBRARY_TYPE OBJECT)
+ else ()
+ set(JavaScriptCore_LIBRARY_TYPE SHARED)
+ set(WTF_LIBRARY_TYPE SHARED)
+ endif ()
endif ()

if (WIN32)
@@ -74,7 +81,7 @@ if (WIN32)
if (WTF_CPU_ARM OR WTF_CPU_MIPS)
SET_AND_EXPOSE_TO_BUILD(USE_CAPSTONE TRUE)
@@ -71,7 +66,7 @@ if (WIN32)
endif ()
endif ()

Expand All @@ -39,15 +25,3 @@ index ff391d7e0849..e05f2a3adeef 100644

if (WTF_CPU_X86_64)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS OFF)
@@ -94,7 +101,10 @@ if (WIN32)
endif ()

string(TOLOWER ${EVENT_LOOP_TYPE} LOWERCASE_EVENT_LOOP_TYPE)
-if (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib")
+if (WIN32)
+ SET_AND_EXPOSE_TO_BUILD(USE_GENERIC_EVENT_LOOP 0)
+ SET_AND_EXPOSE_TO_BUILD(WTF_DEFAULT_EVENT_LOOP 1)
+elseif (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib")
find_package(GLIB 2.36 REQUIRED COMPONENTS gio gio-unix gobject)
SET_AND_EXPOSE_TO_BUILD(USE_GLIB 1)
SET_AND_EXPOSE_TO_BUILD(USE_GLIB_EVENT_LOOP 1)
46 changes: 0 additions & 46 deletions overlay-ports/javascriptcore/tune_wtf.patch

This file was deleted.

2 changes: 1 addition & 1 deletion overlay-ports/javascriptcore/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "javascriptcore",
"version": "2023-09-15",
"version": "2024-02-01",
"description": "JavaScriptCore is the built-in JavaScript engine for WebKit, which implements ECMAScript as in ECMA-262 specification.",
"homepage": "https://webkit.org/",
"license": null,
Expand Down

0 comments on commit 6a38c35

Please sign in to comment.