-
Notifications
You must be signed in to change notification settings - Fork 32
193 lines (191 loc) · 8.37 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
name: build_mmc
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
jobs:
build_all:
name: Build All
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-12, 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 add-apt-repository -s "deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main universe"
sudo apt-get update && sudo apt-get install -y ocl-icd-libopencl1 opencl-headers ocl-icd-opencl-dev liboctave-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: |
brew install octave
brew install upx
- name: Link libgomp.a (MacOS only)
if: ${{ runner.os == 'macOS' }}
run: |
sudo ln -s /usr/local/lib/gcc/11/libgomp.a /usr/local/lib/libgomp.a
- name: Install dependencies (Windows only)
if: ${{ runner.os == 'Windows' }}
run: |
choco install octave.portable --version=8.3.0
choco install upx
choco install mingw --version=8.1.0
echo 'C:\ProgramData\chocolatey\lib\octave.portable\tools\octave\mingw64\bin' >> $GITHUB_PATH
echo 'C:\ProgramData\Chocolatey\lib\mingw\tools\install\mingw64\bin\' >> $GITHUB_PATH
echo 'MW_MINGW64_LOC=/c/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/' >> $GITHUB_ENV
- name: Install OpenCL.dll and static libraries (Windows only)
if: ${{ runner.os == 'Windows' }}
run: |
mkdir opencl
cd opencl
curl http://mcx.space/wiki/upload/opencl.zip --output opencl.zip
unzip opencl.zip
cp bin/OpenCL.dll 'c:\Windows\System32'
cd ..
rm -rf opencl
- 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 mmclab for Octave
run: |
cd src
which gcc
gcc -v
mkoctfile --version
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9
make oct MEXLINKOPT="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lc -lm -lstdc++ -lpthread -Wl,-Bdynamic"
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 7
ldd ../mmclab/mmc.mex
elif [[ "$RUNNER_OS" == "macOS" ]]; then
make oct CC=gcc-11 CXX=g++-11 USEROCTOPT="CXXFLAGS='-pipe -Os -arch x86_64' DL_LD=g++ DL_LDFLAGS='-fopenmp -static-libgcc -static-libstdc++'"
otool -L ../mmclab/mmc.mex
else
PATH='/c/ProgramData/chocolatey/lib/octave.portable/tools/octave/mingw64/bin':$PATH
which g++
g++ --version
make oct CC=gcc CXX=g++ LIBOPENCL='/c/Windows/System32/OpenCL.dll --verbose' LFLAGS='-static-libgcc -static-libstdc++'
objdump -p ../mmclab/mmc.mex | grep "DLL Name:"
make clean
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 mmclab for MATLAB
run: |
cd src
if [[ "$RUNNER_OS" == "Windows" ]]; then
alias cc=gcc
make mex CC=gcc CXX=g++ LDFLAGS="-static lib/libzmat.a" EXTRALIB="-Lc:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/lib -v"
objdump -p ../mmclab/mmc.mexw* | grep "DLL Name:"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
which mex
make mex CC=gcc-11 CXX=g++-11 MEXLINKOPT="-static-libstdc++ -static-libgcc -fopenmp" EXTRALIB="-v -f mexopts_maci64_gcc.xml"
otool -L ../mmclab/mmc.mex*
else
make mex MEXLINKOPT="-static-libstdc++ -static-libgcc -Wl,-Bstatic -lstdc++ -lpthread -fopenmp -Wl,-Bdynamic" EXTRALIB="-v"
ldd ../mmclab/mmc.mex*
fi
- name: Build binary
run: |
cd src
make clean
if [[ "$RUNNER_OS" == "Linux" ]]; then
make AR=c++ EXTRALIB="-static-libstdc++ -static-libgcc -Wl,-Bdynamic -lOpenCL -Wl,-Bstatic -lc -lm -lstdc++ -lpthread -fopenmp"
ldd ../bin/mmc
elif [[ "$RUNNER_OS" == "macOS" ]]; then
make CC=gcc-11 CXX=g++-11
otool -L ../bin/mmc
else
make CC=gcc CXX=g++ USERARFLAGS="-static-libstdc++ -static-libgcc -Wl,-Bstatic lib/libzmat.a -Lc:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/lib"
ldd ../bin/mmc
fi
- name: Create package folder
run: |
mkdir packages
mkdir -p mmclab/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 mmclab
run: |
upx -9 mmclab/mmc.mex* || true
mv mmclab/mmc.mex mmclab/octave/${{ env.OCTAVE_ARCH }}
if [[ "$RUNNER_OS" == "Windows" ]]; then
cp /c/ProgramData/chocolatey/lib/octave.portable/tools/octave/mingw64/bin/libgomp-1.dll mmclab/octave/${{ env.OCTAVE_ARCH }}
cp /c/ProgramData/chocolatey/lib/octave.portable/tools/octave/mingw64/bin/libwinpthread-1.dll mmclab/octave/${{ env.OCTAVE_ARCH }}
upx -9 mmclab/octave/${{ env.OCTAVE_ARCH }}/* || true
7z a -tzip packages/mmclab-${{ env.RELEASE_TAG }}.zip mmclab
else
zip -FSr --symlink packages/mmclab-${{ env.RELEASE_TAG }}.zip mmclab
fi
- name: Upload mmclab package
if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-12' || matrix.os == 'windows-2019' }}
uses: actions/upload-artifact@v3
with:
name: all-mmc-packages
path: packages/mmclab-${{ env.RELEASE_TAG }}.zip
- name: Prepare mmc package
run: |
rm -rf .git mmclab webmmc commons src .git_filters .gitattributes .github .travis.yml win32 deploy
- name: Zip mmc
run: |
cd .. && pwd
upx -9 mmc/bin/* || true
if [[ "$RUNNER_OS" == "Windows" ]]; then
7z a -tzip mmc/packages/mmc-${{ env.RELEASE_TAG }}.zip mmc -xr!mmc/packages
else
zip -FSr --symlink mmc/packages/mmc-${{ env.RELEASE_TAG }}.zip mmc -x 'mmc/packages*'
fi
- name: Upload mmc package
if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-12' || matrix.os == 'windows-2019' }}
uses: actions/upload-artifact@v3
with:
name: all-mmc-packages
path: packages/mmc-${{ 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 mmclab
uses: actions/download-artifact@v3
with:
name: all-mmc-packages
path: packages
- name: Create all-in-one octave mmclab
run: |
cd packages
unzip -n 'mmclab*.zip'
tree .
zip -FSr --symlink mmclab-allinone-github-latest.zip mmclab
rm -rf mmclab
- 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 }}