forked from WasmEdge/WasmEdge
-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (94 loc) · 4.12 KB
/
reusable-build-on-macos.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
name: Build on MacOS
on:
workflow_call:
inputs:
version:
type: string
required: true
matrix: # [ { name, runner, darwin_version }, ... ]
type: string
required: true
release:
type: boolean
jobs:
build_on_macos:
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(inputs.matrix) }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
env:
BUILD_TESTS: ON
BUILD_TYPE: Debug
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Ensure git safe directory
run: |
git config --global --add safe.directory $(pwd)
- name: Setup build environment
run: |
eval $(/opt/homebrew/bin/brew shellenv)
brew install llvm@16 ninja cmake wabt
- name: Set environment variables for release
if: ${{ inputs.release }}
run: |
echo "BUILD_TESTS=OFF" | tee -a $GITHUB_ENV
echo "BUILD_TYPE=Release" | tee -a $GITHUB_ENV
- name: Build WasmEdge
run: |
eval $(/opt/homebrew/bin/brew shellenv)
export LLVM_DIR="$(brew --prefix)/opt/llvm@16/lib/cmake"
export CC=clang
export CXX=clang++
rm -rf build output
mkdir -p output
cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWASMEDGE_BUILD_TESTS=$BUILD_TESTS -DWASMEDGE_LINK_LLVM_STATIC=ON -DWASMEDGE_BUILD_PACKAGE="TGZ" -DCMAKE_INSTALL_PREFIX:PATH=$GITHUB_WORKSPACE/output .
cmake --build build
- name: Test WasmEdge
run: |
eval $(/opt/homebrew/bin/brew shellenv)
export DYLD_LIBRARY_PATH="$(pwd)/build/lib/api:$DYLD_LIBRARY_PATH"
cd build
ctest
- name: Create package tarball
run: |
eval $(/opt/homebrew/bin/brew shellenv)
cmake --build build --target package
- name: Test Standalone WasmEdge without LLVM
run: |
eval $(/opt/homebrew/bin/brew shellenv)
export DYLD_LIBRARY_PATH="$(pwd)/build/lib/api:$DYLD_LIBRARY_PATH"
echo "otool -L ./build/tools/wasmedge/wasmedge:"
otool -L ./build/tools/wasmedge/wasmedge
echo "otool -L ./build/tools/wasmedge/wasmedgec:"
otool -L ./build/tools/wasmedge/wasmedgec
echo "otool -L ./build/lib/api/libwasmedge.dylib:"
otool -L ./build/lib/api/libwasmedge.dylib
if otool -L ./build/lib/api/libwasmedge.dylib | grep libLLVM; then echo "Fail: libLLVM shared library linked" && exit 1; else echo "Pass: libLLVM shared library not linked"; fi;
echo "Generate fibonacci.wasm from fibonacci.wat"
wat2wasm examples/wasm/fibonacci.wat -o examples/wasm/fibonacci.wasm
echo "./build/tools/wasmedge/wasmedgec examples/wasm/fibonacci.wasm fib_c.dylib"
./build/tools/wasmedge/wasmedgec examples/wasm/fibonacci.wasm fib_c.dylib
echo "./build/tools/wasmedge/wasmedge --reactor fib_c.dylib fib 20"
./build/tools/wasmedge/wasmedge --reactor fib_c.dylib fib 20
echo "./build/tools/wasmedge/wasmedge compile examples/wasm/fibonacci.wasm fib_compile.dylib"
./build/tools/wasmedge/wasmedge compile examples/wasm/fibonacci.wasm fib_compile.dylib
echo "./build/tools/wasmedge/wasmedge --reactor fib_compile.dylib fib 20"
./build/tools/wasmedge/wasmedge --reactor fib_compile.dylib fib 20
- name: Upload artifact
if: ${{ !inputs.release }}
uses: actions/upload-artifact@v3
with:
name: WasmEdge-${{ inputs.version }}-darwin_${{ matrix.darwin_version }}_${{ matrix.arch }}.tar.gz
path: build/WasmEdge-${{ inputs.version }}-Darwin.tar.gz
- name: Upload package tarball
if: ${{ inputs.release }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
eval $(/opt/homebrew/bin/brew shellenv)
mv build/WasmEdge-${{ inputs.version }}-Darwin.tar.gz WasmEdge-${{ inputs.version }}-darwin_${{ matrix.arch }}.tar.gz
gh release upload ${{ inputs.version }} WasmEdge-${{ inputs.version }}-darwin_${{ matrix.arch }}.tar.gz --clobber