Skip to content

Commit 16bccab

Browse files
committed
[cmake] Add a CMake build CI job.
- omc is built using CMake on xenial. - The job will download and install CMake 3.17.2 since the xenial docker image we use has older CMake version. We can use focal as well but right now the idea is to resemble the other jobs. Work where they work with minimal changes. - Control CI CMake build with a label. - By default the CMake job is on. - Add the label "CI/Skip CMake Build" to your PRs if you want to skip the cmake build. Use this as a last resort if you can not figure out how to fix the cmake build. Please also notify @mahge if you do so that the issue can be fixed.
1 parent 0fe24f2 commit 16bccab

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.CI/common.groovy

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,40 @@ void buildOMSens() {
307307
}
308308
}
309309

310+
void buildOMC_CMake(cmake_args, cmake_exe='cmake') {
311+
standardSetup()
312+
313+
if (isWindows()) {
314+
bat ("""
315+
set OMDEV=C:\\OMDev
316+
echo on
317+
(
318+
echo export MSYS_WORKSPACE="`cygpath '${WORKSPACE}'`"
319+
echo echo MSYS_WORKSPACE: \${MSYS_WORKSPACE}
320+
echo cd \${MSYS_WORKSPACE}
321+
echo export MAKETHREADS=16
322+
echo set -ex
323+
echo mkdir OMCompiler/build_cmake
324+
echo cmake -S OMCompiler -B OMCompiler/build_cmake ${cmake_args}
325+
echo time cmake --build OMCompiler/build_cmake --parallel \${MAKETHREADS} --target install
326+
echo OMCompiler/build_cmake/install_cmake/bin/omc --help
327+
echo OMCompiler/build_cmake/install_cmake/bin/omc --version
328+
) > buildOMCWindows.sh
329+
330+
set MSYSTEM=MINGW64
331+
set MSYS2_PATH_TYPE=inherit
332+
%OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath '${WORKSPACE}'` && chmod +x buildOMCWindows.sh && ./buildOMCWindows.sh && rm -f ./buildOMCWindows.sh"
333+
""")
334+
}
335+
else {
336+
sh "mkdir OMCompiler/build_cmake"
337+
sh "${cmake_exe} -S OMCompiler -B OMCompiler/build_cmake ${cmake_args}"
338+
sh "${cmake_exe} --build OMCompiler/build_cmake --parallel ${numPhysicalCPU()} --target install"
339+
sh "OMCompiler/build_cmake/install_cmake/bin/omc --help"
340+
sh "OMCompiler/build_cmake/install_cmake/bin/omc --version"
341+
}
342+
}
343+
310344
void buildGUI(stash, isQt5) {
311345
if (isWindows()) {
312346
bat ("""
@@ -484,6 +518,15 @@ def shouldWeBuildCENTOS7() {
484518
return params.BUILD_CENTOS7
485519
}
486520

521+
def shouldWeSkipCMakeBuild() {
522+
if (isPR()) {
523+
if (pullRequest.labels.contains("CI/Skip CMake Build")) {
524+
return true
525+
}
526+
}
527+
return params.SKIP_CMAKE_BUILD
528+
}
529+
487530
def shouldWeRunTests() {
488531
if (isPR()) {
489532
def skipTestsFilesList = [".*[.]md",

Jenkinsfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ def common
22
def shouldWeBuildOSX
33
def shouldWeBuildMINGW
44
def shouldWeBuildCENTOS7
5+
def shouldWeSkipCMakeBuild_value
56
def shouldWeRunTests
67
def isPR
78
pipeline {
@@ -17,6 +18,7 @@ pipeline {
1718
booleanParam(name: 'BUILD_OSX', defaultValue: false, description: 'Build with OSX')
1819
booleanParam(name: 'BUILD_MINGW', defaultValue: false, description: 'Build with Win/MinGW')
1920
booleanParam(name: 'BUILD_CENTOS7', defaultValue: false, description: 'Build on CentOS7 with CMake 2.8')
21+
booleanParam(name: 'SKIP_CMAKE_BUILD', defaultValue: false, description: 'Skip building omc with the CMake build system (CMake 3.17.2)')
2022
}
2123
// stages are ordered according to execution time; highest time first
2224
// nodes are selected based on a priority (in Jenkins config)
@@ -41,6 +43,8 @@ pipeline {
4143
print "shouldWeBuildMINGW: ${shouldWeBuildMINGW}"
4244
shouldWeBuildCENTOS7 = common.shouldWeBuildCENTOS7()
4345
print "shouldWeBuildCENTOS7: ${shouldWeBuildCENTOS7}"
46+
shouldWeSkipCMakeBuild_value = common.shouldWeSkipCMakeBuild()
47+
print "shouldWeSkipCMakeBuild: ${shouldWeSkipCMakeBuild_value}"
4448
shouldWeRunTests = common.shouldWeRunTests()
4549
print "shouldWeRunTests: ${shouldWeRunTests}"
4650
}
@@ -176,6 +180,39 @@ pipeline {
176180
//stash name: 'omc-centos7', includes: 'build/**, **/config.status'
177181
}
178182
}
183+
stage('cmake-xenial-gcc') {
184+
agent {
185+
docker {
186+
// image 'docker.openmodelica.org/build-deps:focal.nightly.amd64'
187+
image 'docker.openmodelica.org/build-deps:v1.16-qt4-xenial'
188+
label 'linux'
189+
alwaysPull true
190+
args "--mount type=volume,source=omlibrary-cache,target=/cache/omlibrary " +
191+
"-v /var/lib/jenkins/gitcache:/var/lib/jenkins/gitcache"
192+
}
193+
}
194+
when {
195+
beforeAgent true
196+
expression { !shouldWeSkipCMakeBuild_value }
197+
}
198+
environment {
199+
CC = "gcc"
200+
CXX = "g++"
201+
}
202+
steps {
203+
script {
204+
echo "Download and install CMake 3.17.2"
205+
sh '''
206+
wget "cmake.org/files/v3.17/cmake-3.17.2-Linux-x86_64.sh"
207+
mkdir -p /tmp/cmake
208+
sh cmake-3.17.2-Linux-x86_64.sh --prefix=/tmp/cmake --skip-license
209+
/tmp/cmake/bin/cmake --version
210+
'''
211+
common.buildOMC_CMake('-DCMAKE_BUILD_TYPE=Release -DOMC_USE_CCACHE=OFF', '/tmp/cmake/bin/cmake')
212+
}
213+
// stash name: 'omc-cmake-gcc', includes: 'OMCompiler/build_cmake/install_cmake/bin/**'
214+
}
215+
}
179216
stage('checks') {
180217
agent {
181218
docker {

0 commit comments

Comments
 (0)