Skip to content

Support JavaScriptCore 6.0 #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,49 @@ jobs:
cxx: clang++
type: static
backend: JavaScriptCore
javascriptcore_api_version: "4.0"
- os: ubuntu-latest
cc: gcc
cxx: g++
type: static
backend: JavaScriptCore
javascriptcore_api_version: "4.0"
- os: ubuntu-latest
cc: clang
cxx: clang++
type: shared
backend: JavaScriptCore
javascriptcore_api_version: "4.0"
- os: ubuntu-latest
cc: gcc
cxx: g++
type: shared
backend: JavaScriptCore
javascriptcore_api_version: "4.0"
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static
backend: JavaScriptCore
javascriptcore_api_version: "6.0"
- os: ubuntu-latest
cc: gcc
cxx: g++
type: static
backend: JavaScriptCore
javascriptcore_api_version: "6.0"
- os: ubuntu-latest
cc: clang
cxx: clang++
type: shared
backend: JavaScriptCore
javascriptcore_api_version: "6.0"
- os: ubuntu-latest
cc: gcc
cxx: g++
type: shared
backend: JavaScriptCore
javascriptcore_api_version: "6.0"

# Sanitizers
- os: ubuntu-latest
Expand All @@ -54,12 +82,14 @@ jobs:
type: static
options: -DINCLUDEJS_ADDRESS_SANITIZER:BOOL=ON
backend: JavaScriptCore
javascriptcore_api_version: "4.0"
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static
options: -DINCLUDEJS_UNDEFINED_SANITIZER:BOOL=ON
backend: JavaScriptCore
javascriptcore_api_version: "4.0"
- os: macos-latest
cc: clang
cxx: clang++
Expand All @@ -82,7 +112,7 @@ jobs:
if: runner.os == 'linux'
run: |
sudo apt-get update --yes
sudo apt-get install --yes clang-format libjavascriptcoregtk-4.0-dev
sudo apt-get install --yes clang-format libjavascriptcoregtk-${{ matrix.platform.javascriptcore_api_version }}-dev

# See https://github.com/actions/runner-images/issues/8659
- name: Workaround Clang issue (GNU/Linux)
Expand All @@ -105,6 +135,7 @@ jobs:
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DINCLUDEJS_BACKEND:STRING=${{ matrix.platform.backend }}
-DINCLUDEJS_BACKEND_JAVASCRIPTCORE_API_VERSION:STRING=${{ matrix.platform.javascriptcore_api_version }}
-DINCLUDEJS_TESTS:BOOL=ON
-DINCLUDEJS_DOCS:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=OFF
Expand All @@ -116,6 +147,7 @@ jobs:
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DINCLUDEJS_BACKEND:STRING=${{ matrix.platform.backend }}
-DINCLUDEJS_BACKEND_JAVASCRIPTCORE_API_VERSION:STRING=${{ matrix.platform.javascriptcore_api_version }}
-DINCLUDEJS_TESTS:BOOL=ON
-DINCLUDEJS_DOCS:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=ON
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(CMAKE_CXX_STANDARD 17)

# Options
set(INCLUDEJS_BACKEND "JavaScriptCore" CACHE STRING "The IncludeJS Engine backend")
set(INCLUDEJS_BACKEND_JAVASCRIPTCORE_API_VERSION "" CACHE STRING "Build IncludeJS against a specific version of JavaScriptCore (empty means no preference)")
option(INCLUDEJS_ENGINE "Build the IncludeJS engine library" ON)
option(INCLUDEJS_TESTS "Build the IncludeJS tests" OFF)
option(INCLUDEJS_DOCS "Build the IncludeJS docs" OFF)
Expand Down
1 change: 1 addition & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendorpull https://github.com/sourcemeta/vendorpull 70342aaf458e6cb80baeb5b718901075fc42ede6
noa https://github.com/sourcemeta/noa 9da0f1877859f60e439e31856cd4ef5fd4ca6063
googletest https://github.com/google/googletest 987e225614755fec7253aa95bf959c09e0d380d7
webkitgtk https://github.com/WebKit/WebKit webkitgtk-2.43.4
35 changes: 34 additions & 1 deletion cmake/FindJavaScriptCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,26 @@ if(NOT JavaScriptCore_FOUND)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_library(javascript_core INTERFACE IMPORTED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(JAVASCRIPTCORE REQUIRED javascriptcoregtk-4.0)

# If find_package(JavaScriptCore [version]) is called we only look for that
# otherwise loop through a list of supported options, pick the first one found
# and error out if there is no match
if(JavaScriptCore_FIND_VERSION)
pkg_check_modules(JAVASCRIPTCORE javascriptcoregtk-${JavaScriptCore_FIND_VERSION} REQUIRED)
else()
set(supported_versions 6.0 4.1 4.0)
foreach(ver ${supported_versions})
pkg_check_modules(JAVASCRIPTCORE javascriptcoregtk-${ver})
if(JAVASCRIPTCORE_FOUND)
set(JavaScriptCore_FIND_VERSION ${ver})
break()
endif()
endforeach()
if(NOT JAVASCRIPTCORE_FOUND)
message(FATAL_ERROR "Required package JavaScriptCore was not found")
endif()
endif()

set_property(TARGET javascript_core PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${JAVASCRIPTCORE_INCLUDE_DIRS})
set_property(TARGET javascript_core PROPERTY
Expand All @@ -17,6 +36,20 @@ if(NOT JavaScriptCore_FOUND)
INTERFACE_LINK_OPTIONS ${JAVASCRIPTCORE_LDFLAGS})
set_property(TARGET javascript_core PROPERTY
INTERFACE_LINK_LIBRARIES ${JAVASCRIPTCORE_LINK_LIBRARIES})

if(JavaScriptCore_FIND_VERSION STREQUAL "6.0")
# NOTE: this is required since WebkitGTK (which includes JavaScriptCore) only
# exposes the GLib headers starting in versions after 4.0
# see: https://github.com/WebKit/WebKit/blob/main/Source/WebKit/gtk/migrating-to-webkitgtk-6.0.md#stop-using-deprecated-apis
file(GLOB headers ${PROJECT_SOURCE_DIR}/vendor/webkitgtk/Source/JavaScriptCore/API/*.h)
foreach(header ${headers})
cmake_path(GET header FILENAME header_filename)
configure_file("${header}" "${PROJECT_BINARY_DIR}/javascriptcore-headers/JavaScriptCore/${header_filename}" COPYONLY)
endforeach()
set_property(TARGET javascript_core PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${PROJECT_BINARY_DIR}/javascriptcore-headers")
endif()

add_library(JavaScriptCore::JavaScriptCore ALIAS javascript_core)
set(JavaScriptCore_FOUND ON)
endif()
Expand Down
202 changes: 202 additions & 0 deletions vendor/webkitgtk.mask

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading