Skip to content
Open
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: 29 additions & 5 deletions .github/actions/cleanup-linux-disk-space/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,37 @@ runs:
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'
# Regular package cleanup
sudo apt-get remove -y --purge '^mysql-.*' '^mongodb-.*' '^mssql-.*' '^postgresql-.*' '^aspnetcore-*' '^dotnet-.*' '^php.*-.*' 'mono-complete' '^llvm-.*' 'powershell' 'google-chrome-*' 'microsoft-edge-*' 'firefox' 'nginx' 'apache2' 'ghc' '^ghc-*'
sudo apt-get autoremove -y
# Remove unnecessary large directories
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'
sudo rm -rf /usr/local/.ghcup /opt/ghc
# Android SDK cleanup
echo 'Showing installed Android SDKs'
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --list_installed
echo 'Cleaning unnecessary Android SDK components...'
echo 'Removing old build tools...'
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --uninstall "build-tools;31.0.0" "build-tools;32.0.0" "build-tools;33.0.0" "build-tools;33.0.1" "build-tools;33.0.2" "build-tools;33.0.3" "build-tools;34.0.0"
echo 'Removing old platforms...'
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --uninstall "platforms;android-31" "platforms;android-32" "platforms;android-33" "platforms;android-33-ext4" "platforms;android-33-ext5" "platforms;android-34" "platforms;android-34-ext8" "platforms;android-34-ext10" "platforms;android-34-ext11" "platforms;android-34-ext12"
echo 'Removing NDKs...'
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --uninstall "ndk;26.3.11579264"
echo 'Removing extras...'
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --uninstall "extras;android;m2repository" "extras;google;google_play_services" "extras;google;m2repository"
# Docker cleanup
echo 'Cleaning up Docker resources'
docker system prune -af || true
echo 'Removing all Docker images'
docker rmi -f $(docker images -aq)
docker rmi -f $(docker images -aq) || true
echo 'Disk space after cleanup'
df -aH
200 changes: 182 additions & 18 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
name: Build jsc-android and test

on:
workflow_dispatch: {}
workflow_dispatch:
inputs:
publish:
description: 'Publish npm packages after build/test succeed'
type: boolean
default: false
npm-tag:
description: 'npm dist-tag'
required: false
default: latest
dry-run:
description: 'Run npm publish in dry-run mode'
type: boolean
default: true
push:
branches: [main]
pull_request:
Expand All @@ -12,10 +25,16 @@ jobs:
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}
NDK_VERSION_27: '27.1.12297006'
NDK_VERSION_28: '28.2.13676358'
BUILD_CACHE_VERSION: v1

steps:
- uses: actions/checkout@v4

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

- name: 🔨 Use JDK 17
uses: actions/setup-java@v4
with:
Expand All @@ -27,39 +46,126 @@ jobs:
with:
node-version: 22

- name: Compute build cache key
id: build-hash
run: |
HASH=$(node scripts/build-hash.js)
echo "hash=$HASH" >> "$GITHUB_OUTPUT"

- name: Restore JSC build artifacts
id: cache-dist
uses: actions/cache@v4
with:
path: |
dist-ndk27
dist-ndk27.unstripped
dist-ndk28
dist-ndk28.unstripped
dist-ndk29
dist-ndk29.unstripped
key: jsc-dist-${{ env.BUILD_CACHE_VERSION }}-${{ steps.build-hash.outputs.hash }}

- name: Restore WebKit sources
id: cache-download
uses: actions/cache@v4
with:
path: build/download
key: jsc-download-${{ env.BUILD_CACHE_VERSION }}-${{ steps.build-hash.outputs.hash }}
restore-keys: |
jsc-download-${{ env.BUILD_CACHE_VERSION }}-

- name: Install packages
run: |
sudo apt-get update
sudo apt-get install coreutils curl git wget python3 ruby gperf -y
sudo apt-get install coreutils curl git wget python3 ruby gperf ccache -y
shell: bash

- name: Restore ccache
id: cache-ccache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-${{ env.BUILD_CACHE_VERSION }}-${{ runner.os }}-${{ env.NDK_VERSION_27 }}-${{ steps.build-hash.outputs.hash }}
restore-keys: |
ccache-${{ env.BUILD_CACHE_VERSION }}-${{ runner.os }}-${{ env.NDK_VERSION_27 }}-

- name: Configure ccache
run: |
mkdir -p ~/.cache/ccache
if command -v ccache >/dev/null 2>&1; then
ccache --max-size=5G
ccache --zero-stats || true
fi
shell: bash

- name: Cache Android NDK r27
id: cache-ndk-27
uses: actions/cache@v4
with:
path: ${{ env.ANDROID_HOME }}/ndk/${{ env.NDK_VERSION_27 }}
key: android-ndk-${{ runner.os }}-${{ env.NDK_VERSION_27 }}

- 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;27.1.12297006"
# move out builtin icu headers from ndk and prevent icu build errors
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
sdkmanager "cmake;3.22.1"
if [[ ! -d "${ANDROID_HOME}/ndk/${NDK_VERSION_27}" ]]; then
sdkmanager "ndk;${NDK_VERSION_27}"
fi
UNICODE_DIR="${ANDROID_HOME}/ndk/${NDK_VERSION_27}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/unicode"
if [[ -d "${UNICODE_DIR}" ]]; then
mv "${UNICODE_DIR}" "${UNICODE_DIR}2"
fi
echo "ANDROID_NDK=$ANDROID_HOME/ndk/${NDK_VERSION_27}" >> $GITHUB_ENV
echo "PATH=$PATH" >> $GITHUB_ENV
shell: bash

- name: Install dependencies
run: yarn install --frozen-lockfile
shell: bash

- name: Clean previous build outputs
if: steps.cache-dist.outputs.cache-hit != 'true'
run: |
rm -rf dist dist.unstripped dist-ndk* build/target* build/compiled* build/cppruntime*
shell: bash

- name: Download sources
if: steps.cache-download.outputs.cache-hit != 'true'
run: yarn download
shell: bash

- name: Build
if: steps.cache-dist.outputs.cache-hit != 'true'
run: yarn start
shell: bash

- name: Show ccache stats
if: steps.cache-dist.outputs.cache-hit != 'true'
run: |
yarn install --frozen-lockfile
yarn clean
yarn download
yarn start
if command -v ccache >/dev/null 2>&1; then
ccache --show-stats
fi
shell: bash

- name: Archive
run: |
rm -rf archive
mkdir -p archive
mv dist archive/
mv dist.unstripped archive/
shopt -s nullglob
found=0
for dir in dist-ndk*; do
if [[ -d "$dir" ]]; then
cp -R "$dir" archive/
found=1
fi
done
shopt -u nullglob
if [[ $found -eq 0 ]]; then
echo "No distribution directories were produced." >&2
exit 1
fi
shell: bash

- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -96,8 +202,12 @@ jobs:

- name: Extract archive
run: |
mv archive/dist dist
mv archive/dist.unstripped dist.unstripped
shopt -s nullglob
for dir in archive/dist-ndk*; do
dest=$(basename "$dir")
mv "$dir" "$dest"
done
shopt -u nullglob
rmdir archive
shell: bash

Expand Down Expand Up @@ -125,6 +235,7 @@ jobs:
target: google_apis
working-directory: test
script: |
export JSC_GRADLE_DIST_PATH=../../dist-ndk27
npx expo run:android --variant release --no-bundler
adb logcat -c
set +e
Expand All @@ -142,3 +253,56 @@ jobs:
$HOME/.maestro/tests/**/*
test/android/app/build/outputs/apk/release/app-release.apk
test/adb.log

publish:
if: github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true'
needs:
- build
- test
runs-on: ubuntu-latest
environment:
name: npm-publish
url: https://www.npmjs.com/package/jsc-android
permissions:
contents: read
steps:
- uses: actions/checkout@v4

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

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

- name: Install dependencies
run: yarn install --frozen-lockfile
shell: bash

- name: Verify npm token availability
if: github.event.inputs.dry-run != 'true'
run: |
if [[ -z "${NPM_TOKEN:-}" ]]; then
echo "NPM_TOKEN secret is required for publishing." >&2
exit 1
fi
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
shell: bash

- name: Publish packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: 'true'
run: |
TAG="${{ github.event.inputs.npm-tag }}"
DRY_RUN="${{ github.event.inputs.dry-run }}"
PUBLISH_ARGS=("-T" "$TAG")
if [[ "$DRY_RUN" == 'true' ]]; then
PUBLISH_ARGS+=("--dry-run")
fi
node scripts/publish.js "${PUBLISH_ARGS[@]}" archive
shell: bash
4 changes: 4 additions & 0 deletions lib/jsc-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ android {
versionCode 1
versionName "1.0"

ndk {
abiFilters 'arm64-v8a', 'x86_64'
}

externalNativeBuild {
cmake {
arguments '-DANDROID_STL=c++_shared',
Expand Down
39 changes: 36 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,47 @@
"/dist"
],
"scripts": {
"clean": "rm -rf dist; rm -rf build",
"clean": "rm -rf dist dist.unstripped dist-ndk* dist-ndk*.unstripped; rm -rf build",
"info": "./scripts/info.sh",
"download": "./scripts/download.sh",
"start": "./scripts/start.sh"
},
"config": {
"webkitGTK": "2.26.4",
"chromiumICUCommit": "64e5d7d43a1ff205e3787ab6150bbc1a1837332b"
"bunWebKitRepo": "https://github.com/oven-sh/WebKit.git",
"bunWebKitCommit": "26e6460697dab3e8681489ce67857434b2180e6f",
"icuRelease": "release-74-2",
"icuArchive": "icu4c-74_2-src.tgz",
"ndkVariants": [
{
"id": "ndk27",
"label": "Android NDK r27",
"npmPackage": "jsc-android-ndk27",
"pkgRevisionPrefixes": ["27."],
"buildSuffix": "ndk27",
"distDir": "dist-ndk27",
"distUnstrippedDir": "dist-ndk27.unstripped",
"disableLoopVectorization": true
},
{
"id": "ndk28c",
"label": "Android NDK r28c",
"npmPackage": "jsc-android",
"pkgRevisionPrefixes": ["28.2."],
"buildSuffix": "ndk28",
"distDir": "dist-ndk28",
"distUnstrippedDir": "dist-ndk28.unstripped",
"default": true
},
{
"id": "ndk29",
"label": "Android NDK r29",
"npmPackage": "jsc-android-ndk29",
"pkgRevisionPrefixes": ["29."],
"buildSuffix": "ndk29",
"distDir": "dist-ndk29",
"distUnstrippedDir": "dist-ndk29.unstripped"
}
]
},
"devDependencies": {
"commander": "^12.1.0",
Expand Down
30 changes: 30 additions & 0 deletions patches/jsc_android_collator_static.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/webkit/Source/WTF/wtf/unicode/CollatorDefault.cpp b/webkit/Source/WTF/wtf/unicode/CollatorDefault.cpp
index 9a45990fa7..b709f02052 100644
--- a/webkit/Source/WTF/wtf/unicode/CollatorDefault.cpp
+++ b/webkit/Source/WTF/wtf/unicode/CollatorDefault.cpp
@@ -27,13 +27,15 @@
*/

#include "config.h"
+#include <wtf/text/StringView.h>
+#include <wtf/text/WTFString.h>
#include <wtf/unicode/Collator.h>

#if UCONFIG_NO_COLLATION

namespace WTF {

-int Collator::collate(StringView a, StringView b) const
+int Collator::collate(StringView a, StringView b)
{
unsigned commonLength = std::min(a.length(), b.length());
for (unsigned i = 0; i < commonLength; ++i) {
@@ -51,7 +53,7 @@ int Collator::collate(StringView a, StringView b) const
return 0;
}

-int Collator::collate(const char8_t* a, const char8_t* b) const
+int Collator::collate(const char8_t* a, const char8_t* b)
{
return collate(String::fromUTF8(byteCast<char>(a)), String::fromUTF8(byteCast<char>(b)));
}
Loading
Loading