Skip to content

Commit

Permalink
feat: build with ndk r27b on top of webkitgtk 2.26.4 (#184)
Browse files Browse the repository at this point in the history
# Why

to support android 16k page sizes and react-native 0.77

# How

- migrate webkit repo from svn to git
- update to webkitgtk 2.26.4 (previous we had 2.26.1). the main reason is that git repo don't have 2.26.1 tag but 2.26 branch.
- change the version scheme. originally we use svn revision, but webkit team don't have revision anymore. the new version scheme will base on webkitgtk version.
  ```sh
  $ echo "2.26.4" | awk -F. '{printf "%d%03d%03d\n", $1, $2, $3}'
  2026004
  ```
- update ci, lib builder, and test projects
- use ndk r27b
- bump minSdkVersion to 24
- add `-Wl,-z,max-page-size=16384` linker flags
  • Loading branch information
Kudo authored Nov 25, 2024
1 parent 61ac7a8 commit 4a89838
Show file tree
Hide file tree
Showing 96 changed files with 3,916 additions and 8,683 deletions.
25 changes: 25 additions & 0 deletions .github/actions/cleanup-linux-disk-space/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (c) 650 Industries.
#

name: 'Cleanup GitHub Linux Runner Disk Space'
description: 'Cleanup unused preinstalled packages on the GitHub Ubuntu runners'

runs:
using: 'composite'
steps:
- name: '🧹 Cleanup preinstalled packages'
shell: bash
run: |
echo 'Disk space before cleanup'
df -aH
sudo apt-get remove -y --purge '^mysql-.*' '^mongodb-.*' '^mssql-.*' '^postgresql-.*' '^aspnetcore-*' '^dotnet-.*' '^php.*-.*' 'mono-complete' '^llvm-.*' 'powershell' 'google-chrome-*' 'microsoft-edge-*' 'firefox' 'nginx' 'apache2'
sudo apt-get autoremove -y
sudo rm -rf /usr/share/dotnet
echo 'Showing Android SDKs'
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --list
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --uninstall 'ndk;24.0.8215888' 'ndk;25.2.9519653' 'ndk;26.2.11394342'
echo 'Removing all Docker images'
docker rmi -f $(docker images -aq)
echo 'Disk space after cleanup'
df -aH
80 changes: 53 additions & 27 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
name: Build jsc-android and test

on:
workflow_dispatch: {}
push:
branches: [main]
pull_request:

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

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

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

- name: ⬢ Setup Node
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install packages
run: |
apt-get update
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 16
nvm use 16
nvm alias default 16
sudo apt-get update
sudo apt-get install coreutils curl git wget python3 ruby gperf -y
shell: bash

- name: Install Android packages
run: |
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
yes | sdkmanager --licenses || true
sdkmanager \
"cmake;3.22.1" \
"ndk;23.2.8568313"
"ndk;27.1.12297006"
# 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
mv "${ANDROID_HOME}/ndk/27.1.12297006/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/unicode" "${ANDROID_HOME}/ndk/27.1.12297006/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/unicode2"
echo "ANDROID_NDK=$ANDROID_HOME/ndk/27.1.12297006" >> $GITHUB_ENV
echo "PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools" >> $GITHUB_ENV
shell: bash

- name: Build
Expand All @@ -57,38 +59,62 @@ jobs:
mv dist.unstripped archive/
shell: bash

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


test:
needs: build
runs-on: macOS-latest
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: 🧹 Cleanup GitHub Linux runner disk space
uses: ./.github/actions/cleanup-linux-disk-space

- name: ⬢ Setup Node
uses: actions/setup-node@v4
with:
node-version: 22

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

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

- name: 🍺 Install Maestro
run: |
curl -Ls "https://get.maestro.mobile.dev" | bash
echo "${HOME}/.maestro/bin" >> $GITHUB_PATH
- name: Install node packages
run: yarn install --frozen-lockfile
working-directory: test

- name: ⚙️ Enable KVM for Android virtualization
shell: bash
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 21
api-level: 24
arch: x86_64
disable-animations: false
script: mv archive/dist . && cd test && yarn && cd android && ./gradlew :app:assembleRelease :app:assembleAndroidTest :app:connectedAndroidTest
target: google_apis
working-directory: test
script: |
mv ../archive/dist ../dist
npx expo run:android --variant release --no-bundler
maestro test maestro.yaml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This project is based on [facebook/android-jsc](https://github.com/facebook/andr
* Set `export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools/bin`
* Android NDK r19c: download from [NDK Archives](https://developer.android.com/ndk/downloads/older_releases.html)
* Set `export ANDROID_NDK=/path/to/android-ndk-r19c`
* Make sure you have Ruby (>2.3), Python (>2.7), Git, SVN, gperf
* Make sure you have Ruby (>2.3), Python (>2.7), Git, gperf

## Build instructions

Expand Down Expand Up @@ -235,7 +235,7 @@ packagingOptions {
```

## Resources
- [WebkitGTK Sources](https://svn.webkit.org/repository/webkit/releases/WebKitGTK/)
- [WebKit Sources](https://github.com/WebKit/WebKit)
- [ICU Sources](https://android.googlesource.com/platform/external/icu/)
- [Info about Webkit Revisions](https://trac.webkit.org/browser/webkit/releases/WebKitGTK)
- [Info about JSC version used on iOS](https://trac.webkit.org/browser/webkit/releases/WebKitGTK/webkit-2.18.2/Source/WebCore/Configurations/Version.xcconfig)
Expand Down
65 changes: 39 additions & 26 deletions lib/android-jsc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

def distDir = project.findProperty("distDir") ?: ""
def jniLibsDir = project.findProperty("jniLibsDir") ?: ""
Expand All @@ -11,42 +12,54 @@ if (!revision) throw new RuntimeException("expecting --project-prop revision=???
if (!i18n) throw new RuntimeException("expecting --project-prop i18n=??? but was empty")

android {
compileSdkVersion 28
namespace 'org.webkit.androidjsc'
compileSdkVersion 35

defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
defaultConfig {
minSdkVersion 24
targetSdkVersion 34
versionCode 1
versionName "1.0"
}

sourceSets {
main {
jniLibs.srcDirs = ["${jniLibsDir}"]
}
sourceSets {
main {
jniLibs.srcDirs = ["${jniLibsDir}"]
}
}

packagingOptions {
doNotStrip "**/libjsc.so"
}

packagingOptions {
doNotStrip "**/libjsc.so"
publishing {
singleVariant("release") {
}
}
}

dependencies {}

apply plugin: 'maven'
project.group = "org.webkit"
def artifactName = Boolean.valueOf(i18n) ? "android-jsc-intl" : "android-jsc"
project.version = "r${revision}"

task createAAR(type: Upload) {
project.group = "org.webkit"
def artifactName = Boolean.valueOf(i18n) ? "android-jsc-intl" : "android-jsc"
project.version = "r${revision}"

configuration = configurations.archives
repositories.mavenDeployer {
repository url: "file://${distDir}"
pom.project {
name "android-jsc"
artifactId artifactName
packaging "aar"
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
pom {
name = "android-jsc"
artifactId = artifactName
packaging = "aar"
}
}
}
repositories {
maven {
url = "file://${distDir}"
}
}
}
}
3 changes: 1 addition & 2 deletions lib/android-jsc/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.webkit.androidjsc" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
4 changes: 1 addition & 3 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:8.7.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -18,7 +17,6 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
mavenLocal()
}
Expand Down
61 changes: 37 additions & 24 deletions lib/cppruntime/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

def distDir = project.findProperty("distDir") ?: ""
def jniLibsDir = project.findProperty("jniLibsDir") ?: ""
Expand All @@ -9,37 +10,49 @@ if (!jniLibsDir) throw new RuntimeException("expecting --project-prop jniLibsDir
if (!revision) throw new RuntimeException("expecting --project-prop revision=??? but was empty")

android {
compileSdkVersion 28

defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
namespace 'org.webkit.androidjsc_cppruntime'
compileSdkVersion 35

defaultConfig {
minSdkVersion 24
targetSdkVersion 34
versionCode 1
versionName "1.0"
}

sourceSets {
main {
jniLibs.srcDirs = ["${jniLibsDir}"]
}
}

sourceSets {
main {
jniLibs.srcDirs = ["${jniLibsDir}"]
}
publishing {
singleVariant("release") {
}
}
}

dependencies {}

apply plugin: 'maven'

task createAAR(type: Upload) {
project.group = "org.webkit"
project.version = "r${revision}"

configuration = configurations.archives
repositories.mavenDeployer {
repository url: "file://${distDir}"
pom.project {
name "android-jsc"
artifactId "android-jsc-cppruntime"
packaging "aar"
project.group = "org.webkit"
project.version = "r${revision}"

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
pom {
name = "android-jsc"
artifactId = "android-jsc-cppruntime"
packaging = "aar"
}
}
}
repositories {
maven {
url = "file://${distDir}"
}
}
}
}
3 changes: 1 addition & 2 deletions lib/cppruntime/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.webkit.androidjsc_cppruntime" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
Binary file modified lib/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions lib/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Tue May 15 12:33:24 IDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
Loading

0 comments on commit 4a89838

Please sign in to comment.