forked from polymetric/prines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
232 lines (218 loc) · 11.1 KB
/
Jenkinsfile
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
pipeline {
agent any
environment {
VERSION = '2.5'
APPNAME = '${APPNAME}'
GMP_VERSION = '6.2.1'
BOINC_VERSION = '3f8135e46b725fcaf08b80c5c53db8a988a01cbf'
}
stages {
stage('build linux x64') {
agent { docker {
image 'dockcross/linux-x64'
args '-u root:root'
} }
environment {
CROSS_TRIPLE='x86_64-unknown-linux-gnu'
NUM_CPUS="""${sh(
returnStdout: true,
script: "lscpu | grep -E '^CPU\\(s\\):' | awk '{print \$2}'"
)}"""
}
steps {
sh 'set -eux'
// build boinc libs
sh 'rm -rf boinc'
sh 'git clone https://github.com/BOINC/boinc.git'
dir ('boinc') {
sh "git checkout ${BOINC_VERSION}"
sh './_autosetup'
sh "./configure --disable-client --disable-server --disable-fcgi --disable-manager --enable-generic-processor --enable-libraries --enable-install-headers --enable-static --host=${CROSS_TRIPLE}"
sh 'make -j\${NUM_CPUS}'
sh 'make DESTDIR=/work/temproot install'
}
// build gmp
sh 'rm -rf gmp*'
sh 'wget https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz'
sh 'tar xf gmp-${GMP_VERSION}.tar.xz'
dir ('gmp-${GMP_VERSION}') {
sh "./configure --host ${CROSS_TRIPLE} --enable-fat --enable-cxx --enable-static"
sh 'make -j\${NUM_CPUS}'
// sh 'make check'
sh 'make DESTDIR=/work/temproot install'
}
// build app
sh 'mkdir -p build'
sh "\$CXX main.cpp -o build/${APPNAME}_${VERSION}_${CROSS_TRIPLE} -I/work/temproot/usr/local/include -L/work/temproot/usr/local/lib -pthread -lboinc_api -lboinc -lgmp -lgmpxx -Ofast -static"
// assert that the resulting executable is fully static
sh "[ \"\$(ldd build/${APPNAME}_${VERSION}_${CROSS_TRIPLE} | xargs)\" = 'not a dynamic executable' ]"
stash includes: "build/${APPNAME}_${VERSION}_${CROSS_TRIPLE}", name: 'bin linux x64'
}
}
stage('build linux arm64') {
agent { docker {
image 'dockcross/linux-arm64'
args '-u root:root'
} }
environment {
CROSS_TRIPLE='aarch64-unknown-linux-gnu'
NUM_CPUS="""${sh(
returnStdout: true,
script: "lscpu | grep -E '^CPU\\(s\\):' | awk '{print \$2}'"
)}"""
}
steps {
sh 'set -eux'
// build boinc libs
sh 'rm -rf boinc'
sh 'git clone https://github.com/BOINC/boinc.git'
dir ('boinc') {
sh "git checkout ${BOINC_VERSION}"
sh './_autosetup'
sh "./configure --disable-client --disable-server --disable-fcgi --disable-manager --enable-generic-processor --enable-libraries --enable-install-headers --enable-static --host=${CROSS_TRIPLE}"
sh 'make -j\${NUM_CPUS}'
sh 'make DESTDIR=/work/temproot install'
}
// build gmp
sh 'rm -rf gmp*'
sh 'wget https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz'
sh 'tar xf gmp-${GMP_VERSION}.tar.xz'
dir ('gmp-${GMP_VERSION}') {
sh "./configure --host ${CROSS_TRIPLE} --enable-fat --enable-cxx --enable-static"
sh 'make -j\${NUM_CPUS}'
// sh 'make check'
sh 'make DESTDIR=/work/temproot install'
}
// build app
sh 'mkdir -p build'
sh "\$CXX main.cpp -o build/${APPNAME}_${VERSION}_${CROSS_TRIPLE} -I/work/temproot/usr/local/include -L/work/temproot/usr/local/lib -pthread -lboinc_api -lboinc -lgmp -lgmpxx -Ofast -static"
// assert that the resulting executable is fully static
sh "[ \"\$(ldd build/${APPNAME}_${VERSION}_${CROSS_TRIPLE} | xargs)\" = 'not a dynamic executable' ]"
stash includes: "build/${APPNAME}_${VERSION}_${CROSS_TRIPLE}", name: 'bin linux arm64'
}
}
// stage('build linux armv7') {
// agent { docker {
// image 'dockcross/linux-armv7'
// args '-u root:root'
// } }
// environment {
// CROSS_TRIPLE='arm-unknown-linux-gnueabihf'
// NUM_CPUS="""${sh(
// returnStdout: true,
// script: "lscpu | grep -E '^CPU\\(s\\):' | awk '{print \$2}'"
// )}"""
// }
// steps {
// sh 'set -eux'
// // build boinc libs
// sh 'rm -rf boinc'
// sh 'git clone https://github.com/BOINC/boinc.git'
// dir ('boinc') {
// sh "git checkout ${BOINC_VERSION}"
// sh './_autosetup'
// sh "./configure --disable-client --disable-server --disable-fcgi --disable-manager --enable-generic-processor --enable-libraries --enable-install-headers --enable-static --host=${CROSS_TRIPLE}"
// sh 'make -j\${NUM_CPUS}'
// sh 'make DESTDIR=/work/temproot install'
// }
// // build gmp
// sh 'rm -rf gmp*'
// sh 'wget https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz'
// sh 'tar xf gmp-${GMP_VERSION}.tar.xz'
// dir ('gmp-${GMP_VERSION}') {
// sh "./configure --host ${CROSS_TRIPLE} --enable-fat --enable-cxx --enable-static"
// sh 'make -j\${NUM_CPUS}'
// //sh 'make check'
// sh 'make DESTDIR=/work/temproot install'
// }
// // build app
// sh 'mkdir -p build'
// sh "\$CXX main.cpp -o build/${APPNAME}_${VERSION}_${CROSS_TRIPLE} -I/work/temproot/usr/local/include -L/work/temproot/usr/local/lib -pthread -lboinc_api -lboinc -lgmp -lgmpxx -Ofast -static"
// // assert that the resulting executable is fully static
// sh "[ \"\$(ldd build/${APPNAME}_${VERSION}_${CROSS_TRIPLE} | xargs)\" = 'not a dynamic executable' ]"
// stash includes: "build/${APPNAME}_${VERSION}_${CROSS_TRIPLE}", name: 'bin linux armv7'
// }
// }
stage('build windows x64') {
agent { docker {
image 'dockcross/windows-static-x64'
args '-u root:root'
} }
environment {
CROSS_TRIPLE='x86_64-windows-gnu'
NUM_CPUS="""${sh(
returnStdout: true,
script: "lscpu | grep -E '^CPU\\(s\\):' | awk '{print \$2}'"
)}"""
}
steps {
sh 'set -eux'
sh 'apt-get update'
sh 'apt-get install -y zstd'
// build boinc libs
// this is commented out cause cross compiling is broken
// we just use the pre-compiled one in the include directory
// for now
// sh 'rm -rf boinc'
// sh 'git clone https://github.com/BOINC/boinc.git'
// dir ('boinc') {
// sh "git checkout ${BOINC_VERSION}"
// sh './_autosetup'
// sh "./configure --disable-client --disable-server --disable-fcgi --disable-manager --enable-generic-processor --enable-libraries --enable-install-headers --enable-static --host=${CROSS_TRIPLE}"
// sh 'make -j\${NUM_CPUS}'
// sh 'make DESTDIR=/work/temproot install'
// }
// build gmp
// sh 'rm -rf gmp*'
// sh 'wget https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz'
// sh 'tar xf gmp-${GMP_VERSION}.tar.xz'
// dir ('gmp-${GMP_VERSION}') {
// sh "./configure --host ${CROSS_TRIPLE} --disable-assembly --enable-cxx --enable-static"
// sh 'make -j\${NUM_CPUS}'
// //sh 'make check'
// sh 'make DESTDIR=/work/temproot install'
// }
// install gmp
sh "wget https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gmp-${GMP_VERSION}-2-any.pkg.tar.zst"
sh "tar -I zstd -xf mingw-w64-x86_64-gmp-${GMP_VERSION}-2-any.pkg.tar.zst"
// build app
sh 'mkdir -p build'
// use precompiled boinc libs
sh "\$CXX main.cpp -o build/${APPNAME}_${VERSION}_${CROSS_TRIPLE}.exe -I/work/temproot/usr/local/include -L/work/temproot/usr/local/lib -L./include/boinc/lib/win -L./mingw64/lib -I./mingw64/include -I./include -pthread -lboinc_api -lboinc -lgmp -lgmpxx -Ofast -static"
// assert that the resulting executable is fully static
sh "[ \"\$(ldd build/${APPNAME}_${VERSION}_${CROSS_TRIPLE}.exe | xargs)\" = 'not a dynamic executable' ]"
stash includes: "build/${APPNAME}_${VERSION}_${CROSS_TRIPLE}.exe", name: 'bin windows x64'
}
}
stage('package') {
steps {
unstash 'bin linux x64'
unstash 'bin windows x64'
unstash 'bin linux arm64'
// unstash 'bin linux armv7'
sh "./package add-version ${APPNAME} ${VERSION} x86_64-pc-linux-gnu build/${APPNAME}_${VERSION}_x86_64-unknown-linux-gnu"
sh "./package add-version ${APPNAME} ${VERSION} windows_x86_64 build/${APPNAME}_${VERSION}_x86_64-windows"
sh "./package add-version ${APPNAME} ${VERSION} aarch64-unknown-linux-gnu build/${APPNAME}_${VERSION}_aarch64-unknown-linux-gnu"
// sh "./package add-version ${APPNAME} ${VERSION} arm-unknown-linux-gnueabihf build/${APPNAME}_${VERSION}_arm-unknown-linux-gnueabihf"
sh "./package archive ${APPNAME}_${VERSION}"
stash includes: "${APPNAME}_${VERSION}.tar.xz", name: 'package'
}
}
}
post {
always {
unstash 'bin linux x64'
unstash 'bin windows x64'
unstash 'bin linux arm64'
// unstash 'bin linux armv7'
unstash 'package'
archiveArtifacts artifacts: "build/${APPNAME}_${VERSION}_x86_64-unknown-linux-gnu", fingerprint: true
archiveArtifacts artifacts: "build/${APPNAME}_${VERSION}_x86_64-windows-gnu", fingerprint: true
archiveArtifacts artifacts: "build/${APPNAME}_${VERSION}_aarch64-unknown-linux-gnu", fingerprint: true
// archiveArtifacts artifacts: "build/${APPNAME}_${VERSION}_arm-unknown-linux-gnueabihf", fingerprint: true
// archiveArtifacts artifacts: "build/${APPNAME}_${VERSION}_x86_64-apple-darwin", fingerprint: true
archiveArtifacts artifacts: "${APPNAME}_${VERSION}.tar.xz", fingerprint: true
deleteDir()
}
}
}