-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (75 loc) · 3.06 KB
/
build.yml
File metadata and controls
81 lines (75 loc) · 3.06 KB
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
name: Build Webify
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
ZIG_TARGET: ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
target: [aarch64-windows-gnu, aarch64-linux-musl, aarch64-macos-none, x86_64-windows-gnu, x86_64-linux-musl, x86_64-macos-none, arm-linux-musleabihf, x86-windows-gnu, x86-linux-musl]
steps:
- name: Checkout
uses: actions/checkout@main
with:
path: ${{ github.workspace }}
submodules: true
- name: Setup Zig
uses: mlugg/setup-zig@main
with:
version: "0.17.0-dev.304+9787df942"
use-cache: false
- name: Setup Zig Toolchain
shell: bash
run: git clone https://github.com/HomuHomu833/zig-as-llvm ${{ github.workspace }}/zig-as-llvm
- name: Build Webify
shell: bash
run: |
TOOLCHAIN=${{ github.workspace }}/zig-as-llvm
ARCH="${ZIG_TARGET%%-*}"
REST="${ZIG_TARGET#*-}"
OS="${REST%%-*}"
case "$OS" in
linux) CMAKE_SYSTEM_NAME="Linux" ;;
windows) CMAKE_SYSTEM_NAME="Windows" ;;
macos) CMAKE_SYSTEM_NAME="Darwin" ;;
*) CMAKE_SYSTEM_NAME="Generic" ;;
esac
case "$ARCH" in
x86_64) CMAKE_SYSTEM_PROCESSOR="x86_64" ;;
x86) CMAKE_SYSTEM_PROCESSOR="i686" ;;
aarch64) CMAKE_SYSTEM_PROCESSOR="aarch64" ;;
arm) CMAKE_SYSTEM_PROCESSOR="arm" ;;
*) CMAKE_SYSTEM_PROCESSOR="$ARCH" ;;
esac
if echo 'int main(){}' | "${TOOLCHAIN}/bin/cc" -x c - -static -o /dev/null 2>/dev/null; then
STATIC_FLAG="-static"
fi
JOBS=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo "${NUMBER_OF_PROCESSORS:-4}")
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_SYSTEM_NAME="${CMAKE_SYSTEM_NAME}" \
-DCMAKE_SYSTEM_PROCESSOR="${CMAKE_SYSTEM_PROCESSOR}" \
-DCMAKE_CROSSCOMPILING=TRUE \
-DCMAKE_C_FLAGS="${STATIC_FLAG} -D_LARGEFILE64_SOURCE=1" \
-DCMAKE_CXX_FLAGS="${STATIC_FLAG} -D_LARGEFILE64_SOURCE=1" \
-DCMAKE_EXE_LINKER_FLAGS="${STATIC_FLAG}" \
-DCMAKE_C_COMPILER="${TOOLCHAIN}/bin/cc" \
-DCMAKE_CXX_COMPILER="${TOOLCHAIN}/bin/c++" \
-DCMAKE_ASM_COMPILER="${TOOLCHAIN}/bin/cc" \
-DCMAKE_LINKER="${TOOLCHAIN}/bin/ld" \
-DCMAKE_OBJCOPY="${TOOLCHAIN}/bin/objcopy" \
-DCMAKE_AR="${TOOLCHAIN}/bin/ar" \
-DCMAKE_RANLIB="${TOOLCHAIN}/bin/ranlib" \
-DCMAKE_STRIP="${TOOLCHAIN}/bin/strip" \
-DCMAKE_RC_COMPILER="${TOOLCHAIN}/bin/rc"
cmake --build . --config MinSizeRel -j"${JOBS}"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: webify-${{ matrix.target }}
path: build/webify*
if-no-files-found: error