Skip to content

Commit

Permalink
Add Workflow for Windows (caoccao#392)
Browse files Browse the repository at this point in the history
* Add workflow for Windows x86_64
* Add badge to README
  • Loading branch information
caoccao authored Sep 11, 2024
1 parent 08f430e commit 0a44e1b
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 3 deletions.
211 changes: 211 additions & 0 deletions .github/workflows/windows_x86_64_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
name: Windows x86_64 Build

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

env:
JAVET_NODE_VERSION: 20.17.0
JAVET_V8_VERSION: 12.8.374.17
JAVET_VERSION: 3.1.7
ROOT: D:\a\Javet

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

steps:

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout the code
uses: actions/checkout@v4

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

- name: Setup Path
run: |
echo "${{ env.ROOT }}\google\depot_tools" >> $GITHUB_PATH
- name: Build V8
env:
DEPOT_TOOLS_WIN_TOOLCHAIN: 0
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 ..
.\depot_tools\fetch.bat v8
cd v8
git checkout ${{ env.JAVET_V8_VERSION }}
cd ..
.\depot_tools\gclient.bat 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
..\depot_tools\gn.bat gen out.gn/x64.release
python3 ${{ env.ROOT }}\Javet\scripts\python\patch_v8_build.py -p .\
..\depot_tools\ninja.bat -C out.gn/x64.release v8_monolith
- name: Setup JDK 8
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 8

- name: Setup Cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.23.x'

- name: Patch V8
shell: bash
run: |
cd ../google/v8
sed -i '/static_assert(alignof(Type) <= alignof(decltype(/d' src/objects/tagged-field.h
- name: Build Javet JNI
run: |
cd ${{ env.ROOT }}\Javet\cpp
.\build-windows.cmd -DV8_DIR=${{ env.ROOT }}\google\v8
- name: Upload the Artifact
uses: actions/upload-artifact@v4
with:
name: javet-windows-v8-x86_64-${{ env.JAVET_VERSION }}
path: src\main\resources\*.dll

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

steps:

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout the code
uses: actions/checkout@v4

- name: Install NASM
run: choco install nasm

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

- 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 }}
.\vcbuild.bat static without-intl vs2022
- name: Setup JDK 8
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 8

- name: Setup Cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.23.x'

- name: Build Javet JNI
run: |
cd ${{ env.ROOT }}/Javet/cpp
.\build-windows.cmd -DNODE_DIR=${{ env.ROOT }}\node
- name: Upload the Artifact
uses: actions/upload-artifact@v4
with:
name: javet-windows-node-x86_64-${{ env.JAVET_VERSION }}
path: src\main\resources\*.dll

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

steps:

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout the code
uses: actions/checkout@v4

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

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.5

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

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

- name: Build the Artifact
shell: bash
run: |
touch src/main/resources/libjavet-v8*
gradle build test --rerun-tasks --debug
touch src/main/resources/libjavet-node*
gradle test --rerun-tasks --debug
gradle build generatePomFileForGeneratePomPublication
- name: Install 7zip
run: choco install 7zip.install

- name: Clear up Source Jar
run: |
7z d build\libs\javet-${{ env.JAVET_VERSION }}-sources.jar *.dll
- name: Upload the Artifact
uses: actions/upload-artifact@v4
with:
name: javet-windows-x86_64-${{ env.JAVET_VERSION }}
path: |
build\libs\*.jar
build\libs\*.pom
- name: Delete Javet V8
uses: geekyeggo/delete-artifact@v4
with:
name: javet-windows-v8-x86_64-${{ env.JAVET_VERSION }}

- name: Delete Javet Node
uses: geekyeggo/delete-artifact@v4
with:
name: javet-windows-node-x86_64-${{ env.JAVET_VERSION }}
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Javet

|Maven Central| |Discord| |Donate|

|Linux x86_64 Build| |MacOS x86_64 Build| |MacOS arm64 Build| |Android Node Build| |Android V8 Build|
|Linux x86_64 Build| |MacOS x86_64 Build| |MacOS arm64 Build| |Windows x86_64 Build| |Android Node Build| |Android V8 Build|

.. |Maven Central| image:: https://img.shields.io/maven-central/v/com.caoccao.javet/javet?style=for-the-badge
:target: https://central.sonatype.com/search?q=g:com.caoccao.javet
Expand All @@ -23,6 +23,9 @@ Javet
.. |MacOS arm64 Build| image:: https://github.com/caoccao/Javet/actions/workflows/macos_arm64_build.yml/badge.svg
:target: https://github.com/caoccao/Javet/actions/workflows/macos_arm64_build.yml

.. |Windows x86_64 Build| image:: https://github.com/caoccao/Javet/actions/workflows/windows_x86_64_build.yml/badge.svg
:target: https://github.com/caoccao/Javet/actions/workflows/windows_x86_64_build.yml

.. |Android Node Build| image:: https://github.com/caoccao/Javet/actions/workflows/android_node_build.yml/badge.svg
:target: https://github.com/caoccao/Javet/actions/workflows/android_node_build.yml

Expand All @@ -48,7 +51,7 @@ arm64 ✔️ ✔️ ✔️ ❌
=========== ======= ======= ======= =======

* Node.js ``v20.17.0`` + V8 ``v12.8.374.17``
* Dynamic switch between Node.js and V8 mode (`Which mode do you prefer? <https://github.com/caoccao/Javet/discussions/92>`_)
* Dynamic switch between Node.js and V8 mode
* Polyfill V8 mode with `Javenode <https://github.com/caoccao/Javenode>`_
* V8 API exposure in JVM
* JavaScript and Java interop
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. include:: ../README.rst
:start-line: 0
:end-line: 154
:end-line: 157

.. toctree::
:maxdepth: 2
Expand Down
3 changes: 3 additions & 0 deletions scripts/python/change_javet_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def update(self):
self._update(
'.github/workflows/macos_x86_64_build.yml', '\n',
re.compile(r'JAVET_VERSION: (?P<version>\d+\.\d+\.\d+)'))
self._update(
'.github/workflows/windows_x86_64_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 @@ -92,6 +92,9 @@ def update(self) -> None:
self._update(
'.github/workflows/macos_x86_64_build.yml', '\n',
re.compile(r'JAVET_NODE_VERSION: (?P<version>\d+\.\d+\.\d+)$'))
self._update(
'.github/workflows/windows_x86_64_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 @@ -136,6 +139,9 @@ def update(self) -> None:
self._update(
'.github/workflows/macos_x86_64_build.yml', '\n',
re.compile(r'JAVET_V8_VERSION: (?P<version>\d+\.\d+\.\d+\.\d+)$'))
self._update(
'.github/workflows/windows_x86_64_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 0a44e1b

Please sign in to comment.