Skip to content

Commit

Permalink
Add a pipeline for OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Jun 4, 2019
1 parent 84f52c5 commit 3e60c14
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 43 deletions.
36 changes: 26 additions & 10 deletions .CI/Jenkinsfile.osx
@@ -1,28 +1,44 @@
def common
pipeline {
agent none
environment {
LC_ALL = 'C.UTF-8'
}
stages {
stage('Environment') {
agent {
label '!windows'
}
steps {
script {
if (changeRequest()) {
def buildNumber = env.BUILD_NUMBER as int
if (buildNumber > 1) milestone(buildNumber - 1)
milestone(buildNumber)
}
common = load("${env.workspace}/.CI/common.groovy")
}
}
}
stage('MacOS') {
agent {
node {
label 'osx'
}
}
environment {
RUNTESTDB = "/Users/hudson/jenkins-cache/runtest/"
LIBRARIES = "/Users/hudson/jenkins-cache/omlibrary"
RUNTESTDB = '/Users/hudson/jenkins-cache/runtest/'
LIBRARIES = '/Users/hudson/jenkins-cache/omlibrary'
GMAKE = 'gmake'
LC_ALL = 'C'
}
steps {
script {
common = load("${env.workspace}/.CI/common.groovy")
env.PATH="${env.MACPORTS}/bin:${env.PATH}"
// Qt5 is MacOS 10.12+...
env.QTDIR="${env.MACPORTS}/libexec/qt4"
common.buildOMC('cc', 'c++', "OMPCC='gcc-mp-5 -fopenmp -mno-avx' GNUCXX=g++-mp-5 FC=gfortran-mp-5 LDFLAGS=-L${env.MACPORTS}/lib CPPFLAGS=-I${env.MACPORTS}/include")
common.makeLibsAndCache()
common.buildGUI('')
common.partest()
}
common.buildOMC('cc', 'c++', '')
common.buildGUI('')
common.makeLibsAndCache()
common.partest()
}
}
}
Expand Down
23 changes: 15 additions & 8 deletions .CI/common.groovy
Expand Up @@ -56,7 +56,7 @@ void partest(cache=true, extraArgs='') {

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

void makeLibsAndCache(libs='core') {
Expand All @@ -68,7 +68,7 @@ void makeLibsAndCache(libs='core') {
sh "find libraries"
sh "ln -s '${env.LIBRARIES}/svn' '${env.LIBRARIES}/git' libraries/"
generateTemplates()
def cmd = "make -j${numLogicalCPU()} --output-sync omlibrary-${libs} ReferenceFiles omc-diff"
def cmd = "${makeCommand()} -j${numLogicalCPU()} --output-sync omlibrary-${libs} ReferenceFiles omc-diff"
if (env.SHARED_LOCK) {
lock(env.SHARED_LOCK) {
sh cmd
Expand All @@ -84,26 +84,28 @@ void buildOMC(CC, CXX, extraFlags) {
// 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}' make -j${numPhysicalCPU()} --output-sync omc omc-diff omsimulator"
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) {
standardSetup()
if (stash) {
standardSetup()
unstash stash
}
sh 'autoconf'
patchConfigStatus()
if (stash) {
patchConfigStatus()
}
sh 'CONFIG=`./config.status --config` && ./configure `eval $CONFIG`'
sh 'touch omc.skip omc-diff.skip ReferenceFiles.skip omsimulator.skip && make -q omc omc-diff ReferenceFiles omsimulator' // Pretend we already built omc since we already did so
sh "make -j${numPhysicalCPU()} --output-sync" // Builds the GUI files
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() {
patchConfigStatus()
// Runs Susan again, for bootstrapping tests, etc
sh 'make -C OMCompiler/Compiler/Template/ -f Makefile.in OMC=$PWD/build/bin/omc'
sh "${makeCommand()} -C OMCompiler/Compiler/Template/ -f Makefile.in OMC=\$PWD/build/bin/omc"
sh 'cd OMCompiler && ./config.status'
sh './config.status'
}
Expand Down Expand Up @@ -138,4 +140,9 @@ def tagName() {
return name == "master" ? "latest" : name
}

def makeCommand() {
// OSX uses gmake as the GNU make program
return env.GMAKE ?: "make"
}

return this
52 changes: 27 additions & 25 deletions OMCompiler/SimulationRuntime/cpp/CMakeLists.txt
Expand Up @@ -28,7 +28,7 @@
# if the equation systems of a FMU should be solved with sundials solvers -DFMU_SUNDIALS=ON [default: OFF]
# if the logger should be completely disabled or used -DUSE_LOGGER=OFF [default: ON]
# specify target platform for compilation -DPLATFORM=<dynamic, static or platform triple> [default: "dynamic"]
# use Klu sparse liner solver -DUSE_KLU [default: OFF]
# use Klu sparse liner solver -DUSE_KLU [default: OFF]
# use NOX non linear solver from trilinos library -DUSE_TRILINOS [default: OFF]
# Example: "cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo" to create statically linked libraries
#
Expand Down Expand Up @@ -552,32 +552,34 @@ IF(USE_SUNDIALS)
MESSAGE(STATUS "${SUNDIALS_LIBRARY_RELEASE_HOME}")


FIND_PATH(SUNDIALS_INCLUDE_DIR cvode/cvode.h PATHS ${SUNDIALS_INLCUDE_HOME})
IF (NOT SUNDIALS_INCLUDE_DIR)
SET(SUNDIALS_INCLUDE_DIR "${SUNDIALS_INLCUDE_HOME}")
IF (NOT EXISTS "${SUNDIALS_INLCUDE_HOME}/cvode/cvode.h")
MESSAGE(FATAL_ERROR "Could not find Sundials; compile omc first")
ELSE(NOT SUNDIALS_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${SUNDIALS_INCLUDE_DIR})
# Extract the version number from sundials_config.h
FIND_PATH(SUNDIALS_CONFIG_FILE "sundials_config.h" ${SUNDIALS_INCLUDE_DIR} "${SUNDIALS_INCLUDE_DIR}/sundials")
SET(SUNDIALS_CONFIG_FILE "${SUNDIALS_CONFIG_FILE}/sundials_config.h")
FILE(READ "${SUNDIALS_CONFIG_FILE}" SUNDIALS_CONFIG_FILE_CONTENT)
STRING(REGEX MATCH "#define SUNDIALS_PACKAGE_VERSION .([0-9]+)\\.([0-9]+)\\.([0-9]+)." SUNDIALS_CONFIG_FILE_CONTENT ${SUNDIALS_CONFIG_FILE_CONTENT})
STRING(REGEX REPLACE "#define SUNDIALS_PACKAGE_VERSION .([0-9]+)\\.([0-9]+)\\.([0-9]+)." "\\1;\\2;\\3" SUNDIALS_CONFIG_FILE_VERSION ${SUNDIALS_CONFIG_FILE_CONTENT})
LIST(GET SUNDIALS_CONFIG_FILE_VERSION 0 SUNDIALS_MAJOR_VERSION)
IF(SUNDIALS_MAJOR_VERSION)
ADD_DEFINITIONS("-DSUNDIALS_MAJOR_VERSION=${SUNDIALS_MAJOR_VERSION}")
ELSE()
MESSAGE(FATAL_ERROR "Could not determine sundials version")
ENDIF()
LIST(GET SUNDIALS_CONFIG_FILE_VERSION 1 SUNDIALS_MINOR_VERSION)
IF(SUNDIALS_MINOR_VERSION)
ADD_DEFINITIONS("-DSUNDIALS_MINOR_VERSION=${SUNDIALS_MINOR_VERSION}")
ELSE()
MESSAGE(FATAL_ERROR "Could not determine sundials version")
ENDIF()
LIST(GET SUNDIALS_CONFIG_FILE_VERSION 2 SUNDIALS_PATCH_VERSION)
MESSAGE(STATUS "Using sundials ${SUNDIALS_MAJOR_VERSION}.${SUNDIALS_MINOR_VERSION}.${SUNDIALS_PATCH_VERSION}")
ENDIF()
INCLUDE_DIRECTORIES(${SUNDIALS_INCLUDE_DIR})
# Extract the version number from sundials_config.h
SET(SUNDIALS_CONFIG_FILE "${SUNDIALS_INCLUDE_DIR}/sundials/sundials_config.h")
IF(NOT EXISTS "${SUNDIALS_CONFIG_FILE}")
MESSAGE(FATAL_ERROR "Could not find sundials_config.h")
ENDIF()
FILE(READ "${SUNDIALS_CONFIG_FILE}" SUNDIALS_CONFIG_FILE_CONTENT)
MESSAGE(STATUS "Found config file ${SUNDIALS_CONFIG_FILE}")
STRING(REGEX MATCH "#define SUNDIALS_PACKAGE_VERSION .([0-9]+)\\.([0-9]+)\\.([0-9]+)." SUNDIALS_CONFIG_FILE_CONTENT ${SUNDIALS_CONFIG_FILE_CONTENT})
STRING(REGEX REPLACE "#define SUNDIALS_PACKAGE_VERSION .([0-9]+)\\.([0-9]+)\\.([0-9]+)." "\\1;\\2;\\3" SUNDIALS_CONFIG_FILE_VERSION ${SUNDIALS_CONFIG_FILE_CONTENT})
LIST(GET SUNDIALS_CONFIG_FILE_VERSION 0 SUNDIALS_MAJOR_VERSION)
IF(SUNDIALS_MAJOR_VERSION)
ADD_DEFINITIONS("-DSUNDIALS_MAJOR_VERSION=${SUNDIALS_MAJOR_VERSION}")
ELSE()
MESSAGE(FATAL_ERROR "Could not determine sundials version")
ENDIF()
LIST(GET SUNDIALS_CONFIG_FILE_VERSION 1 SUNDIALS_MINOR_VERSION)
IF(SUNDIALS_MINOR_VERSION)
ADD_DEFINITIONS("-DSUNDIALS_MINOR_VERSION=${SUNDIALS_MINOR_VERSION}")
ELSE()
MESSAGE(FATAL_ERROR "Could not determine sundials version")
ENDIF()
LIST(GET SUNDIALS_CONFIG_FILE_VERSION 2 SUNDIALS_PATCH_VERSION)
MESSAGE(STATUS "Using sundials ${SUNDIALS_MAJOR_VERSION}.${SUNDIALS_MINOR_VERSION}.${SUNDIALS_PATCH_VERSION}")

FIND_LIBRARY(SUNDIALS_NVECSERIAL_LIB "sundials_nvecserial" NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH PATHS ${SUNDIALS_LIBRARY_RELEASE_HOME} $ENV{SUNDIALS_ROOT}/lib)
IF(NOT SUNDIALS_NVECSERIAL_LIB)
Expand Down

0 comments on commit 3e60c14

Please sign in to comment.