-
Notifications
You must be signed in to change notification settings - Fork 6
125 lines (104 loc) · 3.59 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
name: build
on: push
jobs:
build:
runs-on: >-
${{
((matrix.os == 'linux' && matrix.arch == 'arm64') &&
'ubuntu-24.04-arm' ||
((matrix.os == 'mac' && matrix.arch == 'arm64') &&
'macos-15' ||
(fromJson('{"linux":"ubuntu-24.04","mac":"macos-13","win":"windows-2022"}')[matrix.os])))
}}
continue-on-error: false
strategy:
fail-fast: false
matrix:
os: [linux, mac, win]
arch: [arm64, x64]
exclude:
- os: win
arch: arm64
steps:
- name: Install Linux dependencies
if: matrix.os == 'linux'
run: sudo apt-get install -y ninja-build libblas-dev liblapack-dev liblapacke-dev
- name: Install macOS dependencies
if: matrix.os == 'mac'
run: brew install ninja openblas
- name: Install Windows SDK
if: matrix.os == 'win'
uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
with:
sdk-version: 22621
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install node modules
run: yarn
- name: Use ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-${{ matrix.os }}-${{ matrix.arch }}
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: Build (Posix)
if: matrix.os != 'win'
run: |
yarn build -p ${{ steps.cpu-cores.outputs.count }} \
-G Ninja \
--CDCMAKE_C_COMPILER_LAUNCHER=ccache \
--CDCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Build (Windows)
if: matrix.os == 'win'
shell: cmd
run: |
pushd "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
for /f "delims=" %%x in ('.\vswhere.exe -latest -property InstallationPath') do set VSPATH=%%x
popd
call "%VSPATH%\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch }}
yarn build -p ${{ steps.cpu-cores.outputs.count }} ^
-G Ninja ^
-DCMAKE_C_COMPILER_LAUNCHER=ccache ^
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_C_COMPILER=cl ^
-DCMAKE_CXX_COMPILER=cl ^
-DCMAKE_RC_COMPILER=cl
- name: Test
if: matrix.os != 'win'
run: yarn test
- name: Prepare .node file
run: cp build/Release/node_mlx.node mlx-${{ matrix.os }}-${{ matrix.arch }}.node
- name: Prepare .metallib file
if: matrix.os == 'mac' && matrix.arch == 'arm64'
run: cp build/deps/mlx/mlx/backend/metal/kernels/mlx.metallib mlx-${{ matrix.os }}-${{ matrix.arch }}.metallib
- name: Upload Binary Files
uses: actions/upload-artifact@v4
with:
name: mlx-${{ matrix.os }}-${{ matrix.arch }}
path: mlx-${{ matrix.os }}-${{ matrix.arch }}.*
retention-days: 1
release:
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest
permissions:
# Needed by action-gh-release.
contents: write
steps:
- name: Download Files
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Compress files
run: gzip *
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
name: node-mlx ${{ github.ref_name }}
body: '## Changelog'
files: '*.gz'