Skip to content

Commit

Permalink
jenkins: add option to set max number of threads
Browse files Browse the repository at this point in the history
  • Loading branch information
vvbandeira committed Mar 25, 2021
1 parent 5ffd104 commit ebf3b33
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
15 changes: 8 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pipeline {
agent any;
environment {
COMMIT_AUTHOR_EMAIL= sh (returnStdout: true, script: "git --no-pager show -s --format='%ae'").trim();
COMMIT_AUTHOR_EMAIL = sh (returnStdout: true, script: "git --no-pager show -s --format='%ae'").trim();
NUM_THREADS = 8
}
stages {
stage('Build and test') {
Expand All @@ -10,7 +11,7 @@ pipeline {
stages {
stage('Build centos7 gcc8') {
steps {
sh './etc/Build.sh';
sh './etc/Build.sh -threads=$NUM_THREADS';
}
}
stage('Test centos7 gcc8') {
Expand All @@ -35,7 +36,7 @@ pipeline {
stages {
stage('Build centos7 gcc8 without GUI') {
steps {
sh './etc/Build.sh -no-gui -dir=build-without-gui';
sh './etc/Build.sh -threads=$NUM_THREADS -no-gui -dir=build-without-gui';
}
}
}
Expand All @@ -44,7 +45,7 @@ pipeline {
stages{
stage('Build centos7 gcc8') {
steps {
sh './etc/DockerHelper.sh create -os=centos7 -target=builder -compiler=gcc';
sh './etc/DockerHelper.sh create -threads=$NUM_THREADS -os=centos7 -target=builder -compiler=gcc';
}
}
stage('Test centos7 gcc8') {
Expand All @@ -58,7 +59,7 @@ pipeline {
stages{
stage('Build centos7 clang7') {
steps {
sh './etc/DockerHelper.sh create -os=centos7 -target=builder -compiler=clang';
sh './etc/DockerHelper.sh create -threads=$NUM_THREADS -os=centos7 -target=builder -compiler=clang';
}
}
stage('Test centos7 clang7') {
Expand All @@ -72,7 +73,7 @@ pipeline {
stages{
stage('Build ubuntu20 gcc9') {
steps {
sh './etc/DockerHelper.sh create -os=ubuntu20 -target=builder -compiler=gcc';
sh './etc/DockerHelper.sh create -threads=$NUM_THREADS -os=ubuntu20 -target=builder -compiler=gcc';
}
}
stage('Test ubuntu20 gcc9') {
Expand All @@ -86,7 +87,7 @@ pipeline {
stages{
stage('Build ubuntu20 clang10') {
steps {
sh './etc/DockerHelper.sh create -os=ubuntu20 -target=builder -compiler=clang';
sh './etc/DockerHelper.sh create -threads=$NUM_THREADS -os=ubuntu20 -target=builder -compiler=clang';
}
}
stage('Test ubuntu20 clang10') {
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ COPY . /OpenROAD
WORKDIR /OpenROAD
ARG compiler=gcc
RUN ./etc/Build.sh -compiler=${compiler}
ARG numThreads=$(nproc)
RUN ./etc/Build.sh -compiler=${compiler} -threads=${numThreads}
9 changes: 8 additions & 1 deletion etc/DockerHelper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ usage: $0 [CMD] [OPTIONS]
'dev': os + packages to compile app
'builder': os + packages to compile app +
copy source code and build app
'runner': os + packages to run a compiled app
'runtime': os + packages to run a compiled app
-threads Max number of threads to use if compiling.
Default = \$(nproc)
-sha Use git commit sha as the tag image. Default is
'latest'.
-h -help Show this message and exits
Expand Down Expand Up @@ -67,6 +69,7 @@ _setup() {
fromImage="${org}/${os}-dev:${imageTag}"
context="."
buildArgs="--build-arg compiler=${compiler}"
buildArgs="--build-arg numThreads=${numThreads}"
imageName="${imageName}-${compiler}"
;;
"dev" )
Expand Down Expand Up @@ -150,6 +153,7 @@ os="centos7"
target="dev"
compiler="gcc"
useCommitSha="no"
numThreads="$(nproc)"

while [ "$#" -gt 0 ]; do
case "${1}" in
Expand All @@ -165,6 +169,9 @@ while [ "$#" -gt 0 ]; do
-target=* )
target="${1#*=}"
;;
-threads=* )
numThreads="${1#*=}"
;;
-sha )
useCommitSha=yes
;;
Expand Down
30 changes: 19 additions & 11 deletions etc/Installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,25 @@ EOF
exit "${1:-1}"
}

case "${1}" in
-run|-runtime)
option="runtime"
;;
-dev|-development)
option="dev"
;;
*)
echo "argument $1 not recognized" >&2
_help
esac
# default values, can be overwritten by cmdline args
while [ "$#" -gt 0 ]; do
case "${1}" in
-h|-help)
_help 0
;;
-run|-runtime)
option="runtime"
;;
-dev|-development)
option="dev"
;;
*)
echo "unknown option: ${1}" >&2
_help
;;
esac
shift 1
done

platform="$(uname -s)"
case "${platform}" in
Expand Down

0 comments on commit ebf3b33

Please sign in to comment.