-
Notifications
You must be signed in to change notification settings - Fork 22
257 lines (227 loc) · 10.3 KB
/
macos-precompile.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
name: macos-precompile
on:
push:
tags:
- 'v*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
mix_compile:
runs-on: ${{ matrix.pair.os }}
env:
MIX_ENV: prod
OPENCV_VER: "4.10.0"
EVISION_PREFER_PRECOMPILED: "false"
EVISION_GENERATE_LANG: "erlang,elixir"
strategy:
fail-fast: false
matrix:
include:
- pair:
os: macos-12
arch: x86_64
arch_name: x86_64
NIF_VERSION: "2.16"
OTP_VERSION: "25.3"
ELIXIR_VERSION: "1.16.1"
- pair:
os: macos-14
arch: arm64
arch_name: aarch64
NIF_VERSION: "2.16"
OTP_VERSION: "25.3"
ELIXIR_VERSION: "1.16.1"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Erlang and Elixir
run: |
brew install autoconf coreutils curl git openssl wxwidgets asdf ffmpeg eigen
brew link ffmpeg
asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
export KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac"
asdf install erlang ${{ matrix.pair.OTP_VERSION }}
asdf install elixir ${{ matrix.pair.ELIXIR_VERSION }}
asdf global erlang ${{ matrix.pair.OTP_VERSION }}
asdf global elixir ${{ matrix.pair.ELIXIR_VERSION }}
source $(brew --prefix asdf)/libexec/asdf.sh
mix local.hex --force
mix local.rebar --force
- name: Cache mix packages
id: cache-mix-deps
uses: actions/cache@v4
with:
key: deps-${{ hashFiles('mix.lock') }}
path: |
./deps
- name: Get mix deps
if: steps.cache-mix-deps.outputs.cache-hit != 'true'
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
mix deps.get
- name: Cache OpenCV source code
id: cache-opencv
uses: actions/cache@v4
with:
key: opencv-with-contrib-${{ env.OPENCV_VER }}
path: |
./3rd_party
- name: Download OpenCV source code
if: steps.cache-opencv.outputs.cache-hit != 'true'
run: |
bash scripts/download_opencv.sh ${OPENCV_VER} 3rd_party/cache 3rd_party/opencv/
bash scripts/download_opencv_contrib.sh ${OPENCV_VER} 3rd_party/cache 3rd_party/opencv/
- name: Compile OpenCV (without contrib modules)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=false
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -rf "./_build/${{ env.MIX_ENV }}/lib/evision"
mix compile_opencv
- name: Mix compile (without contrib modules)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=false
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.so
rm -rf lib/generated && rm -rf src/generated
mkdir -p lib/generated && mkdir -p src/generated
mix compile
- name: Create precompiled library (without contrib modules)
run: |
export PKG_NAME=evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-apple-darwin-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
mv "${PRIV_DIR}/include" /tmp/include
cp -a "${PRIV_DIR}" "${PKG_NAME}"
cp -a lib/generated "${PKG_NAME}/elixir_generated"
cp -a src/generated "${PKG_NAME}/erlang_generated"
tar -czf "${PKG_NAME}.tar.gz" "${PKG_NAME}"
rm -rf "${PKG_NAME}"
ls -lah "${PKG_NAME}.tar.gz"
mkdir -p artifacts
mv "${PKG_NAME}.tar.gz" artifacts
cd artifacts
sha256sum "${PKG_NAME}.tar.gz" | tee "${PKG_NAME}.tar.gz.sha256"
mv /tmp/include "${PRIV_DIR}/include"
- name: Mix compile (without contrib modules) for Gleam (experimental)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=false
export GLEAM_EVISION=true
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.so
rm -rf lib/generated && rm -rf src/generated
mix compile
unset GLEAM_EVISION
- name: Create precompiled library (without contrib modules)
run: |
export PKG_NAME=gleam_evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-apple-darwin-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
mv "${PRIV_DIR}/include" /tmp/include
cp -a "${PRIV_DIR}" "${PKG_NAME}"
cp -a gleam_src "${PKG_NAME}/gleam_generated"
cp -a src/evision_highgui.erl "${PKG_NAME}/gleam_generated/"
cp -a src/evision_internal_structurise.erl "${PKG_NAME}/gleam_generated/"
cp -a src/evision_windows_fix.erl "${PKG_NAME}/gleam_generated/"
tar -czf "${PKG_NAME}.tar.gz" "${PKG_NAME}"
rm -rf "${PKG_NAME}"
ls -lah "${PKG_NAME}.tar.gz"
mkdir -p artifacts
mv "${PKG_NAME}.tar.gz" artifacts
cd artifacts
sha256sum "${PKG_NAME}.tar.gz" | tee "${PKG_NAME}.tar.gz.sha256"
mv /tmp/include "${PRIV_DIR}/include"
- name: Compile OpenCV (with contrib modules)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=true
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -rf "./_build/${{ env.MIX_ENV }}/lib/evision"
mix compile_opencv
- name: Mix compile (with contrib modules)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=true
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.so
rm -rf lib/generated && rm -rf src/generated
mkdir -p lib/generated && mkdir -p src/generated
mix compile
- name: Create precompiled library (with contrib modules)
run: |
export PKG_NAME=evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-apple-darwin-contrib-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
mv "${PRIV_DIR}/include" /tmp/include
cp -a "${PRIV_DIR}" "${PKG_NAME}"
cp -a lib/generated "${PKG_NAME}/elixir_generated"
cp -a src/generated "${PKG_NAME}/erlang_generated"
tar -czf "${PKG_NAME}.tar.gz" "${PKG_NAME}"
rm -rf "${PKG_NAME}"
ls -lah "${PKG_NAME}.tar.gz"
mkdir -p artifacts
mv "${PKG_NAME}.tar.gz" artifacts
cd artifacts
sha256sum "${PKG_NAME}.tar.gz" | tee "${PKG_NAME}.tar.gz.sha256"
mv /tmp/include "${PRIV_DIR}/include"
- name: Mix compile (with contrib modules) for Gleam (experimental)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=true
export GLEAM_EVISION=true
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.so
rm -rf lib/generated && rm -rf src/generated
mix compile
- name: Create precompiled library (with contrib modules)
run: |
export PKG_NAME=gleam_evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-apple-darwin-contrib-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
mv "${PRIV_DIR}/include" /tmp/include
cp -a "${PRIV_DIR}" "${PKG_NAME}"
cp -a gleam_src "${PKG_NAME}/gleam_generated"
cp -a src/evision_highgui.erl "${PKG_NAME}/gleam_generated/"
cp -a src/evision_internal_structurise.erl "${PKG_NAME}/gleam_generated/"
cp -a src/evision_windows_fix.erl "${PKG_NAME}/gleam_generated/"
tar -czf "${PKG_NAME}.tar.gz" "${PKG_NAME}"
rm -rf "${PKG_NAME}"
ls -lah "${PKG_NAME}.tar.gz"
mkdir -p artifacts
mv "${PKG_NAME}.tar.gz" artifacts
cd artifacts
sha256sum "${PKG_NAME}.tar.gz" | tee "${PKG_NAME}.tar.gz.sha256"
mv /tmp/include "${PRIV_DIR}/include"
- uses: softprops/action-gh-release@v2
with:
files: |
artifacts/*.tar.gz
artifacts/*.sha256