-
Notifications
You must be signed in to change notification settings - Fork 73
246 lines (244 loc) · 10.3 KB
/
build_all.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
name: build_mcx
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
jobs:
build_all:
name: Build All
strategy:
matrix:
os: [ubuntu-20.04, windows-2019]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install dependencies (Linux only)
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get update && sudo apt-get install -y liboctave-dev lazarus libxmu-dev gcc-7 g++-7 upx-ucl
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 7
- name: Install dependencies (MacOS only)
if: ${{ runner.os == 'macOS' }}
run: |
curl -o xcode.zip --insecure https://mcx.space/dev/ci/Xcode731.zip
unzip xcode.zip
sudo mv Xcode.app /Applications/Xcode_7.3.1.app/
sudo xcode-select -s /Applications/Xcode_7.3.1.app/Contents/Developer
xcode-select -p
curl -o libauto.dylib --insecure https://mcx.space/dev/ci/libauto.dylib
echo "DYLD_LIBRARY_PATH=$PWD:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
brew install octave
- name: Install dependencies (Windows only)
if: ${{ runner.os == 'Windows' }}
run: |
curl --retry 3 -kL http://cdimage.debian.org/mirror/gnu.org/gnu/octave/windows/octave-5.2.0_1-w64-64.7z --output octave_5.2.7z
7z x octave_5.2.7z -ooctave -y
rm -rf octave_5.2.7z
#curl --retry 3 -kL https://mcx.space/dev/ci/lazarus-2.0.8-fpc-3.0.4-win32.exe --output lazarus_installer.exe
#chmod +x lazarus_installer.exe
#./lazarus_installer.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
#choco install octave.portable --version=5.2.0
choco install lazarus --version=2.0.6
curl --retry 3 -kL https://github.com/upx/upx/releases/download/v4.0.2/upx-4.0.2-win64.zip --output upx.zip
7z x upx.zip -oupx -y
echo "$PWD/octave/octave-5.2.0-w64-64/mingw64/bin" >> $GITHUB_PATH
echo 'C:\lazarus' >> $GITHUB_PATH
echo 'C:\ProgramData\Chocolatey\lib\mingw\tools\install\mingw64\bin\' >> $GITHUB_PATH
echo 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\' >> $GITHUB_PATH
echo 'MW_MINGW64_LOC=/c/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/' >> $GITHUB_ENV
- name: Install CUDA (Linux only)
if: ${{ runner.os == 'Linux' }}
run: |
cd /tmp && wget -q https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda_9.2.148_396.37_linux
sudo sh /tmp/cuda_9.2.148_396.37_linux --silent --toolkit --override
rm -rf /tmp/cuda_9.2.148_396.37_linux
export PATH=/usr/local/cuda/bin:$PATH
ls /usr/local/cuda/bin
echo "/usr/local/cuda/bin" >> $GITHUB_PATH
nvcc --version
- name: Install CUDA (MacOS only)
if: ${{ runner.os == 'macOS' }}
run: |
curl -o cuda.zip --insecure https://mcx.space/dev/ci/cuda_8.zip
unzip cuda.zip
sudo mv cuda/ /usr/local/
sudo chmod +x /usr/local/cuda/bin/*
echo "CUDA_PATH=/usr/local/cuda/bin" >> $GITHUB_ENV
echo "CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/" >> $GITHUB_ENV
echo "/usr/local/cuda/bin" >> $GITHUB_PATH
mkdir -p ~/bin
- name: Install CUDA (Windows only)
if: ${{ runner.os == 'Windows' }}
uses: Jimver/[email protected]
id: cuda-toolkit
with:
cuda: '9.2.148'
method: 'network'
sub-packages: '["nvcc"]'
- name: Link libgomp.a (MacOS only)
if: ${{ runner.os == 'macOS' }}
run: |
sudo ln -s /usr/local/lib/gcc/10/libgomp.a /usr/local/lib/libgomp.a
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Update RCS keywords
run: |
printf '\n[filter "rcs-keywords"]\n\tclean = .git_filters/rcs-keywords.clean\n\tsmudge = .git_filters/rcs-keywords.smudge %f\n' >> .git/config
rm -rf src/*.c
git checkout src/*.c
- name: Build mcxlab for Octave
if: ${{ runner.os != 'Windows' }}
run: |
cd src
which gcc
gcc -v
mkoctfile -p ALL_CXXFLAGS
mkoctfile -p INCLUDEDIR
mkoctfile -p INCFLAGS
if [[ "$RUNNER_OS" == "Linux" ]]; then
make oct BACKEND=cudastatic
ldd ../mcxlab/mcx.mex
elif [[ "$RUNNER_OS" == "macOS" ]]; then
make oct CC=gcc-10 CXX=g++-10 USEROCTOPT="CXXFLAGS='-pipe -Os -arch x86_64' DL_LD=g++-10 DL_LDFLAGS='-fopenmp -static-libgcc -static-libstdc++'"
otool -L ../mcxlab/mcx.mex
else
ln -s "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2" cuda
make oct INCLUDEDIRS="-I./cuda/include" CUDA_PATH="./cuda" XTRA_CFLAGS='-openmp' XTRA_CXXFLAGS='-openmp' INCLUDEDIR=' '
objdump -p ../mcxlab/mcx.mex | grep "DLL Name:"
fi
octave-cli --eval "fprintf(1,['OCTAVE_ARCH=' regexprep(computer('arch'), 'darwin[0-9.]+-', 'darwin-')])"
octave-cli --eval "fprintf(1,['OCTAVE_ARCH=' regexprep(computer('arch'), 'darwin[0-9.]+-', 'darwin-')])" >> $GITHUB_ENV
- name: Build mcxlab for MATLAB
if: ${{ runner.os != 'macOS' }}
run: |
cd src
if [[ "$RUNNER_OS" == "Windows" ]]; then
make mex
objdump -p ../mcxlab/mcx.mexw* | grep "DLL Name:"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
which mex
make mex CC=gcc-10 CXX=g++-10 MEXLINKOPT="-static-libstdc++ -static-libgcc -fopenmp" EXTRALIB="-f mexopts_maci64_gcc.xml"
otool -L ../mcxlab/mcx.mex*
else
make mex MEXLINKOPT="-static-libstdc++ -static-libgcc -fopenmp"
ldd ../mcxlab/mcx.mex*
strip ../mcxlab/mcx.mex*
upx -9 ../mcxlab/mcx.mex*
fi
- name: Build binary
run: |
cd src
make clean
if [[ "$RUNNER_OS" == "Linux" ]]; then
make AR=g++ BACKEND=cudastatic USERLINKOPT='lib/libzmat.a -Wl,-Bstatic -lgomp -Wl,-Bdynamic'
ldd ../bin/mcx
elif [[ "$RUNNER_OS" == "macOS" ]]; then
make BACKEND=cudastatic CC=gcc-10 CXX=g++-10
otool -L ../bin/mcx
else
make static
objdump -p ../bin/mcx.exe | grep "DLL Name:"
fi
- name: Build mcxstudio
if: ${{ runner.os != 'macOS' }}
run: |
cd mcxstudio
lazbuild --build-mode=release mcxshow.lpi
lazbuild --build-mode=release mcxviewer.lpi
lazbuild --build-mode=release mcxstudio.lpi
cp debug/mcxstudio ../bin
cp mcxshow ../bin
cp mcxviewer ../bin
cp README.txt ../inno/MCXStudio_README.txt
- name: Create package folder
run: |
mkdir packages
mkdir -p mcxlab/octave/${{ env.OCTAVE_ARCH }}
- name: Create release tag
run: perl -e "print 'RELEASE_TAG='. lc('${{ runner.os }}-${{ runner.arch }}-github-latest')" >> $GITHUB_ENV
- name: Zip mcxlab
run: |
[[ -f mcxlab/mcx.mex ]] && mv mcxlab/mcx.mex mcxlab/octave/${{ env.OCTAVE_ARCH }}
if [[ "$RUNNER_OS" == "Windows" ]]; then
upx/upx-4.0.2-win64/upx mcxlab/mcx.mex*
7z a -tzip packages/mcxlab-${{ env.RELEASE_TAG }}.zip mcxlab
else
zip -FSr --symlink packages/mcxlab-${{ env.RELEASE_TAG }}.zip mcxlab
fi
- name: Upload mcxlab package
if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-11' || matrix.os == 'windows-2019' }}
uses: actions/upload-artifact@v3
with:
name: all-mcx-packages
path: packages/mcxlab-${{ env.RELEASE_TAG }}.zip
- name: Prepare mcx package
run: |
if [[ "$RUNNER_OS" == "macOS" ]]; then
cp -a src/mcstudio/debug/mcxstudio.app bin
cp -a src/mcstudio/mcxshow.app bin
cp -a src/mcstudio/mcxviewer.app bin
elif [[ "$RUNNER_OS" == "Windows" ]]; then
rm -rf octave cuda_installer* bin/mcx.lib bin/mcx.exp
strip -S bin/*
upx/upx-4.0.2-win64/upx -9 bin/*
rm -rf upx
else
strip bin/*
upx -9 bin/*
fi
rm -rf .git .github mcxlab vsproj nsight mcxstudio src Makefile package icons genlog.sh .git* deploy icons filter mcxcloud pmcx pymcx winget inno
- name: Zip mcx
run: |
cd .. && pwd
if [[ "$RUNNER_OS" == "Windows" ]]; then
7z a -tzip mcx/packages/mcx-${{ env.RELEASE_TAG }}.zip mcx -xr!mcx/packages
else
zip -FSr --symlink mcx/packages/mcx-${{ env.RELEASE_TAG }}.zip mcx -x 'mcx/packages*'
fi
- name: Upload mcx package
if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-10.15' || matrix.os == 'windows-2019' }}
uses: actions/upload-artifact@v3
with:
name: all-mcx-packages
path: packages/mcx-${{ env.RELEASE_TAG }}.zip
upload_package:
name: Upload Packages
needs: build_all
runs-on: ubuntu-20.04
if: ${{ github.repository_owner == 'fangq' && github.event_name != 'pull_request'}}
steps:
- name: Download mcx
uses: actions/download-artifact@v3
with:
name: all-mcx-packages
path: packages
- name: Create all-in-one octave mcxlab
run: |
cd packages
unzip -n 'mcxlab*.zip'
tree .
zip -FSr --symlink mcxlab-allinone-github-latest.zip mcxlab
rm -rf mcxlab
- name: Display structure of downloaded files
run: ls -R packages
- name: Copy package to server
if: ${{ github.repository_owner == 'fangq' && github.event_name != 'pull_request'}}
uses: wlixcc/[email protected]
with:
server: ${{ secrets.MCX_SERVER }}
username: ${{ secrets.MCX_SERVER_USER }}
ssh_private_key: ${{ secrets.MCX_SERVER_SSH_KEY }}
local_path: "packages/*"
remote_path: ${{ secrets.MCX_CI_PATH }}