Mercurial > hg > orthanc-object-storage
changeset 58:37185ec1cf49
holy build box for S3
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 22 Jun 2021 17:43:53 +0200 |
parents | ba1be668e475 |
children | f3c44d61e1e1 |
files | Aws/holy-build-box-compile.sh Aws/holy-build-box-internal.sh |
diffstat | 2 files changed, 120 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Aws/holy-build-box-compile.sh Tue Jun 22 17:43:53 2021 +0200 @@ -0,0 +1,60 @@ +#!/bin/bash + +# Cloud storage plugins for Orthanc +# Copyright (C) 2020-2021 Osimis S.A., Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +## +## 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 +## AWS SDK. +## + +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)`/.. + +DOCKER_IMAGE=phusion/holy-build-box-64:3.0.0 + +mkdir -p ${ROOT_DIR}/holy-build-box + +# Mapping "/etc/passwd" and "/etc/group" is necessary, otherwise git +# fails with error: "fatal: unable to look up current user in the +# passwd file: no such user" +docker run -t ${DOCKER_FLAGS} --rm \ + --user $(id -u):$(id -g) \ + -v /etc/passwd:/etc/passwd:ro \ + -v /etc/group:/etc/group:ro \ + -v ${ROOT_DIR}:/source:ro \ + -v ${ROOT_DIR}/holy-build-box:/target:rw \ + ${DOCKER_IMAGE} \ + bash /source/Aws/holy-build-box-internal.sh $1 + +ls -lR ${ROOT_DIR}/holy-build-box/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Aws/holy-build-box-internal.sh Tue Jun 22 17:43:53 2021 +0200 @@ -0,0 +1,60 @@ +#!/bin/bash + +# Cloud storage plugins for Orthanc +# Copyright (C) 2020-2021 Osimis S.A., Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +set -e + +# Activate Holy Build Box environment. +source /hbb_exe/activate + +set -ex + +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 -p /tmp/source-writeable/Aws + +cp -r /source/Common /tmp/source-writeable/ +cp -r /source/UnitTestsSources /tmp/source-writeable/ +cp /source/Aws/* /tmp/source-writeable/Aws/ || true # Ignore error about omitting directories + +cmake /tmp/source-writeable/Aws/ \ + -DORTHANC_FRAMEWORK_SOURCE=web \ + -DCMAKE_BUILD_TYPE=$1 -DSTATIC_BUILD=ON + +# Use only 2 processes (not `nproc`), as this is a very heavy compilation +make -j2 + +./UnitTests + +if [ "$1" == "Release" ]; then + strip ./libOrthancAwsS3Storage.so +fi + +cp ./libOrthancAwsS3Storage.so /target/ +cp ./UnitTests /target/