Skip to content

Commit

Permalink
Add workflow for MacOS x86_64 (#248)
Browse files Browse the repository at this point in the history
* Add 3 jobs
   * Build V8
      * Clone
      * Build
      * Upload
   * Build Node
      * Clone
      * Build
      * Upload
   * Build Javet
      * Download
      * Build
      * Upload
  • Loading branch information
caoccao authored Jun 29, 2023
1 parent 44401b4 commit a7e30b7
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:

- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Build docker image
run: docker build -t javet-android:local -f docker/android/build.Dockerfile .
Expand Down
180 changes: 180 additions & 0 deletions .github/workflows/macos_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
name: MacOS x86_64 Build

concurrency:
group: macos_x86_64_build_${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:

env:
JAVET_NODE_VERSION: 18.16.1
JAVET_V8_VERSION: 11.5.150.12
JAVET_VERSION: 2.2.1
ROOT: /Users/runner/work/Javet

jobs:
build_javet_v8:
name: Build Javet V8
runs-on: macos-latest

steps:

- name: Checkout the code
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Setup XCode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- 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 }}
cd ..
gclient sync -D
cd v8
python3 tools/dev/v8gen.py x64.release -- 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
gn gen out.gn/x64.release
ninja -C out.gn/x64.release v8_monolith
- name: Setup JDK 8
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8

- 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-macos.sh -DV8_DIR=${{ env.ROOT }}/google/v8
- name: Upload the Artifact
uses: actions/upload-artifact@v3
with:
name: javet-macos-v8-x86_64-${{ env.JAVET_VERSION }}
path: src/main/resources/*.dylib

build_javet_node:
name: Build Javet Node
runs-on: macos-latest

steps:

- name: Checkout the code
uses: actions/checkout@v3

- name: Setup XCode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Build Node.js
run: |
cd ${{ env.ROOT }}
git clone https://github.com/nodejs/node.git
cd node
git checkout v${{ env.JAVET_NODE_VERSION }}
./configure --enable-static --without-intl
make -j4
- name: Setup JDK 8
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8

- 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-macos.sh -DNODE_DIR=${{ env.ROOT }}/node
- name: Upload the Artifact
uses: actions/upload-artifact@v3
with:
name: javet-macos-node-x86_64-${{ env.JAVET_VERSION }}
path: src/main/resources/*.dylib

build_javet_jar:
needs: [build_javet_v8, build_javet_node]
name: Build Javet Jar
runs-on: macos-latest

steps:

- name: Checkout the code
uses: actions/checkout@v3

- name: Setup JDK 8
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 8.1

- name: Download Javet V8
uses: actions/download-artifact@v3
with:
name: javet-macos-v8-x86_64-${{ env.JAVET_VERSION }}
path: src/main/resources/

- name: Download Javet Node
uses: actions/download-artifact@v3
with:
name: javet-macos-node-x86_64-${{ env.JAVET_VERSION }}
path: src/main/resources/

- name: Build the Artifact
run: |
cd ${{ env.ROOT }}/Javet
touch src/main/resources/libjavet-v8*
gradle build test --rerun-tasks --debug
touch src/main/resources/libjavet-node*
gradle test --rerun-tasks --debug
- name: Upload the Artifact
uses: actions/upload-artifact@v3
with:
name: javet-macos-x86_64-${{ env.JAVET_VERSION }}
path: build/libs/*.jar

- name: Delete Javet V8
uses: geekyeggo/delete-artifact@v2
with:
name: javet-macos-v8-x86_64-${{ env.JAVET_VERSION }}

- name: Delete Javet Node
uses: geekyeggo/delete-artifact@v2
with:
name: javet-macos-node-x86_64-${{ env.JAVET_VERSION }}
3 changes: 3 additions & 0 deletions scripts/python/change_javet_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def update(self):
self._update(
'.github/workflows/linux_build_node_v8_image.yml', '\n',
re.compile(r'JAVET_VERSION: (?P<version>\d+\.\d+\.\d+)'))
self._update(
'.github/workflows/macos_build.yml', '\n',
re.compile(r'JAVET_VERSION: (?P<version>\d+\.\d+\.\d+)'))
self._update(
'docker/android/base.Dockerfile', '\n',
re.compile(r'javet-android:(?P<version>\d+\.\d+\.\d+) '))
Expand Down
6 changes: 6 additions & 0 deletions scripts/python/change_node_v8_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def update(self) -> None:
self._update(
'.github/workflows/linux_build_node_v8_image.yml', '\n',
re.compile(r'JAVET_NODE_VERSION: (?P<version>\d+\.\d+\.\d+)$'))
self._update(
'.github/workflows/macos_build.yml', '\n',
re.compile(r'JAVET_NODE_VERSION: (?P<version>\d+\.\d+\.\d+)$'))
self._update(
'docker/linux-x86_64/base_all_in_one.Dockerfile', '\n',
re.compile(r'JAVET_NODE_VERSION=(?P<version>\d+\.\d+\.\d+)$'))
Expand Down Expand Up @@ -109,6 +112,9 @@ def update(self) -> None:
self._update(
'.github/workflows/linux_build_node_v8_image.yml', '\n',
re.compile(r'JAVET_V8_VERSION: (?P<version>\d+\.\d+\.\d+\.\d+)$'))
self._update(
'.github/workflows/macos_build.yml', '\n',
re.compile(r'JAVET_V8_VERSION: (?P<version>\d+\.\d+\.\d+\.\d+)$'))
self._update(
'docker/android/base.Dockerfile', '\n',
re.compile(r'JAVET_V8_VERSION=(?P<version>\d+\.\d+\.\d+\.\d+)$'))
Expand Down

0 comments on commit a7e30b7

Please sign in to comment.