Skip to content

feat: build with ndk r23c on top of webkitgtk 2.26.1 #179

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

Merged
merged 19 commits into from
Feb 5, 2023
Merged
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
48 changes: 36 additions & 12 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,50 @@
name: Build jsc-android and test

on: [push, pull_request]
on:
push:
branches: [main]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
container: reactnativecommunity/react-native-android:2019-9-4
container: reactnativecommunity/react-native-android:5.4

steps:
- uses: actions/checkout@v1

- name: 🔨 Use JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

- name: Install packages
run: |
apt-get update
apt-get install coreutils realpath curl git subversion python3.5 python3.5-dev ruby gperf -y
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
apt-get install coreutils curl git subversion wget python3 ruby gperf -y
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
echo 'export NVM_DIR="$HOME/.nvm"' >> "${HOME}/.bashrc"
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> "${HOME}/.bashrc"
source "${HOME}/.bashrc"
nvm install 10
nvm use 10
nvm alias default 10
nvm install 16
nvm use 16
nvm alias default 16
shell: bash

- name: Install Android packages
run: |
sdkmanager \
"cmake;3.10.2.4988404"
"cmake;3.22.1" \
"ndk;23.2.8568313"
# move out builtin icu headers from ndk and prevent icu build errors
mv "${ANDROID_HOME}/ndk/23.2.8568313/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/unicode" "${ANDROID_HOME}/ndk/23.2.8568313/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/unicode2"
echo "ANDROID_NDK=$ANDROID_HOME/ndk/23.2.8568313" >> $GITHUB_ENV
shell: bash

- name: Build
run: |
yarn install --frozen-lockfile
yarn clean
yarn download
yarn start
Expand All @@ -56,15 +70,25 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: 🔨 Use JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

- uses: actions/download-artifact@v2
with:
name: archive
path: archive

- name: Install node packages
run: yarn install --frozen-lockfile
working-directory: test

- name: Run test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 16
arch: x86
api-level: 21
arch: x86_64
disable-animations: false
script: mv archive/dist . && cd test && yarn && cd android && ./gradlew assembleRelease assembleAndroidTest connectedAndroidTest
script: mv archive/dist . && cd test && yarn && cd android && ./gradlew :app:assembleRelease :app:assembleAndroidTest :app:connectedAndroidTest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package-lock.json
/build
/dist
/dist.unstripped

# Created by https://www.gitignore.io/api/node,android,reactnative,intellij+all,androidstudio,visualstudiocode

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsc-android",
"version": "250230.2.1",
"version": "250231.0.0",
"description": "Pre-build version of JavaScriptCore to be used by React Native apps",
"repository": {
"type": "git",
Expand Down
11 changes: 11 additions & 0 deletions patches/ndkr23.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- target-org/webkit/Source/WTF/wtf/URLHelpers.cpp 2023-02-04 00:50:26
+++ target/webkit/Source/WTF/wtf/URLHelpers.cpp 2023-02-04 00:50:29
@@ -301,7 +301,7 @@
Optional<UChar32> previousCodePoint;
while (i < length) {
UChar32 c;
- U16_NEXT(buffer, i, length, c)
+ U16_NEXT(buffer, i, length, c);
UErrorCode error = U_ZERO_ERROR;
UScriptCode script = uscript_getScript(c, &error);
if (error != U_ZERO_ERROR) {
37 changes: 7 additions & 30 deletions scripts/compile/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,18 @@ TOOLCHAIN_PLATFORM=$(ls -1 $ANDROID_NDK/toolchains/llvm/prebuilt | head -1)
TOOLCHAIN_DIR="$ANDROID_NDK/toolchains/llvm/prebuilt/$TOOLCHAIN_PLATFORM/"

# settings
PLATFORM_CFLAGS_arm=" \
-march=armv7-a \
-mfloat-abi=softfp \
-mfpu=neon \
-mthumb \
"
PLATFORM_LDFLAGS_arm=" \
-march=armv7-a \
-Wl,--fix-cortex-a8 \
"
PLATFORM_CFLAGS_arm=""
PLATFORM_LDFLAGS_arm=""
JNI_ARCH_arm=armeabi-v7a

PLATFORM_LDFLAGS_arm64=""
JNI_ARCH_arm64=arm64-v8a

PLATFORM_CFLAGS_x86=" \
-march=i686 \
-mtune=intel \
-mssse3 \
-mfpmath=sse \
-m32 \
"
PLATFORM_CFLAGS_x86=""
PLATFORM_LDFLAGS_x86=""
JNI_ARCH_x86=x86

PLATFORM_CFLAGS_x86_64=" \
-march=x86-64 \
-msse4.2 \
-mpopcnt \
-m64 \
-mtune=intel \
"
PLATFORM_CFLAGS_x86_64=""
PLATFORM_LDFLAGS_x86_64=""
JNI_ARCH_x86_64=x86_64

Expand Down Expand Up @@ -119,7 +99,7 @@ DEBUG_SYMBOL_LEVEL="-g2"
if [[ "$BUILD_TYPE" = "Release" ]]
then
FRAME_POINTER_FLAG="-fomit-frame-pointer"
CFLAGS_BUILD_TYPE="-DNDEBUG -g0"
CFLAGS_BUILD_TYPE="-DNDEBUG -g0 -Oz -flto=full"
ICU_CFLAGS_BUILD_TYPE="-Oz"
else
FRAME_POINTER_FLAG="-fno-omit-frame-pointer"
Expand All @@ -133,7 +113,6 @@ COMMON_LDFLAGS=" \
-Wl,-z,noexecstack \
-Wl,--gc-sections \
-Wl,--exclude-libs,libgcc.a \
-Wl,--exclude-libs,libunwind.a \
-Wl,--no-undefined \
"

Expand All @@ -149,7 +128,7 @@ $FRAME_POINTER_FLAG \
-DCUSTOMIZE_REACT_NATIVE \
$SWITCH_COMMON_CFLAGS_INTL \
$CFLAGS_BUILD_TYPE \
-D__ANDROID_API__=${ANDROID_API} \
-D__ANDROID_MIN_SDK_VERSION__=${ANDROID_API} \
"

COMMON_CXXFLAGS=" \
Expand All @@ -158,10 +137,8 @@ COMMON_CXXFLAGS=" \
ICU_CFLAGS="$COMMON_CFLAGS $PLATFORM_CFLAGS $ICU_CFLAGS_BUILD_TYPE"
ICU_CXXFLAGS="$COMMON_CXXFLAGS $ICU_CFLAGS $ICU_CFLAGS_BUILD_TYPE"
ICU_LDFLAGS="$COMMON_LDFLAGS \
-fuse-ld=gold \
-Wl,--icf=safe \
$PLATFORM_LDFLAGS \
"

JSC_LDFLAGS="$COMMON_LDFLAGS"
JSC_CFLAGS="$COMMON_CFLAGS -DU_STATIC_IMPLEMENTATION=1 -DU_SHOW_CPLUSPLUS_API=0"
JSC_CFLAGS="$COMMON_CFLAGS -Wno-implicit-const-int-float-conversion -DU_STATIC_IMPLEMENTATION=1 -DU_SHOW_CPLUSPLUS_API=0 -DTRUE=1 -DFALSE=0"
6 changes: 4 additions & 2 deletions scripts/compile/icu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ $TARGETDIR/icu/source/configure --prefix=${INSTALL_DIR} \
LDFLAGS="$ICU_LDFLAGS" \
CC=$CROSS_COMPILE_PLATFORM_CC-clang \
CXX=$CROSS_COMPILE_PLATFORM_CC-clang++ \
AR=$CROSS_COMPILE_PLATFORM-ar \
RINLIB=$CROSS_COMPILE_PLATFORM-ranlib \
AR=$TOOLCHAIN_DIR/bin/llvm-ar \
LD=$TOOLCHAIN_DIR/bin/ld \
RANLIB=$TOOLCHAIN_DIR/bin/llvm-ranlib \
STRIP=$TOOLCHAIN_DIR/bin/llvm-strip \
--with-data-packaging=static

make -j5 install
Expand Down
3 changes: 2 additions & 1 deletion scripts/compile/jsc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ $TARGETDIR/webkit/Tools/Scripts/build-webkit \
--no-netscape-plugin-api \
--no-tools \
--cmakeargs="-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DUSE_LD_GOLD=OFF \
-DANDROID_ABI=${JNI_ARCH} \
-DANDROID_PLATFORM=${ANDROID_API} \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \
Expand All @@ -90,7 +91,7 @@ mkdir -p $INSTALL_UNSTRIPPED_DIR_I18N/$JNI_ARCH
mkdir -p $INSTALL_DIR_I18N/$JNI_ARCH
cp $TARGETDIR/webkit/WebKitBuild/$BUILD_TYPE/lib/libjsc.so $INSTALL_UNSTRIPPED_DIR_I18N/$JNI_ARCH
cp $TARGETDIR/webkit/WebKitBuild/$BUILD_TYPE/lib/libjsc.so $INSTALL_DIR_I18N/$JNI_ARCH
$TOOLCHAIN_DIR/$CROSS_COMPILE_PLATFORM/bin/strip $INSTALL_DIR_I18N/$JNI_ARCH/libjsc.so
$TOOLCHAIN_DIR/bin/llvm-strip $INSTALL_DIR_I18N/$JNI_ARCH/libjsc.so
mv $TARGETDIR/webkit/WebKitBuild $TARGETDIR/webkit/${CROSS_COMPILE_PLATFORM}-${FLAVOR}

cp $TOOLCHAIN_DIR/sysroot/usr/lib/$CROSS_COMPILE_PLATFORM/libc++_shared.so $INSTALL_CPPRUNTIME_DIR
4 changes: 3 additions & 1 deletion scripts/info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ URL="https://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-${npm_pa
ROOTDIR=$PWD

INFO=$(svn info "${URL}")
export REVISION=$(LANG=en svn info "${URL}" | sed -n 's/^Last Changed Rev: //p')
export REVISION=$(node -e "console.log(require('./package.json').version.split('.')[0])")
WEBKIT_REVISION=$(LANG=en svn info "${URL}" | sed -n 's/^Last Changed Rev: //p')
CONFIG=$(node -e "console.log(require('$ROOTDIR/package.json').config)")
APPLE_VERSION=$(svn cat "${URL}/Source/WebCore/Configurations/Version.xcconfig" | grep 'MAJOR_VERSION\s=\|MINOR_VERSION\s=\|TINY_VERSION\s=\|MICRO_VERSION\s=\|NANO_VERSION\s=')

Expand All @@ -15,6 +16,7 @@ else
fi

printf "\n\n\n\n\n\t\t\tRevision: \x1B[32m$REVISION\x1B[0m\n\n\n"
printf "WebKit revision:\n$WEBKIT_REVISION\n\n"
printf "Config:\n$CONFIG\n\n"
printf "Info:\n$INFO\n\n"
printf "AppleWebkit:\n$APPLE_VERSION\n\n"
Expand Down
3 changes: 3 additions & 0 deletions scripts/patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ JSC_PATCHSET=(
# Feature toggles, e.g. disable unnecessary build or JIT settings
"jsc_features.patch"

# NDK r23 errors
"ndkr23.patch"

# NDK does not support backtrace and execinfo.h
"jsc_fix_build_error_execinfo.patch"

Expand Down
6 changes: 0 additions & 6 deletions test/.buckconfig

This file was deleted.

75 changes: 0 additions & 75 deletions test/.flowconfig

This file was deleted.

1 change: 0 additions & 1 deletion test/.gitattributes

This file was deleted.

24 changes: 14 additions & 10 deletions test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local

# Android/IntelliJ
#
Expand All @@ -28,32 +29,35 @@ build/
.gradle
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# CocoaPods
# Ruby / CocoaPods
/ios/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*
Loading