Skip to content

Commit

Permalink
add staging and pipeline commands for Windows/MinGW (optional)
Browse files Browse the repository at this point in the history
- remove tabs
- put parentheses for the if condition
- escape $ in string -> \$
- escape \ -> \\
- shorten the name of the stage Windows/MinGW -> Win/MinGW
- use msys sh on Windows
- export OPENMODELICAHOME and OPENMODELICALIBRARY
- hardcode OMDEV for now, print PATH on Windows for debugging
- use bat instead of sh on Windows
- use cygpath to go from windows $WORKSPACE to msys directory
- more magic with quoting the Windows paths in the msys script
- use: set MSYS2_PATH_TYPE=inherit
- resurect runtimeCPPinstall target and make it point to OMSICPPinstall
  • Loading branch information
adrpo committed Jun 8, 2019
1 parent 7247254 commit 8674038
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 2 deletions.
133 changes: 131 additions & 2 deletions .CI/common.groovy
@@ -1,5 +1,17 @@

def isWindows() {
return !isUnix()
}

void standardSetup() {
echo "${env.NODE_NAME}"

if (isWindows()) {
echo "PATH: ${env.PATH}"
bat "git clean -ffdx -e OMSetup && git submodule foreach --recursive git clean -ffdx"
return
}

// Jenkins cleans with -fdx; --ffdx is needed to remove git repositories
sh "git clean -ffdx && git submodule foreach --recursive git clean -ffdx"
}
Expand All @@ -8,6 +20,13 @@ def numPhysicalCPU() {
if (env.JENKINS_NUM_PHYSICAL_CPU) {
return env.JENKINS_NUM_PHYSICAL_CPU
}

if (isWindows())
{
return env.NUMBER_OF_PROCESSORS.toInteger() / 2 ?: 1
}


def uname = sh script: 'uname', returnStdout: true
if (uname.startsWith("Darwin")) {
env.JENKINS_NUM_PHYSICAL_CPU = sh (
Expand All @@ -27,6 +46,12 @@ def numLogicalCPU() {
if (env.JENKINS_NUM_LOGICAL_CPU) {
return env.JENKINS_NUM_LOGICAL_CPU
}

if (isWindows())
{
return env.NUMBER_OF_PROCESSORS.toInteger() ?: 1
}

def uname = sh script: 'uname', returnStdout: true
if (uname.startsWith("Darwin")) {
env.JENKINS_NUM_LOGICAL_CPU = sh (
Expand All @@ -43,8 +68,37 @@ def numLogicalCPU() {
}

void partest(cache=true, extraArgs='') {
if (isWindows()) {

bat ("""
set OMDEV=C:\\OMDev
echo on
(
echo export MSYS_WORKSPACE="`cygpath ' ${WORKSPACE} '`"
echo export OPENMODELICAHOME="\${MSYS_WORKSPACE}\\build"
echo export OPENMODELICALIBRARY="${MSYS_WORKSPACE}\\build\\lib\\omlibrary"
echo cd ${MSYS_WORKSPACE}/testsuite/partest
echo time perl ./runtests.pl -j8 -nocolour -with-xml
echo CODE=\$?
echo if test "\$CODE\" = 0 -o "\$CODE" = 7; then
echo cp -f ../runtest.db.* "${env.RUNTESTDB}/"
echo fi
echo if test "\$CODE" = 0 -o "\$CODE" = 7; then
echo exit 0
echo else
echo exit $CODE
echo fi
) > runTestWindows.sh
set MSYSTEM=MINGW64
set MSYS2_PATH_TYPE=inherit
%OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cypath ' ${WORKSPACE} '` && chmod +x runTestWindows.sh && ./runTestWindows.sh && rm -f ./runTestWindows.sh"
""")

} else {
sh "rm -f omc-diff.skip && ${makeCommand()} -C testsuite/difftool clean && ${makeCommand()} --output-sync -C testsuite/difftool"
sh 'build/bin/omc-diff -v1.4'

sh ("""#!/bin/bash -x
ulimit -t 1500
ulimit -v 6291456 # Max 6GB per process
Expand All @@ -61,15 +115,25 @@ void partest(cache=true, extraArgs='') {
cp ../runtest.db.* "${env.RUNTESTDB}/"
fi
""" : ''))

}

junit 'testsuite/partest/result.xml'
}

void patchConfigStatus() {
// Running on nodes with different paths for the workspace
sh 'sed -i.bak "s,--with-ombuilddir=[A-Za-z0-9/_-]*,--with-ombuilddir=`pwd`/build," config.status OMCompiler/config.status'
if (isUnix())
{
// Running on nodes with different paths for the workspace
sh 'sed -i.bak "s,--with-ombuilddir=[A-Za-z0-9/_-]*,--with-ombuilddir=`pwd`/build," config.status OMCompiler/config.status'
}
}

void makeLibsAndCache(libs='core') {
if (isWindows())
{
// do nothing
} else {
// If we don't have any result, copy to the master to get a somewhat decent cache
sh "cp -f ${env.RUNTESTDB}/${cacheBranch()}/runtest.db.* testsuite/ || " +
"cp -f ${env.RUNTESTDB}/master/runtest.db.* testsuite/ || true"
Expand All @@ -86,19 +150,70 @@ void makeLibsAndCache(libs='core') {
} else {
sh cmd
}
}
}

void buildOMC(CC, CXX, extraFlags) {
standardSetup()

if (isWindows()) {
bat ("""
set OMDEV=C:\\OMDev
echo on
(
echo export MSYS_WORKSPACE="`cygpath ' ${WORKSPACE} '`"
echo cd \${MSYS_WORKSPACE}
echo export MAKETHREADS=-j16
echo set -e
echo export OPENMODELICAHOME="\${MSYS_WORKSPACE}\\build"
echo export OPENMODELICALIBRARY="\${MSYS_WORKSPACE}\\build\\lib\\omlibrary"
echo time make -f Makefile.omdev.mingw \${MAKETHREADS} omc omc-diff omlibrary-core
echo set +e
echo cd \${MSYS_WORKSPACE}
echo sed -i.bak 's/mingw32-make/..\\..\\usr\\bin\\make/g' build/share/omc/scripts/Compile.bat
echo cd \${MSYS_WORKSPACE}
echo make -f Makefile.omdev.mingw \${MAKETHREADS} BUILDTYPE=Release simulationruntimecmsvc BuildType=Release
echo cd \${MSYS_WORKSPACE}
echo make -f 'Makefile.omdev.mingw' \${MAKETHREADS} BUILDTYPE=Release runtimeCPPmsvcinstall
echo cd \${MSYS_WORKSPACE}
echo make -f 'Makefile.omdev.mingw' \${MAKETHREADS} BUILDTYPE=Release runtimeCPPinstall
) > buildOMCWindows.sh
set MSYSTEM=MINGW64
set MSYS2_PATH_TYPE=inherit
%OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath ' ${WORKSPACE} '` && chmod +x buildOMCWindows.sh && ./buildOMCWindows.sh && rm -f ./buildOMCWindows.sh"
""")
} else {
sh 'autoconf'
// Note: Do not use -march=native since we might use an incompatible machine in later stages
sh "./configure CC='${CC}' CXX='${CXX}' FC=gfortran CFLAGS=-Os --with-cppruntime --without-omc --without-omlibrary --with-omniORB --enable-modelica3d ${extraFlags}"
// OMSimulator requires HOME to be set and writeable
sh "HOME='${env.WORKSPACE}' ${makeCommand()} -j${numPhysicalCPU()} --output-sync omc omc-diff omsimulator"
sh 'find build/lib/*/omc/ -name "*.so" -exec strip {} ";"'
}
}

void buildGUI(stash) {
if (isWindows()) {
bat ("""
set OMDEV=C:\\OMDev
echo on
(
echo export MSYS_WORKSPACE="`cygpath ' ${WORKSPACE} '`"
echo cd \${MSYS_WORKSPACE}
echo export MAKETHREADS=-j16
echo set -e
echo export OPENMODELICAHOME="\${MSYS_WORKSPACE}\\build"
echo export OPENMODELICALIBRARY="\${MSYS_WORKSPACE}\\build\\lib\\omlibrary"
echo time make -f Makefile.omdev.mingw \${MAKETHREADS} qtclients
) > buildGUIWindows.sh
set MSYSTEM=MINGW64
set MSYS2_PATH_TYPE=inherit
%OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath ' ${WORKSPACE} '` && chmod +x buildGUIWindows.sh && ./buildGUIWindows.sh && rm -f ./buildGUIWindows.sh"
""")
} else {

if (stash) {
standardSetup()
unstash stash
Expand All @@ -110,21 +225,34 @@ void buildGUI(stash) {
sh 'CONFIG=`./config.status --config` && ./configure `eval $CONFIG`'
sh "touch omc.skip omc-diff.skip ReferenceFiles.skip omsimulator.skip && ${makeCommand()} -q omc omc-diff ReferenceFiles omsimulator" // Pretend we already built omc since we already did so
sh "${makeCommand()} -j${numPhysicalCPU()} --output-sync" // Builds the GUI files

}
}

void generateTemplates() {
if (isWindows()) {
// do nothing
} else {
patchConfigStatus()
// Runs Susan again, for bootstrapping tests, etc
sh "${makeCommand()} -C OMCompiler/Compiler/Template/ -f Makefile.in OMC=\$PWD/build/bin/omc"
sh 'cd OMCompiler && ./config.status'
sh './config.status'
}
}

def getVersion() {
if (isWindows()) {
return (bat (script: 'set OMDEV=C:\\OMDev && set MSYSTEM=MINGW64 && set MSYS2_PATH_TYPE=inherit && %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "build/bin/omc --version | grep -o \"v[0-9]\\+[.][0-9]\\+[.][0-9]\\+[^ ]*\""', returnStdout: true)).replaceAll("\\s","")
} else {
return (sh (script: 'build/bin/omc --version | grep -o "v[0-9]\\+[.][0-9]\\+[.][0-9]\\+[^ ]*"', returnStdout: true)).replaceAll("\\s","")
}
}

void compliance() {
if (isWindows()) {
// do nothing for now
} else {
standardSetup()
unstash 'omc-clang'
makeLibsAndCache('all')
Expand All @@ -139,6 +267,7 @@ void compliance() {
// get rid of freaking %
sh "sed -i.bak 's/%/\\%/g' ${env.COMPLIANCEPREFIX}.ignore.xml && sed -i.bak 's/[^[:print:]]/ /g' ${env.COMPLIANCEPREFIX}.ignore.xml"
junit "${env.COMPLIANCEPREFIX}.ignore.xml"
}
}

def cacheBranch() {
Expand Down
23 changes: 23 additions & 0 deletions Jenkinsfile
Expand Up @@ -9,6 +9,7 @@ pipeline {
}
parameters {
booleanParam(name: 'BUILD_OSX', defaultValue: false, description: 'Build with OSX')
booleanParam(name: 'BUILD_MINGW', defaultValue: false, description: 'Build with Win/MinGW')
}
// stages are ordered according to execution time; highest time first
// nodes are selected based on a priority (in Jenkins config)
Expand Down Expand Up @@ -86,6 +87,28 @@ pipeline {
}
}
}
stage('Win/MinGW') {
agent {
node {
label 'windows.openmodelica.org'
}
}
when {
expression { params.BUILD_MINGW }
}
environment {
RUNTESTDB = '/c/dev/'
LIBRARIES = '/c/dev/jenkins-cache/omlibrary/'
}
steps {
script {
env.PATH="C:\\OMDev\\tools\\msys\\usr\\bin;C:\\Program Files\\TortoiseSVN\\bin;c:\\bin\\jdk\\bin;c:\\bin\\nsis\\;${env.PATH};c:\\bin\\git\\bin;"
common.buildOMC('cc', 'c++', "")
common.makeLibsAndCache()
common.buildGUI('')
}
}
}
stage('checks') {
agent {
docker {
Expand Down
2 changes: 2 additions & 0 deletions Makefile.omdev.mingw
Expand Up @@ -197,6 +197,8 @@ simulationruntimecmsvc:
runtimeCPPmsvcinstall:
$(MAKE) -C OMCompiler -f $(defaultMakefileTarget) OMBUILDDIR=$(OMBUILDDIR) BUILDTYPE=$(BUILDTYPE) runtimeCPPmsvcinstall

runtimeCPPinstall: OMSICPPinstall

OMSICPPinstall:
$(MAKE) -C OMCompiler -f $(defaultMakefileTarget) OMBUILDDIR=$(OMBUILDDIR) BUILDTYPE=$(BUILDTYPE) OMSICPPinstall

Expand Down

0 comments on commit 8674038

Please sign in to comment.