Skip to content

Commit

Permalink
V8 110 (#35)
Browse files Browse the repository at this point in the history
Upgrade to v8 110 with ios xcframework build
  • Loading branch information
Kudo authored Feb 25, 2023
1 parent b32a20a commit ce0dd06
Show file tree
Hide file tree
Showing 23 changed files with 190 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .github/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN apt-get update
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get install -y sudo

RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1001 ubuntu
RUN echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER ubuntu
WORKDIR /home/ubuntu
11 changes: 3 additions & 8 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build for Android

on: [push]
on:
push:
workflow_dispatch:

env:
CACHE_KEY_SUFFIX: v2
Expand All @@ -22,13 +24,6 @@ jobs:
NO_JIT: ${{ !contains(matrix.variant, 'jit') }}

steps:
- name: Setup docker workspace
run: |
sudo sh -c "chown -R ubuntu $HOME"
sudo sh -c "chmod 777 $GITHUB_WORKSPACE"
# sudo sh -c "chmod 777 $GITHUB_WORKSPACE/../../_temp"
sudo sh -c "chmod 777 /home"
- uses: actions/checkout@v3

- name: Setup Ubuntu environment
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: iOS build

on: [push]
on:
push:
workflow_dispatch:

jobs:
build:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tools_macos_android.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: v8-android tools builder for macos host

on: [push]
on:
workflow_dispatch:

env:
CACHE_KEY_SUFFIX: v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To integrate with React Native, please check [react-native-v8](https://github.co
1. Single libv8android.so (or libv8.so on iOS) file.
2. Support i18n and JavaScript [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).
3. V8 Lite mode (JIT-less mode) https://v8.dev/blog/v8-lite
4. Build by Android official NDK r21e which prevent potential ABI incompatible issue to integrate with React Native.
4. Build by Android official NDK r23c which prevent potential ABI incompatible issue to integrate with React Native.

## Build Guides

Expand Down
1 change: 1 addition & 0 deletions mkcodecache/mkcodecache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "include/v8-message.h"
#include "include/v8-script.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/wrappers.h"

#include <chrono>

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "10.100.1",
"version": "11.110.0",
"workspaces": [
"packages/*"
],
Expand All @@ -15,6 +15,6 @@
"start_tools_macos_android": "bash -c '. ./scripts/export_npm_env.sh && TOOLS_ONLY=true ./scripts/start.sh macos_android'"
},
"config": {
"V8": "10.0.139.9"
"V8": "11.0.226.16"
}
}
2 changes: 1 addition & 1 deletion packages/v8-android-jit-nointl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v8-android-jit-nointl",
"version": "10.100.1",
"version": "11.110.0",
"description": "Pre-build version of V8 to be used by React Native apps",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/v8-android-jit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v8-android-jit",
"version": "10.100.1",
"version": "11.110.0",
"description": "Pre-build version of V8 to be used by React Native apps",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/v8-android-nointl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v8-android-nointl",
"version": "10.100.1",
"version": "11.110.0",
"description": "Pre-build version of V8 to be used by React Native apps (Non Intl supported version)",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/v8-android-tools-linux/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v8-android-tools-linux",
"version": "10.100.1",
"version": "11.110.0",
"description": "Tools for v8-android",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/v8-android-tools-macos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v8-android-tools-macos",
"version": "10.100.1",
"version": "11.110.0",
"description": "Tools for v8-android",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/v8-android/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v8-android",
"version": "10.100.1",
"version": "11.110.0",
"description": "Pre-build version of V8 to be used by React Native apps",
"repository": {
"type": "git",
Expand Down
26 changes: 26 additions & 0 deletions packages/v8-ios/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "v8-ios",
"version": "11.110.0",
"description": "Pre-build version of V8 to be used by React Native apps",
"repository": {
"type": "git",
"url": "git+https://github.com/Kudo/v8-android-buildscripts.git",
"directory": "packages/v8-ios"
},
"keywords": [
"react-native",
"ios",
"v8"
],
"license": "BSD-2-Clause",
"bugs": {
"url": "https://github.com/Kudo/v8-android-buildscripts/issues"
},
"homepage": "https://github.com/Kudo/v8-android-buildscripts#readme",
"files": [
"v8-ios.podspec",
"include/",
"v8.xcframework/",
"tools/"
]
}
21 changes: 21 additions & 0 deletions packages/v8-ios/v8-ios.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "json"

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = package['name']
s.version = package['version']
s.summary = package['description']
s.license = package['license']

s.authors = package['author']
s.homepage = package['homepage']
s.platforms = { :ios => "12.0" }

s.source = { :http => "https://registry.npmjs.org/v8-ios/-/v8-ios-#{s.version}.tgz" }

s.vendored_framework = 'v8.xcframework'
s.source_files = 'include/**/*.h'
s.preserve_paths = 'include'
s.header_mappings_dir = 'include'
end
4 changes: 2 additions & 2 deletions patches/custom_timezone.patch
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ index f64538ec1c..8460c610c6 100644
#undef TIME_ZONE_DETECTION_ASSERT_EQ

MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context,
@@ -9046,12 +9047,13 @@ void Isolate::SetAllowAtomicsWait(bool allow) {
@@ -9869,12 +9870,13 @@ void Isolate::SetAllowAtomicsWait(bool allow) {
}

void v8::Isolate::DateTimeConfigurationChangeNotification(
- TimeZoneDetection time_zone_detection) {
+ TimeZoneDetection time_zone_detection, const char* custom_timezone_id) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
LOG_API(i_isolate, Isolate, DateTimeConfigurationChangeNotification);
API_RCS_SCOPE(i_isolate, Isolate, DateTimeConfigurationChangeNotification);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
i_isolate->date_cache()->ResetDateCache(
- static_cast<base::TimezoneCache::TimeZoneDetection>(time_zone_detection));
Expand Down
47 changes: 0 additions & 47 deletions patches/v8_97_android_unwind_link_error.patch

This file was deleted.

26 changes: 26 additions & 0 deletions patches/v8_android_unwind_link_error.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/build/config/android/BUILD.gn b/build/config/android/BUILD.gn
index efdd3826e..71d492424 100644
--- a/build/config/android/BUILD.gn
+++ b/build/config/android/BUILD.gn
@@ -55,9 +55,18 @@ config("compiler") {
}
}

- # Instead of using an unwind lib from the toolchain,
- # buildtools/third_party/libunwind will be built and used directly.
- ldflags += [ "--unwindlib=none" ]
+ if (current_cpu == "x86") {
+ arch_dir = "i386"
+ } else if (current_cpu == "x64") {
+ arch_dir = "x86_64"
+ } else if (current_cpu == "arm") {
+ arch_dir = "arm"
+ } else if (current_cpu == "arm64") {
+ arch_dir = "aarch64"
+ } else {
+ assert(false, "Unknown Android ABI: " + current_cpu)
+ }
+ lib_dirs = [ "$android_ndk_library_path/clang/12.0.9/lib/linux/$arch_dir"]

# $compile_api_level corresponds to the API level used for the sysroot path
# calculation in //build/config/android/config.gni
53 changes: 41 additions & 12 deletions scripts/archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function makeDistPackageDir() {
}

DIST_PACKAGE_DIR=$(makeDistPackageDir)
mkdir -p "${DIST_PACKAGE_DIR}"

function createAAR() {
printf "\n\n\t\t===================== create aar =====================\n\n"
Expand All @@ -30,16 +31,45 @@ function createAAR() {
popd
}

function createUniversalDylib() {
printf "\n\n\t\t===================== create universal dylib =====================\n\n"
mkdir -p "${BUILD_DIR}/lib/universal"
lipo "${BUILD_DIR}/lib/arm64/libv8.dylib" "${BUILD_DIR}/lib/x64/libv8.dylib" -output "${BUILD_DIR}/lib/universal/libv8.dylib" -create
}

function copyDylib() {
printf "\n\n\t\t===================== copy dylib =====================\n\n"
mkdir -p "${DIST_PACKAGE_DIR}"
cp -Rf "${BUILD_DIR}/lib" "${DIST_PACKAGE_DIR}/"
function createXcframework() {
plist=$(cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>v8</string>
<key>CFBundleIdentifier</key>
<string>io.csie.kudo.v8.framework</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
</dict>
</plist>
EOF
)
printf "\n\n\t\t===================== create ios device framework =====================\n\n"
mkdir -p "${BUILD_DIR}/ios-arm64/v8.framework"
echo "${plist}" > "${BUILD_DIR}/ios-arm64/v8.framework/Info.plist"
cp -f "${BUILD_DIR}/lib/device/arm64/libv8.dylib" "${BUILD_DIR}/ios-arm64/v8.framework/v8"
install_name_tool -id "@rpath/v8.framework/v8" "${BUILD_DIR}/ios-arm64/v8.framework/v8"

printf "\n\n\t\t===================== create ios simulator framework =====================\n\n"
mkdir -p "${BUILD_DIR}/ios-arm64_x86_64-simulator/v8.framework"
echo "${plist}" > "${BUILD_DIR}/ios-arm64_x86_64-simulator/v8.framework/Info.plist"
lipo "${BUILD_DIR}/lib/simulator/arm64/libv8.dylib" "${BUILD_DIR}/lib/simulator/x64/libv8.dylib" -output "${BUILD_DIR}/ios-arm64_x86_64-simulator/v8.framework/v8" -create
install_name_tool -id "@rpath/v8.framework/v8" "${BUILD_DIR}/ios-arm64_x86_64-simulator/v8.framework/v8"

printf "\n\n\t\t===================== create ios xcframework =====================\n\n"
rm -rf "${BUILD_DIR}/v8.xcframework"
xcodebuild -create-xcframework -framework "${BUILD_DIR}/ios-arm64/v8.framework" -framework "${BUILD_DIR}/ios-arm64_x86_64-simulator/v8.framework" -output "${BUILD_DIR}/v8.xcframework"

cp -Rf "${BUILD_DIR}/v8.xcframework" "${DIST_PACKAGE_DIR}/v8.xcframework"
}

function createUnstrippedLibs() {
Expand Down Expand Up @@ -87,8 +117,7 @@ if [[ ${PLATFORM} = "android" ]]; then
copyTools
copySnapshotBlobIfNeeded
elif [[ ${PLATFORM} = "ios" ]]; then
createUniversalDylib
copyDylib
createXcframework
copyHeaders
copyTools
copySnapshotBlobIfNeeded
Expand Down
Loading

0 comments on commit ce0dd06

Please sign in to comment.