From 82f8a63c7401f9d6aee7233fcd5aa41688cbc39e Mon Sep 17 00:00:00 2001 From: Elmi Ahmadov Date: Wed, 13 Nov 2019 23:45:29 +0100 Subject: [PATCH 1/3] Fix build Switch to V8 7.4.288 branch before executing the command `gclient sync` --- .github/workflows/main.yml | 35 ++++++++++++++++++++++++----------- v8/Dockerfile | 5 ++++- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7a2fab726..690ce0460 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,12 +24,14 @@ jobs: echo $PATH fetch v8 + cd v8 + git checkout 7.4.288 + cd ../ + echo "target_os= ['linux']">>.gclient gclient sync cd v8 - - git checkout 7.4.288 ./tools/dev/v8gen.py x64.release -vv rm out.gn/x64.release/args.gn @@ -76,12 +78,14 @@ jobs: echo $PATH fetch v8 + cd v8 + git checkout 7.4.288 + cd ../ + echo "target_os= ['android']">>.gclient gclient sync cd v8 - - git checkout 7.4.288 ./tools/dev/v8gen.py arm64.release -vv rm out.gn/arm64.release/args.gn @@ -129,12 +133,14 @@ jobs: echo $PATH fetch v8 + cd v8 + git checkout 7.4.288 + cd ../ + echo "target_os= ['android']">>.gclient gclient sync cd v8 - - git checkout 7.4.288 ./tools/dev/v8gen.py arm.release -vv rm out.gn/arm.release/args.gn @@ -175,12 +181,14 @@ jobs: echo $PATH fetch v8 + cd v8 + git checkout 7.4.288 + cd ../ + echo "target_os= ['android']">>.gclient gclient sync cd v8 - - git checkout 7.4.288 ./tools/dev/v8gen.py x64.release -vv rm out.gn/x64.release/args.gn @@ -221,12 +229,14 @@ jobs: echo $PATH fetch v8 + cd v8 + git checkout 7.4.288 + cd ../ + echo "target_os= ['android']">>.gclient gclient sync cd v8 - - git checkout 7.4.288 ./tools/dev/v8gen.py ia32.release -vv rm out.gn/ia32.release/args.gn @@ -312,8 +322,11 @@ jobs: python build.py -t android -a arm --docker --keep-native-libs j2v8cmake j2v8jni j2v8cpp j2v8optimize j2v8java python build.py -t android -a x86_64 --docker --keep-native-libs j2v8cmake j2v8jni j2v8cpp j2v8optimize j2v8java python build.py -t android -a arm64 --docker --keep-native-libs j2v8cmake j2v8jni j2v8cpp j2v8optimize j2v8java - python build.py -t android -a arm64 j2v8release --keep-native-libs --docker + - name: Release + if: github.ref == 'refs/heads/master' + run: python build.py -t android -a arm64 j2v8release --keep-native-libs --docker + - name: Archive J2V8 Android aar file uses: actions/upload-artifact@v1.0.0 with: diff --git a/v8/Dockerfile b/v8/Dockerfile index 0cbebac38..56e2a21c6 100644 --- a/v8/Dockerfile +++ b/v8/Dockerfile @@ -40,6 +40,10 @@ RUN echo ${path_to_args} # Fetch V8 code RUN fetch v8 +WORKDIR /v8build/v8 +RUN git checkout 7.4.288 +WORKDIR /v8build + RUN echo "target_os= ['${target_os}']">>.gclient RUN gclient sync @@ -49,7 +53,6 @@ RUN echo y | \ ./build/install-build-deps-android.sh ; \ else \ ./build/install-build-deps.sh ; fi -RUN git checkout 7.4.288 RUN ./tools/dev/v8gen.py ${build_platform} -vv From faa5fa7ea95a921c1662d4ea93e7ac884b3461dd Mon Sep 17 00:00:00 2001 From: Elmi Ahmadov Date: Thu, 14 Nov 2019 14:57:38 +0100 Subject: [PATCH 2/3] Use prebuilt V8 monolithic static libraries to build J2V8 --- .github/workflows/main.yml | 314 ++----------------------------------- 1 file changed, 13 insertions(+), 301 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 690ce0460..bffc8b7db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,294 +3,15 @@ name: Build J2V8 on: [push] jobs: - build_j2v8_linux_x86_64: - name: V8 7.4.288 build for Linux x64 - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: check build dependencies - run: | - python --version - git --version - docker --version - - - name: Build J2V8 for Linux x86_64 - run: | - mkdir -p v8build - cd v8build - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git - export PATH=$GITHUB_WORKSPACE/v8build/depot_tools:"$PATH" - echo $PATH - - fetch v8 - cd v8 - git checkout 7.4.288 - cd ../ - - echo "target_os= ['linux']">>.gclient - gclient sync - - cd v8 - ./tools/dev/v8gen.py x64.release -vv - - rm out.gn/x64.release/args.gn - cp $GITHUB_WORKSPACE/v8/linux-x64/args.gn out.gn/x64.release/args.gn - ls -al out.gn/x64.release/ - cat out.gn/x64.release/args.gn - sleep 1m - touch out.gn/x64.release/args.gn - ls -al out.gn/x64.release/ - - ninja -C out.gn/x64.release -t clean - ninja -C out.gn/x64.release v8_monolith - - mkdir -p $GITHUB_WORKSPACE/v8.out/linux.x64 - cp out.gn/x64.release/obj/libv8_monolith.a $GITHUB_WORKSPACE/v8.out/linux.x64 - - cd $GITHUB_WORKSPACE - cp -R v8build/v8/include v8.out/ - python build.py -t linux -a x64 --docker j2v8cmake j2v8jni j2v8cpp j2v8optimize j2v8java j2v8test - - name: Archive J2V8 jar - uses: actions/upload-artifact@v1.0.0 - with: - name: j2v8-linux-x86_64 - path: build.out/j2v8_linux_x86_64-6.0.0-SNAPSHOT.jar - - build_v8_android_arm64: - name: V8 7.4.288 build for Android arm64 - runs-on: ubuntu-16.04 - - steps: - - uses: actions/checkout@v1 - - name: check build dependencies - run: | - python --version - git --version - docker --version - - - name: Build V8 for Android arm64 - run: | - mkdir -p v8build - cd v8build - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git - export PATH=$GITHUB_WORKSPACE/v8build/depot_tools:"$PATH" - echo $PATH - - fetch v8 - cd v8 - git checkout 7.4.288 - cd ../ - - echo "target_os= ['android']">>.gclient - gclient sync - - cd v8 - ./tools/dev/v8gen.py arm64.release -vv - - rm out.gn/arm64.release/args.gn - cp $GITHUB_WORKSPACE/v8/android-arm64/args.gn out.gn/arm64.release/args.gn - ls -al out.gn/arm64.release/ - cat out.gn/arm64.release/args.gn - sleep 1m - touch out.gn/arm64.release/args.gn - ls -al out.gn/arm64.release/ - - ninja -C out.gn/arm64.release -t clean - ninja -C out.gn/arm64.release v8_monolith - - cd $GITHUB_WORKSPACE - zip -r v8_include.zip v8build/v8/include - - name: Archive V8 monolith - uses: actions/upload-artifact@v1.0.0 - with: - name: v8-android-arm64-monolith - path: v8build/v8/out.gn/arm64.release/obj/libv8_monolith.a - - name: Archive V8 header files - uses: actions/upload-artifact@v1.0.0 - with: - name: v8-header-files - path: v8_include.zip - - build_v8_android_arm: - name: V8 7.4.288 build for Android arm - runs-on: ubuntu-16.04 - - steps: - - uses: actions/checkout@v1 - - name: check build dependencies - run: | - python --version - git --version - docker --version - - - name: Build V8 for Android arm - run: | - mkdir -p v8build - cd v8build - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git - export PATH=$GITHUB_WORKSPACE/v8build/depot_tools:"$PATH" - echo $PATH - - fetch v8 - cd v8 - git checkout 7.4.288 - cd ../ - - echo "target_os= ['android']">>.gclient - gclient sync - - cd v8 - ./tools/dev/v8gen.py arm.release -vv - - rm out.gn/arm.release/args.gn - cp $GITHUB_WORKSPACE/v8/android-arm/args.gn out.gn/arm.release/args.gn - ls -al out.gn/arm.release/ - cat out.gn/arm.release/args.gn - sleep 1m - touch out.gn/arm.release/args.gn - ls -al out.gn/arm.release/ - - ninja -C out.gn/arm.release -t clean - ninja -C out.gn/arm.release v8_monolith - - - name: Archive V8 monolith - uses: actions/upload-artifact@v1.0.0 - with: - name: v8-android-arm-monolith - path: v8build/v8/out.gn/arm.release/obj/libv8_monolith.a - - build_v8_android_x86_64: - name: V8 7.4.288 build for Android x86_64 - runs-on: ubuntu-16.04 - - steps: - - uses: actions/checkout@v1 - - name: check build dependencies - run: | - python --version - git --version - docker --version - - - name: Build V8 for Android x86_64 - run: | - mkdir -p v8build - cd v8build - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git - export PATH=$GITHUB_WORKSPACE/v8build/depot_tools:"$PATH" - echo $PATH - - fetch v8 - cd v8 - git checkout 7.4.288 - cd ../ - - echo "target_os= ['android']">>.gclient - gclient sync - - cd v8 - ./tools/dev/v8gen.py x64.release -vv - - rm out.gn/x64.release/args.gn - cp $GITHUB_WORKSPACE/v8/android-x64/args.gn out.gn/x64.release/args.gn - ls -al out.gn/x64.release/ - cat out.gn/x64.release/args.gn - sleep 1m - touch out.gn/x64.release/args.gn - ls -al out.gn/x64.release/ - - ninja -C out.gn/x64.release -t clean - ninja -C out.gn/x64.release v8_monolith - - - name: Archive V8 monolith - uses: actions/upload-artifact@v1.0.0 - with: - name: v8-android-x86_64-monolith - path: v8build/v8/out.gn/x64.release/obj/libv8_monolith.a - - build_v8_android_x86: - name: V8 7.4.288 build for Android x86 - runs-on: ubuntu-16.04 - - steps: - - uses: actions/checkout@v1 - - name: check build dependencies - run: | - python --version - git --version - docker --version - - - name: Build V8 for Android x86 - run: | - mkdir -p v8build - cd v8build - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git - export PATH=$GITHUB_WORKSPACE/v8build/depot_tools:"$PATH" - echo $PATH - - fetch v8 - cd v8 - git checkout 7.4.288 - cd ../ - - echo "target_os= ['android']">>.gclient - gclient sync - - cd v8 - ./tools/dev/v8gen.py ia32.release -vv - - rm out.gn/ia32.release/args.gn - cp $GITHUB_WORKSPACE/v8/android-ia32/args.gn out.gn/ia32.release/args.gn - ls -al out.gn/ia32.release/ - cat out.gn/ia32.release/args.gn - sleep 1m - touch out.gn/ia32.release/args.gn - ls -al out.gn/ia32.release/ - - ninja -C out.gn/ia32.release -t clean - ninja -C out.gn/ia32.release v8_monolith - - - name: Archive V8 monolith - uses: actions/upload-artifact@v1.0.0 - with: - name: v8-android-x86-monolith - path: v8build/v8/out.gn/ia32.release/obj/libv8_monolith.a - - generate_j2v8_aar: - name: Create J2V8 Android archive (aar) - needs: [build_v8_android_arm64, build_v8_android_arm, build_v8_android_x86_64, build_v8_android_x86] + generate_j2v8_archives: + name: Create J2V8 Linux jar and Android aar archive files runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v1 - - name: Download Android arm64 monolithic library - uses: actions/download-artifact@v1 - with: - name: v8-android-arm64-monolith - - - name: Download Android arm monolithic library - uses: actions/download-artifact@v1 - with: - name: v8-android-arm-monolith - - - name: Download Android x86_64 monolithic library - uses: actions/download-artifact@v1 - with: - name: v8-android-x86_64-monolith - - - name: Download Android x86 monolithic library - uses: actions/download-artifact@v1 - with: - name: v8-android-x86-monolith - - - name: Download V8 header files - uses: actions/download-artifact@v1 - with: - name: v8-header-files - - - name: Copy monolithic libraries to v8.out directory and bundle Android aar file + - name: Download monolithic libraries to v8.out directory and bundle Linux jar and Android aar file env: KEY_ID: ${{ secrets.KEY_ID }} KEYSTORE: ${{ secrets.KEYSTORE }} @@ -298,26 +19,12 @@ jobs: MAVEN_REPO_USER: ${{ secrets.MAVEN_REPO_USER }} MAVEN_REPO_PASS: ${{ secrets.MAVEN_REPO_PASS }} run: | - mkdir -p v8.out/android.arm64 - mkdir -p v8.out/android.arm - mkdir -p v8.out/android.x64 - mkdir -p v8.out/android.x86 - - cp -R v8-android-arm64-monolith/* v8.out/android.arm64 - cp -R v8-android-arm-monolith/* v8.out/android.arm - cp -R v8-android-x86_64-monolith/* v8.out/android.x64 - cp -R v8-android-x86-monolith/* v8.out/android.x86 - - unzip v8-header-files/v8_include.zip -d . - mv v8build/v8/include v8.out/ - - ls -la v8.out/ - ls -la v8.out/android.arm64 - ls -la v8.out/android.arm - ls -la v8.out/android.x64 - ls -la v8.out/android.x86 + curl -O https://download.eclipsesource.com/j2v8/v8/libv8_7.4.288_monolith.zip + mkdir -p v8.out + unzip libv8_7.4.288_monolith.zip -d v8.out # start j2v8 build + python build.py -t linux -a x64 --docker j2v8cmake j2v8jni j2v8cpp j2v8optimize j2v8java j2v8test python build.py -t android -a x86 --docker --keep-native-libs j2v8cmake j2v8jni j2v8cpp j2v8optimize j2v8java python build.py -t android -a arm --docker --keep-native-libs j2v8cmake j2v8jni j2v8cpp j2v8optimize j2v8java python build.py -t android -a x86_64 --docker --keep-native-libs j2v8cmake j2v8jni j2v8cpp j2v8optimize j2v8java @@ -331,4 +38,9 @@ jobs: uses: actions/upload-artifact@v1.0.0 with: name: j2v8-android-aar - path: build/outputs/aar/j2v8-release.aar \ No newline at end of file + path: build/outputs/aar/j2v8-release.aar + - name: Archive J2V8 Linux x86_64 jar + uses: actions/upload-artifact@v1.0.0 + with: + name: j2v8-linux-x86_64 + path: build.out/j2v8_linux_x86_64-6.0.0-SNAPSHOT.jar \ No newline at end of file From d26f6dddbe8934e08400c57c99f476c35d4d4266 Mon Sep 17 00:00:00 2001 From: Elmi Ahmadov Date: Tue, 26 Nov 2019 10:28:12 +0100 Subject: [PATCH 3/3] Update build guideline according for the J2V8 6.x --- BUILDING.md | 88 +++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 50 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index e6dff8696..7378db80e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -9,9 +9,8 @@ 1. clone the source code from the [J2V8 GitHub repository](https://github.com/eclipsesource/J2V8) 2. run `j2v8-cli.cmd` (on Win32) or `source j2v8-cli.sh` on MacOS / Linux -3. `nodejs git clone` to clone the Node.js/V8 source code -4. `nodejs diff apply` to apply the required modifications to the Node.js source code -5. start the desired J2V8 build either via `build -i` or `build ...args` (see below for details) +3. `run v8.sh` on MacOS / Linux +4. start the desired J2V8 build either via `build -i` or `build ...args` (see below for details) # Build-System CLI @@ -30,21 +29,18 @@ entering interactive mode... [0] android-x86 @ Docker [1] android-arm @ Docker -[2] alpine-linux-x64 @ Docker -[3] linux-x64 -[4] linux-x64 @ Docker -[5] linux-x86 @ Docker -[6] macosx-x64 -[7] macosx-x64 @ Vagrant -[8] macosx-x86 @ Vagrant -[9] windows-x64 -[10] windows-x64 @ Docker -[11] windows-x64 @ Vagrant - -Select a predefined build-configuration to run: 3 +[2] android-arm64 @ Docker +[3] android-x64 @ Docker +[4] alpine-linux-x64 @ Docker +[5] linux-x64 +[6] linux-x64 @ Docker +[7] macosx-x64 +[8] macosx-x64 @ Vagrant + +Select a predefined build-configuration to run: 5 Building: linux-x64 -Override build-steps ? (leave empty to run pre-configured steps): nodejs j2v8 test +Override build-steps ? (leave empty to run pre-configured steps): v8 j2v8 test ``` ## Non-interactive @@ -53,8 +49,8 @@ build -h, --help # or python build.py -h, --help -usage: build [-h] --target {android,linux,macos,win32} --arch {x86,x64,arm} - [--vendor VENDOR] [--keep-native-libs] [--node-enabled] +usage: build [-h] --target {android,linux,macos,win32} --arch {x86,x64,arm,arm64,x86_64} + [--vendor VENDOR] [--keep-native-libs] [--docker] [--vagrant] [--sys-image SYS_IMAGE] [--no-shutdown] [--redirect-stdout] [--interactive] [build-steps [build-steps ...]] @@ -62,20 +58,20 @@ usage: build [-h] --target {android,linux,macos,win32} --arch {x86,x64,arm} ### Basic Examples -Build for Debian/Ubuntu Linux x64 on the host-system:
-`build -t linux -a x64` +Pre build step:
+`chmod +x v8.sh && ./v8.sh` -Build for Debian/Ubuntu Linux x64 using Docker:
-`build -t linux -a x64 -dkr` +Build for Android arm64 using Docker:
+`python build.py -t android -a arm64 --docker --keep-native-libs j2v8` -Build for Alpine-Linux x64 using Docker and Node.js features included:
-`build -v alpine -t linux -a x64 -dkr -ne` +Build for Debian/Ubuntu Linux x64 on the host-system:
+`build -t linux -a x64 j2v8 test` -Build for MacOSX x64 using Vagrant excluding Node.js features:
-`build -t macos -a x64 -vgr` +Build for Debian/Ubuntu Linux x64 using Docker:
+`build -t linux -a x64 --docker j2v8 test` -Build for Windows x64 directly on the host-system, Node.js features included:
-`build -t win32 -a x64 -ne` +Build for MacOSX x64 on the host-system:
+`build -t macos -a x64 j2v8 test` ### Build-Step syntax @@ -86,8 +82,8 @@ For ease of use, there are also some advanced build-step aliases that when speci - `all` ... is the default, and will run all known build-steps - `native` ... will run only the build-steps that are relevant for building **native** artifacts - - `node_js`, `j2v8_cmake`, `j2v8_jni`, `j2v8_cpp`, `j2v8_optimize` -- `j2v8` ... runs all build-steps, except for `nodejs` and `j2v8test` + - `v8`, `j2v8_cmake`, `j2v8_jni`, `j2v8_cpp`, `j2v8_optimize` +- `j2v8` ... runs all build-steps, except for `v8` and `j2v8test` - `java` ... alias for the single `j2v8java` step - `test` ... alias for the single `j2v8test` step @@ -115,28 +111,21 @@ Run the `j2v8test` step with additional args that will be passed to maven:
The J2V8 build-system performs several build steps in a fixed order to produce the final J2V8 packages for usage on the designated target platforms. What follows is a short summary for what each of the executed build-steps does and what output artifacts are produced by each step. ``` -Node.js --> CMake --> JNI --> C++ --> Optimize --> Java/Android Build --> Java/Android Test +V8 --> CMake --> JNI --> C++ --> Optimize --> Java/Android Build --> Java/Android Test ``` --- -## Node.js -CLI name: `nodejs` +## V8 +CLI name: `v8` -Builds the [Node.js](https://nodejs.org/en/) & [V8](https://developers.google.com/v8/) dependency artifacts that are later linked into the J2V8 native bridge code. -(only works if the Node.js source was checked out into the J2V8 `./node` directory) +Build the [V8](https://developers.google.com/v8/) dependency artifacts that are later linked into the J2V8 native bridge code. __Inputs:__ -- Node.js source code - - see [Github](https://github.com/nodejs/node) -- Node.js GIT patches with customizations for integrating Node.js into J2V8 - - `./node.patches/*.diff` +- V8 source code + - see [Github](https://chromium.googlesource.com/v8/v8) __Artifacts:__ -- Node.js & V8 static link libraries - - `./node/out/` - - *win32 specific* - - `./node/build/` - - `./node/Debug/` - - `./node/Release/` +- V8 monolithic static link library + - `./v8/out.gn/.release/obj/libv8_monolith.a` --- ## CMake CLI name: `j2v8cmake` @@ -144,8 +133,7 @@ CLI name: `j2v8cmake` Uses [CMake](https://cmake.org/) to generate the native Makefiles / IDE project files to later build the J2V8 C++ native bridge shared libraries. __Inputs__: -- Node.js / V8 static link libraries - - `./cmake/NodeJsUtils.cmake` +- V8 monolithic static link library - CMakeLists & CMake utilities - `CMakeLists.txt` - `./cmake/*.cmake` @@ -170,11 +158,11 @@ __Artifacts:__ ## C++ CLI name: `j2v8cpp` -Compile and link the J2V8 native shared libraries (.so/.dylib/.dll), which contain the C++ JNI bridge code to interop with the embedded Node.js / V8 parts. +Compile and link the J2V8 native shared libraries (.so/.dylib/.dll), which contain the C++ JNI bridge code to interop with the embedded V8 parts. __Inputs__: - CMake generated Makefiles / IDE Project-files -- Node.js / V8 static link libraries & C++ header files +- V8 monolithic static link library & C++ header files - J2V8 C++ JNI source code - `./jni/com_eclipsesource_v8_V8Impl.h` - `./jni/com_eclipsesource_v8_V8Impl.cpp` @@ -247,7 +235,7 @@ __Artifacts:__ # Cross-Compiling For cross-compiling J2V8 uses [Docker](https://www.docker.com/) (android, linux, windows) and [Vagrant](https://www.vagrantup.com/) (macos, windows). -The full source-code (of both J2V8 and Node.js) on the build-host are just shared via mounted volumes with the Docker / Vagrant machines, so you can quickly make changes and perform builds fast. +The full source-code (of both J2V8 and V8) on the build-host are just shared via mounted volumes with the Docker / Vagrant machines, so you can quickly make changes and perform builds fast. To invoke a cross-compile build, simply invoke the `build.py` script as usual but add the `--docker`, `-dkr` or `--vagrant`, `-vgr` flags. This will automatically provision and run the necessary virtualization to run the requested build fully independent of your local environment.