changeset 224:8f30b077cdb8

compilation using holy-build-box
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 23 Jan 2020 18:59:52 +0100
parents c49107ed5af8
children 84815d39b14c
files CMakeLists.txt Resources/holy-build-box-compile.sh Resources/holy-build-box-internal.sh
diffstat 3 files changed, 82 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Thu Jan 23 18:19:28 2020 +0100
+++ b/CMakeLists.txt	Thu Jan 23 18:59:52 2020 +0100
@@ -24,10 +24,10 @@
 set(ORTHANC_PLUGIN_VERSION "mainline")
 
 if (ORTHANC_PLUGIN_VERSION STREQUAL "mainline")
-  set(ORTHANC_FRAMEWORK_VERSION "mainline")
+  set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "mainline")
   set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg")
 else()
-  set(ORTHANC_FRAMEWORK_VERSION "1.5.5")
+  set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "1.5.5")
   set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web")
 endif()
 
@@ -36,7 +36,8 @@
 set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
 set(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)")
 set(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
-set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc source code (can be \"hg\", \"archive\", \"web\" or \"path\")")
+set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc framework (can be \"hg\", \"archive\", \"web\" or \"path\")")
+set(ORTHANC_FRAMEWORK_VERSION "${ORTHANC_FRAMEWORK_DEFAULT_VERSION}" CACHE STRING "Version of the Orthanc framework")
 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"")
 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"")
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/holy-build-box-compile.sh	Thu Jan 23 18:59:52 2020 +0100
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+##
+## This script compiles cross-distribution Linux binaries thanks to
+## Holy Build Box: https://github.com/phusion/holy-build-box
+##
+## The ideal solution would be to use Linux Standard Base
+## (LSB). Unfortunately, the LSB C++ compiler is a pre-4.8 gcc that
+## does not feature full C++11 capabilities, which prevents compiling
+## GDCM >= 3.0.
+##
+
+set -ex
+
+if [ "$1" != "Debug" -a "$1" != "Release" ]; then
+    echo "Please provide build type: Debug or Release"
+    exit -1
+fi
+
+if [ -t 1 ]; then
+    # TTY is available => use interactive mode
+    DOCKER_FLAGS='-i'
+fi
+
+ROOT_DIR=`dirname $(readlink -f $0)`/..
+
+mkdir -p ${ROOT_DIR}/holy-build-box
+
+docker run -t ${DOCKER_FLAGS} --rm \
+    --user $(id -u):$(id -g) \
+    -v ${ROOT_DIR}:/source:ro \
+    -v ${ROOT_DIR}/holy-build-box:/target:rw \
+    phusion/holy-build-box-64:2.0.1 \
+    bash /source/Resources/holy-build-box-internal.sh $1
+
+ls -lR ${ROOT_DIR}/holy-build-box/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/holy-build-box-internal.sh	Thu Jan 23 18:59:52 2020 +0100
@@ -0,0 +1,42 @@
+#!/bin/bash
+set -e
+
+# Activate Holy Build Box environment.
+source /hbb_exe/activate
+
+set -x
+
+mkdir /tmp/build
+cd /tmp/build
+
+# Holy Build Box defines LDFLAGS as "-L/hbb_exe/lib
+# -static-libstdc++". The "-L/hbb_exe/lib" option results in linking
+# errors "undefined reference" to `std::__once_callable',
+# 'std::__once_call' and '__once_proxy'.
+export LDFLAGS=-static-libstdc++
+unset LDPATHFLAGS
+unset SHLIB_LDFLAGS
+unset LD_LIBRARY_PATH
+unset LIBRARY_PATH
+
+mkdir /tmp/source-writeable
+
+cp -r /source/CMakeLists.txt /tmp/source-writeable/
+cp -r /source/Plugin /tmp/source-writeable/
+cp -r /source/Resources /tmp/source-writeable/
+cp -r /source/UnitTestsSources /tmp/source-writeable/
+cp -r /source/WebApplication /tmp/source-writeable/
+
+cmake /tmp/source-writeable \
+    -DCMAKE_BUILD_TYPE=$1 -DSTATIC_BUILD=ON \
+    -DORTHANC_FRAMEWORK_SOURCE=web \
+    -DORTHANC_FRAMEWORK_VERSION=1.5.8 \
+    -DCMAKE_INSTALL_PREFIX=/target 
+
+make -j`nproc`
+
+if [ "$1" == "Release" ]; then
+    strip ./libOrthancWebViewer.so
+fi
+
+make install