-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (114 loc) · 5.33 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Build
on:
push:
tags: ['**']
jobs:
build:
name: ${{ matrix.config.target }}
runs-on: ubuntu-22.04
timeout-minutes: 180
strategy:
matrix:
config:
- target: x86_64-unknown-linux-gnu
variant: release
- target: aarch64-linux-android
variant: release
env:
V8_FROM_SOURCE: 1
CARGO_VARIANT_FLAG: ${{ matrix.config.variant == 'release' && '--release' || '' }}
LIB_NAME: librusty_v8
LIB_EXT: a
RUSTFLAGS: -D warnings
steps:
- name: Get version
id: get_version
run: |
version=${GITHUB_REF#refs/tags/}
echo "version=$version" >> $GITHUB_OUTPUT
- name: Checkout rusty_v8
uses: actions/checkout@v4
with:
repository: denoland/rusty_v8
ref: ${{ steps.get_version.outputs.version }}
fetch-depth: 10
submodules: recursive
- name: Checkout rusty_v8_builder
uses: actions/checkout@v4
with:
path: rusty_v8_builder
- name: Check patch available
id: check_patch_available
run: |
if [ -f "rusty_v8_builder/patches/${{ steps.get_version.outputs.version }}.patch" ]; then
echo "Patch ${{ steps.get_version.outputs.version }}.patch available"
echo "patch_available=true" >> $GITHUB_OUTPUT
else
echo "Patch ${{ steps.get_version.outputs.version }}.patch not found"
echo "patch_available=false" >> $GITHUB_OUTPUT
fi
- name: Apply patch
if: steps.check_patch_available.outputs.patch_available == 'true'
run: |
git apply rusty_v8_builder/patches/${{ steps.get_version.outputs.version }}.patch
- name: Install rust
uses: dsherret/rust-toolchain-file@v1
- name: Install python
uses: actions/setup-python@v4
with:
python-version: 3.11.x
architecture: x64
- name: Install cross compilation toolchain
if: matrix.config.target == 'aarch64-linux-android'
run: |
rustup target add aarch64-linux-android
- name: Write git_submodule_status.txt
run: git submodule status --recursive > git_submodule_status.txt
- name: Cache
uses: actions/cache@v3
with:
path: |-
target/sccache
target/*/.*
target/*/build
target/*/deps
key: cargo-${{ matrix.config.target }}-${{ matrix.config.variant }}-${{ hashFiles('Cargo.lock', 'build.rs', 'git_submodule_status.txt') }}
restore-keys: cargo-${{ matrix.config.target }}-${{ matrix.config.variant }}-
- name: Sccache
shell: pwsh
env:
SCCACHE_DIR: ${{ github.workspace }}/target/sccache
SCCACHE_CACHE_SIZE: 128M
SCCACHE_IDLE_TIMEOUT: 0
run: |
$version = "0.2.12"
$platform =
@{ "macOS" = "x86_64-apple-darwin"
"Linux" = "x86_64-unknown-linux-musl"
"Windows" = "x86_64-pc-windows-msvc"
}.${{ runner.os }}
$basename = "sccache-$version-$platform"
$url = "https://github.com/mozilla/sccache/releases/download/" +
"$version/$basename.tar.gz"
cd ~
curl -LO $url
tar -xzvf "$basename.tar.gz"
. $basename/sccache --start-server
echo "$(pwd)/$basename" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Build
env:
BINDGEN_EXTRA_CLANG_ARGS_aarch64_linux_android: '--sysroot=${{ github.workspace }}/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot'
DEP_Z_INCLUDE: '${{ github.workspace }}/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include'
run: |
find . -name "sysroot"
cargo build -vv --locked ${{ env.CARGO_VARIANT_FLAG }} --target ${{ matrix.config.target }}
- name: Prepare Release
run: gzip -9c
target/${{ matrix.config.target }}/${{ matrix.config.variant }}/gn_out/obj/${{ env.LIB_NAME }}.${{ env.LIB_EXT }} >
target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz &&
ls -l target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz