Mercurial > hg > orthanc-object-storage
changeset 161:f7654d481226
created Aws/mingw-compile.sh
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 23 Jun 2024 15:12:06 +0200 |
parents | d3e7c86c3a4e |
children | 80657f326c68 |
files | .hgignore Aws/AwsStaticConfiguration.cmake Aws/README.txt Aws/aws-c-common-0.9.23.patch Aws/mingw-compile.sh Aws/mingw-compile/Dockerfile Aws/mingw-compile/build.sh |
diffstat | 7 files changed, 219 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sun Jun 23 10:53:40 2024 +0200 +++ b/.hgignore Sun Jun 23 15:12:06 2024 +0200 @@ -2,4 +2,6 @@ CMakeLists.txt.user* *~ */ThirdPartyDownloads/* -.vscode/ \ No newline at end of file +.vscode/ +*.orig +Aws/i/
--- a/Aws/AwsStaticConfiguration.cmake Sun Jun 23 10:53:40 2024 +0200 +++ b/Aws/AwsStaticConfiguration.cmake Sun Jun 23 15:12:06 2024 +0200 @@ -63,10 +63,34 @@ SET(AWS_C_CAL_URL "https://orthanc.uclouvain.be/downloads/third-party-downloads/aws/aws-c-cal-${AWS_C_CAL_VERSION}.tar.gz") DownloadPackage(${AWS_C_CAL_MD5} ${AWS_C_CAL_URL} "${AWS_C_CAL_SOURCES_DIR}") + SET(AWS_C_COMMON_SOURCES_DIR ${CMAKE_BINARY_DIR}/aws-c-common-${AWS_C_COMMON_VERSION}) SET(AWS_C_COMMON_URL "https://orthanc.uclouvain.be/downloads/third-party-downloads/aws/aws-c-common-${AWS_C_COMMON_VERSION}.tar.gz") + +if (IS_DIRECTORY "${AWS_C_COMMON_SOURCES_DIR}") + set(FirstRun OFF) +else() + set(FirstRun ON) +endif() + DownloadPackage(${AWS_C_COMMON_MD5} ${AWS_C_COMMON_URL} "${AWS_C_COMMON_SOURCES_DIR}") +if (FirstRun) + # This is a patch for MinGW + execute_process( + COMMAND ${PATCH_EXECUTABLE} -p0 -N -i + ${CMAKE_CURRENT_LIST_DIR}/aws-c-common-${AWS_C_COMMON_VERSION}.patch + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE Failure + ) + + if (Failure) + message(FATAL_ERROR "Error while patching a file") + endif() +endif() + + + SET(AWS_C_COMPRESSION_SOURCES_DIR ${CMAKE_BINARY_DIR}/aws-c-compression-${AWS_C_COMPRESSION_VERSION}) SET(AWS_C_COMPRESSION_URL "https://orthanc.uclouvain.be/downloads/third-party-downloads/aws/aws-c-compression-${AWS_C_COMPRESSION_VERSION}.tar.gz") DownloadPackage(${AWS_C_COMPRESSION_MD5} ${AWS_C_COMPRESSION_URL} "${AWS_C_COMPRESSION_SOURCES_DIR}") @@ -99,6 +123,10 @@ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} RESULT_VARIABLE Failure ) + + if (Failure) + message(FATAL_ERROR "Error while patching a file") + endif() endif() @@ -134,6 +162,10 @@ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} RESULT_VARIABLE Failure ) + + if (Failure) + message(FATAL_ERROR "Error while patching a file") + endif() endif()
--- a/Aws/README.txt Sun Jun 23 10:53:40 2024 +0200 +++ b/Aws/README.txt Sun Jun 23 15:12:06 2024 +0200 @@ -17,5 +17,23 @@ MinGW ===== -MinGW is not supported, at least not on Ubuntu <= 22.04, as AWS uses -C++17 constructions that are not available in gcc 10.x. +The minimum MinGW version to compile the AWS C++ SDK is 13.x. + +To build Windows 32 binaries: + +# ./mingw-compile.sh Release i686 +# ls ../mingw-binaries-i686/ + +To build Windows 64 binaries: + +# ./mingw-compile.sh Release x86_64 +# ls ../mingw-binaries-x86_64/ + + +Microsoft Visual Studio +======================= + +The minimum version to compile the AWS C++ SDK is Visual Studio 2015. + +WARNING: The binaries that are produced with Visual Studio currently +do not work. They write empty files to the S3 storage.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Aws/aws-c-common-0.9.23.patch Sun Jun 23 15:12:06 2024 +0200 @@ -0,0 +1,12 @@ +diff -urEb aws-c-common-0.9.23.orig/include/aws/common/byte_order.inl aws-c-common-0.9.23/include/aws/common/byte_order.inl +--- aws-c-common-0.9.23.orig/include/aws/common/byte_order.inl 2024-06-20 20:25:49.000000000 +0200 ++++ aws-c-common-0.9.23/include/aws/common/byte_order.inl 2024-06-23 14:55:38.563418806 +0200 +@@ -39,7 +39,7 @@ + uint64_t v; + __asm__("bswap %q0" : "=r"(v) : "0"(x)); + return v; +-#elif defined(_MSC_VER) ++#elif defined(_MSC_VER) || defined(__MINGW32__) + return _byteswap_uint64(x); + #else + uint32_t low = x & UINT32_MAX;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Aws/mingw-compile.sh Sun Jun 23 15:12:06 2024 +0200 @@ -0,0 +1,71 @@ +#!/bin/bash + +# Cloud storage plugins for Orthanc +# Copyright (C) 2020-2023 Osimis S.A., Belgium +# Copyright (C) 2024-2024 Orthanc Team SRL, Belgium +# Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, 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 -ex + + +if [ "$1" != "Debug" -a "$1" != "Release" ]; then + echo "Please provide build type as first argument: Debug or Release" + exit -1 +fi + +if [ "$2" != "i686" -a "$2" != "x86_64" ]; then + echo "Please provide architecture as second argument: i686 or x86_64" + exit -1 +fi + + +## +## Prepare a Docker container with mingw +## + +if [ -t 1 ]; then + # TTY is available => use interactive mode + DOCKER_FLAGS='-i' +fi + +ROOT_DIR=`dirname $(readlink -f $0)`/.. +IMAGE=orthanc-aws-mingw +TARGET=${ROOT_DIR}/mingw-binaries-$2/ + +if [ -e "${TARGET}" ]; then + echo "Target folder is already existing, aborting" + exit -1 +fi + +mkdir -p ${TARGET} + +( cd ${ROOT_DIR}/Aws/mingw-compile && \ + docker build -t ${IMAGE} . ) + + +## +## Build +## + +docker run -t ${DOCKER_FLAGS} --rm \ + --user $(id -u):$(id -g) \ + -v ${ROOT_DIR}/:/source:ro \ + -v ${TARGET}:/target:rw \ + ${IMAGE} \ + bash /source/Aws/mingw-compile/build.sh $1 $2 + +ls -lR ${TARGET}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Aws/mingw-compile/Dockerfile Sun Jun 23 15:12:06 2024 +0200 @@ -0,0 +1,31 @@ +# Cloud storage plugins for Orthanc +# Copyright (C) 2020-2023 Osimis S.A., Belgium +# Copyright (C) 2024-2024 Orthanc Team SRL, Belgium +# Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, 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/>. + + +# Debian 12.5 contains mingw 12.x, which is insufficient +# FROM debian:12.5 + +# Ubuntu 24.04 contains mingw 13.x, which is OK +FROM ubuntu:24.04 + +MAINTAINER Sebastien Jodogne <s.jodogne@gmail.com> +LABEL Description="Orthanc, free DICOM server" Vendor="The Orthanc project" + +RUN apt-get -y clean && apt-get -y update && \ + apt-get -y install cmake patch gcc-mingw-w64 g++-mingw-w64 unzip mercurial && \ + apt-get clean && rm -rf /var/lib/apt/lists/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Aws/mingw-compile/build.sh Sun Jun 23 15:12:06 2024 +0200 @@ -0,0 +1,50 @@ +# Cloud storage plugins for Orthanc +# Copyright (C) 2020-2023 Osimis S.A., Belgium +# Copyright (C) 2024-2024 Orthanc Team SRL, Belgium +# Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, 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 -ex + +if [ "$2" = "i686" ]; then + TOOLCHAIN=MinGW-W64-Toolchain32.cmake +elif [ "$2" = "x86_64" ]; then + TOOLCHAIN=MinGW-W64-Toolchain64.cmake +else + exit -1 +fi + + +mkdir /tmp/aws +mkdir /tmp/aws/Aws/ +mkdir /tmp/aws/Build/ + +# Ignore possible build directories in "Aws" folder +find /source/Aws/ -type f -maxdepth 1 | while read f +do + cp "$f" /tmp/aws/Aws/ +done + +cp -r /source/Common /tmp/aws/ +cp -r /source/UnitTestsSources /tmp/aws/ + +cd /tmp/aws/Build/ +cmake ../Aws -DCMAKE_BUILD_TYPE=Release -DUSE_VCPKG_PACKAGES=OFF -DSTATIC_BUILD=ON \ + -DCMAKE_TOOLCHAIN_FILE=/source/Common/Resources/Orthanc/Toolchains/${TOOLCHAIN} +make -j`nproc --all` + +cp ./libOrthancAwsS3Storage.dll /target +cp ./UnitTests.exe /target