diff --git a/.github/workflows/android_build.yml b/.github/workflows/android_build.yml index 260ccef02..45d927e78 100644 --- a/.github/workflows/android_build.yml +++ b/.github/workflows/android_build.yml @@ -1,21 +1,163 @@ name: Android Build +concurrency: + group: android_build_${{ github.ref }} + cancel-in-progress: true + on: - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - paths-ignore: - - '**.rst' - - 'docs/**' - push: - paths-ignore: - - '**.rst' - - 'docs/**' + workflow_dispatch: + +env: + JAVET_NODE_VERSION: 18.17.1 + JAVET_V8_VERSION: 11.6.189.18 + JAVET_VERSION: 2.2.2 + ROOT: /home/runner/work/Javet jobs: + build_javet_arm: + name: Build Javet arm + runs-on: ubuntu-latest + + steps: + + - name: Checkout the code + uses: actions/checkout@v3 + + - name: Setup Ubuntu + run: | + sudo apt-get install -y execstack gcc-multilib + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Setup Android NDK + id: setup-ndk + uses: nttld/setup-ndk@v1 + with: + ndk-version: r25b + local-cache: true + + - name: Setup Path + run: | + echo "${{ env.ROOT }}/google/depot_tools" >> $GITHUB_PATH + + - name: Build V8 + run: | + cd ${{ env.ROOT }} + mkdir google + cd google + git clone --depth=10 --branch=main https://chromium.googlesource.com/chromium/tools/depot_tools.git + cd depot_tools + git checkout remotes/origin/main + cd .. + fetch v8 + cd v8 + git checkout ${{ env.JAVET_V8_VERSION }} + ./build/install-build-deps.sh + cd .. + echo 'target_os = ["android"]' >> .gclient + gclient sync -D + cd v8 + python3 tools/dev/v8gen.py arm.release -- 'target_os="android"' 'target_cpu="arm"' 'v8_target_cpu="arm"' v8_monolithic=true v8_use_external_startup_data=false is_component_build=false v8_enable_i18n_support=false v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false v8_enable_sandbox=false + ninja -C out.gn/arm.release v8_monolith + + - name: Setup JDK 11 + uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: 11 + + - name: Setup Cmake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.23.x' + + - name: Build Javet JNI + run: | + cd ${{ env.ROOT }}/Javet/cpp + sh ./build-android.sh -DV8_DIR=${{ env.ROOT }}/google/v8 -DCMAKE_ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }} -DCMAKE_ANDROID_ARCH=arm + + - name: Upload the Artifact + uses: actions/upload-artifact@v3 + with: + name: javet-linux-v8-arm-${{ env.JAVET_VERSION }} + path: android/javet-android/src/main/jniLibs/armeabi-v7a/*.so + + build_javet_arm64: + name: Build Javet arm64 + runs-on: ubuntu-latest + + steps: - javet_android: + - name: Checkout the code + uses: actions/checkout@v3 + + - name: Setup Ubuntu + run: | + sudo apt-get install -y execstack gcc-multilib + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Setup Android NDK + id: setup-ndk + uses: nttld/setup-ndk@v1 + with: + ndk-version: r25b + local-cache: true + + - name: Setup Path + run: | + echo "${{ env.ROOT }}/google/depot_tools" >> $GITHUB_PATH + + - name: Build V8 + run: | + cd ${{ env.ROOT }} + mkdir google + cd google + git clone --depth=10 --branch=main https://chromium.googlesource.com/chromium/tools/depot_tools.git + cd depot_tools + git checkout remotes/origin/main + cd .. + fetch v8 + cd v8 + git checkout ${{ env.JAVET_V8_VERSION }} + ./build/install-build-deps.sh + cd .. + echo 'target_os = ["android"]' >> .gclient + gclient sync -D + cd v8 + python3 tools/dev/v8gen.py arm64.release -- 'target_os="android"' 'target_cpu="arm64"' 'v8_target_cpu="arm64"' v8_monolithic=true v8_use_external_startup_data=false is_component_build=false v8_enable_i18n_support=false v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false v8_enable_sandbox=false + ninja -C out.gn/arm64.release v8_monolith + + - name: Setup JDK 11 + uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: 11 + + - name: Setup Cmake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.23.x' - name: Javet Android + - name: Build Javet JNI + run: | + cd ${{ env.ROOT }}/Javet/cpp + sh ./build-android.sh -DV8_DIR=${{ env.ROOT }}/google/v8 -DCMAKE_ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }} -DCMAKE_ANDROID_ARCH=arm64 + + - name: Upload the Artifact + uses: actions/upload-artifact@v3 + with: + name: javet-linux-v8-arm64-${{ env.JAVET_VERSION }} + path: android/javet-android/src/main/jniLibs/arm64-v8a/*.so + + build_javet_x86: + name: Build Javet x86 runs-on: ubuntu-latest steps: @@ -23,14 +165,216 @@ jobs: - name: Checkout the code uses: actions/checkout@v3 - - name: Build docker image - run: docker build -t javet-android:local -f docker/android/build.Dockerfile . + - name: Setup Ubuntu + run: | + sudo apt-get install -y execstack gcc-multilib + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Setup Android NDK + id: setup-ndk + uses: nttld/setup-ndk@v1 + with: + ndk-version: r25b + local-cache: true + + - name: Setup Path + run: | + echo "${{ env.ROOT }}/google/depot_tools" >> $GITHUB_PATH + + - name: Build V8 + run: | + cd ${{ env.ROOT }} + mkdir google + cd google + git clone --depth=10 --branch=main https://chromium.googlesource.com/chromium/tools/depot_tools.git + cd depot_tools + git checkout remotes/origin/main + cd .. + fetch v8 + cd v8 + git checkout ${{ env.JAVET_V8_VERSION }} + ./build/install-build-deps.sh + cd .. + echo 'target_os = ["android"]' >> .gclient + gclient sync -D + cd v8 + python3 tools/dev/v8gen.py ia32.release -- 'target_os="android"' 'target_cpu="x86"' 'v8_target_cpu="x86"' v8_monolithic=true v8_use_external_startup_data=false is_component_build=false v8_enable_i18n_support=false v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false v8_enable_sandbox=false + ninja -C out.gn/ia32.release v8_monolith + + - name: Setup JDK 11 + uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: 11 + + - name: Setup Cmake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.23.x' + + - name: Build Javet JNI + run: | + cd ${{ env.ROOT }}/Javet/cpp + sh ./build-android.sh -DV8_DIR=${{ env.ROOT }}/google/v8 -DCMAKE_ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }} -DCMAKE_ANDROID_ARCH=x86 + + - name: Upload the Artifact + uses: actions/upload-artifact@v3 + with: + name: javet-linux-v8-x86-${{ env.JAVET_VERSION }} + path: android/javet-android/src/main/jniLibs/x86/*.so + + build_javet_x86_64: + name: Build Javet x86_64 + runs-on: ubuntu-latest + + steps: + + - name: Checkout the code + uses: actions/checkout@v3 + + - name: Setup Ubuntu + run: | + sudo apt-get install -y execstack gcc-multilib + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Setup Android NDK + id: setup-ndk + uses: nttld/setup-ndk@v1 + with: + ndk-version: r25b + local-cache: true + + - name: Setup Path + run: | + echo "${{ env.ROOT }}/google/depot_tools" >> $GITHUB_PATH + + - name: Build V8 + run: | + cd ${{ env.ROOT }} + mkdir google + cd google + git clone --depth=10 --branch=main https://chromium.googlesource.com/chromium/tools/depot_tools.git + cd depot_tools + git checkout remotes/origin/main + cd .. + fetch v8 + cd v8 + git checkout ${{ env.JAVET_V8_VERSION }} + ./build/install-build-deps.sh + cd .. + echo 'target_os = ["android"]' >> .gclient + gclient sync -D + cd v8 + python3 tools/dev/v8gen.py x64.release -- 'target_os="android"' 'target_cpu="x64"' 'v8_target_cpu="x64"' v8_monolithic=true v8_use_external_startup_data=false is_component_build=false v8_enable_i18n_support=false v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false v8_enable_sandbox=false + ninja -C out.gn/x64.release v8_monolith + + - name: Setup JDK 11 + uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: 11 + + - name: Setup Cmake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.23.x' + + - name: Build Javet JNI + run: | + cd ${{ env.ROOT }}/Javet/cpp + sh ./build-android.sh -DV8_DIR=${{ env.ROOT }}/google/v8 -DCMAKE_ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }} -DCMAKE_ANDROID_ARCH=x86_64 + + - name: Upload the Artifact + uses: actions/upload-artifact@v3 + with: + name: javet-linux-v8-x86_64-${{ env.JAVET_VERSION }} + path: android/javet-android/src/main/jniLibs/x86_64/*.so + + build_javet_aar: + needs: [build_javet_arm, build_javet_arm64, build_javet_x86, build_javet_x86_64] + name: Build Javet Jar + runs-on: ubuntu-latest + + steps: + + - name: Checkout the code + uses: actions/checkout@v3 + + - name: Setup JDK 11 + uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: 11 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + with: + gradle-version: 8.1 + + - name: Prepare JNI Libs + run: | + mkdir -p android/javet-android/src/main/jniLibs/armeabi-v7a + mkdir -p android/javet-android/src/main/jniLibs/arm64-v8a + mkdir -p android/javet-android/src/main/jniLibs/x86 + mkdir -p android/javet-android/src/main/jniLibs/x86_64 + + - name: Download Javet arm + uses: actions/download-artifact@v3 + with: + name: javet-linux-v8-arm-${{ env.JAVET_VERSION }} + path: android/javet-android/src/main/jniLibs/armeabi-v7a + + - name: Download Javet arm64 + uses: actions/download-artifact@v3 + with: + name: javet-linux-v8-arm64-${{ env.JAVET_VERSION }} + path: android/javet-android/src/main/jniLibs/arm64-v8a + + - name: Download Javet x86 + uses: actions/download-artifact@v3 + with: + name: javet-linux-v8-x86-${{ env.JAVET_VERSION }} + path: android/javet-android/src/main/jniLibs/x86 + + - name: Download Javet x86_64 + uses: actions/download-artifact@v3 + with: + name: javet-linux-v8-x86_64-${{ env.JAVET_VERSION }} + path: android/javet-android/src/main/jniLibs/x86_64 + + - name: Build the Artifact + run: | + cd ${{ env.ROOT }}/Javet/scripts/python + python3 patch_android_build.py + cd ${{ env.ROOT }}/Javet/android + gradle build --debug + + - name: Upload the Artifact + uses: actions/upload-artifact@v3 + with: + name: javet-android-${{ env.JAVET_VERSION }} + path: android/javet-android/build/outputs/aar/javet*release.aar + + - name: Delete Javet Anroid + uses: geekyeggo/delete-artifact@v2 + with: + name: javet-android-arm-${{ env.JAVET_VERSION }} - - name: Copy the artifact - run: mkdir $PWD/build && docker run --rm -i -v $PWD/build:/output javet-android:local cp -rf /Javet/android/javet-android/build/outputs /output - - name: Upload the artifact - uses: actions/upload-artifact@v2 + - name: Delete Javet Anroid + uses: geekyeggo/delete-artifact@v2 with: - name: javet-android - path: build/outputs/aar/javet*release.aar + name: javet-android-arm64-${{ env.JAVET_VERSION }} diff --git a/.github/workflows/linux_build.yml b/.github/workflows/linux_build.yml index 36115604e..517adf2ec 100644 --- a/.github/workflows/linux_build.yml +++ b/.github/workflows/linux_build.yml @@ -5,15 +5,6 @@ concurrency: cancel-in-progress: true on: workflow_dispatch: - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - paths-ignore: - - "**.rst" - - "docs/**" - push: - paths-ignore: - - "**.rst" - - "docs/**" env: JAVET_NODE_VERSION: 18.17.1 diff --git a/scripts/python/change_javet_version.py b/scripts/python/change_javet_version.py index 423d79096..f3885ff25 100644 --- a/scripts/python/change_javet_version.py +++ b/scripts/python/change_javet_version.py @@ -40,6 +40,9 @@ def update(self): self._update( 'build.gradle.kts', '\n', re.compile(r'^version = "(?P\d+\.\d+\.\d+)"$')) + self._update( + '.github/workflows/android_build.yml', '\n', + re.compile(r'JAVET_VERSION: (?P\d+\.\d+\.\d+)')) self._update( '.github/workflows/linux_build.yml', '\n', re.compile(r'JAVET_VERSION: (?P\d+\.\d+\.\d+)')) diff --git a/scripts/python/change_node_v8_version.py b/scripts/python/change_node_v8_version.py index 3c8da93de..b71dca393 100644 --- a/scripts/python/change_node_v8_version.py +++ b/scripts/python/change_node_v8_version.py @@ -74,6 +74,9 @@ def update(self) -> None: self._update( 'README.rst', '\n', re.compile(r'Node\.js ``v(?P\d+\.\d+\.\d+)``')) + self._update( + '.github/workflows/android_build.yml', '\n', + re.compile(r'JAVET_NODE_VERSION: (?P\d+\.\d+\.\d+)$')) self._update( '.github/workflows/linux_build.yml', '\n', re.compile(r'JAVET_NODE_VERSION: (?P\d+\.\d+\.\d+)$')) @@ -109,6 +112,9 @@ def update(self) -> None: self._update( 'README.rst', '\n', re.compile(r'V8 ``v(?P\d+\.\d+\.\d+\.\d+)``')) + self._update( + '.github/workflows/android_build.yml', '\n', + re.compile(r'JAVET_V8_VERSION: (?P\d+\.\d+\.\d+\.\d+)$')) self._update( '.github/workflows/linux_build.yml', '\n', re.compile(r'JAVET_V8_VERSION: (?P\d+\.\d+\.\d+\.\d+)$'))