Skip to content

Commit

Permalink
Merge pull request #203 from QIICR/standalone-packaging-rebased
Browse files Browse the repository at this point in the history
Standalone packaging
  • Loading branch information
fedorov authored Feb 20, 2017
2 parents e19f097 + 1fc94d1 commit 7f40682
Show file tree
Hide file tree
Showing 13 changed files with 209 additions and 67 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
build/
docker/dcmqi/dcmqi-linux/

*.[ao]
*~
*.swp
Expand Down
7 changes: 5 additions & 2 deletions CMakeExternals/DCMTK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ if(NOT DEFINED DCMTK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
INSTALL_COMMAND ""
CMAKE_ARGS
-DDCMTK_INSTALL_BINDIR:STRING=bin/${CMAKE_CFG_INTDIR}
-DDCMTK_INSTALL_LIBDIR:STRING=lib/${CMAKE_CFG_INTDIR}
-DDCMTK_INSTALL_LIBDIR:STRING=${DCMQI_INSTALL_LIB_DIR}
CMAKE_CACHE_ARGS
${ep_common_cache_args}
${ep_project_include_arg}
-DBUILD_SHARED_LIBS:BOOL=ON
-DBUILD_SHARED_LIBS:BOOL=OFF
-DDCMTK_WITH_DOXYGEN:BOOL=OFF
-DDCMTK_WITH_ZLIB:BOOL=OFF # see github issue #25
-DDCMTK_WITH_OPENSSL:BOOL=OFF # see github issue #25
Expand All @@ -71,6 +71,9 @@ if(NOT DEFINED DCMTK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
-DDCMTK_OVERWRITE_WIN32_COMPILER_FLAGS:BOOL=OFF
-DDCMTK_ENABLE_BUILTIN_DICTIONARY:BOOL=ON
-DDCMTK_ENABLE_PRIVATE_TAGS:BOOL=ON
USES_TERMINAL_DOWNLOAD 1
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
DEPENDS
${${proj}_DEPENDENCIES}
)
Expand Down
5 changes: 4 additions & 1 deletion CMakeExternals/ITK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if(NOT DEFINED ITK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
#-DITKGroup_IO:BOOL=ON
-DModule_ITKReview:BOOL=ON
-DModule_MGHIO:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=ON
-DBUILD_SHARED_LIBS:BOOL=OFF
-DITK_INSTALL_NO_DEVELOPMENT:BOOL=ON
-DKWSYS_USE_MD5:BOOL=ON # Required by SlicerExecutionModel
-DITK_WRAPPING:BOOL=OFF #${BUILD_SHARED_LIBS} ## HACK: QUICK CHANGE
Expand All @@ -79,6 +79,9 @@ if(NOT DEFINED ITK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INCLUDE_DIR}
-DZLIB_LIBRARY:FILEPATH=${ZLIB_LIBRARY}
${EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS}
USES_TERMINAL_DOWNLOAD 1
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
DEPENDS
${${proj}_DEPENDENCIES}
)
Expand Down
6 changes: 4 additions & 2 deletions CMakeExternals/SlicerExecutionModel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ if(NOT DEFINED SlicerExecutionModel_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM
-DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} # Unused
-DBUILD_SHARED_LIBS:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DITK_DIR:PATH=${ITK_DIR}
-DSlicerExecutionModel_LIBRARY_PROPERTIES:STRING=${DCMQI_LIBRARY_PROPERTIES}
-DSlicerExecutionModel_INSTALL_BIN_DIR:PATH=${DCMQI_INSTALL_BIN_DIR}
-DSlicerExecutionModel_INSTALL_LIB_DIR:PATH=${DCMQI_INSTALL_LIB_DIR}
#-DSlicerExecutionModel_INSTALL_SHARE_DIR:PATH=${Slicer_INSTALL_ROOT}share/${SlicerExecutionModel}
-DSlicerExecutionModel_INSTALL_NO_DEVELOPMENT:BOOL=${Slicer_INSTALL_NO_DEVELOPMENT}
-DSlicerExecutionModel_DEFAULT_CLI_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_BINARY_DIR}/${PROJECT_NAME_LC}-build/${DCMQI_INSTALL_BIN_DIR}
-DSlicerExecutionModel_DEFAULT_CLI_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_BINARY_DIR}/${PROJECT_NAME_LC}-build/${DCMQI_INSTALL_BIN_DIR}
-DSlicerExecutionModel_DEFAULT_CLI_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_BINARY_DIR}/${PROJECT_NAME_LC}-build/${DCMQI_INSTALL_LIB_DIR}
Expand All @@ -56,6 +55,9 @@ if(NOT DEFINED SlicerExecutionModel_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM
-DSlicerExecutionModel_DEFAULT_CLI_INSTALL_ARCHIVE_DESTINATION:STRING=${DCMQI_INSTALL_LIB_DIR}
-DSlicerExecutionModel_DEFAULT_CLI_TARGETS_FOLDER_PREFIX:STRING=Module-
${EXTERNAL_PROJECT_OPTIONAL_ARGS}
USES_TERMINAL_DOWNLOAD 1
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
INSTALL_COMMAND ""
DEPENDS
${${proj}_DEPENDENCIES}
Expand Down
4 changes: 4 additions & 0 deletions CMakeExternals/zlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ if(NOT DEFINED ZLIB_ROOT AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
-DCMAKE_C_FLAGS:STRING=${ep_common_c_flags}
-DZLIB_MANGLE_PREFIX:STRING=dcmqi_zlib_
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
USES_TERMINAL_DOWNLOAD 1
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
USES_TERMINAL_INSTALL 1
DEPENDS
${${proj}_DEPENDENCIES}
)
Expand Down
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,33 @@ endif()

if(DEFINED Slicer_DIR)
include(${Slicer_EXTENSION_CPACK})
else()
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${PROJECT_NAME};RuntimeLibraries;/")
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${DCMTK_DIR};DCMTK;shlib;/")
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ITK_DIR};ITK;RuntimeLibraries;/")
set(CPACK_PACKAGE_NAME "dcmqi")
set(CPACK_PACKAGE_VENDOR "Quantitative Image Informatics for Cancer Research (QIICR)")
set(CPACK_PACKAGE_VERSION_MAJOR ${DCMQI_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${DCMQI_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${DCMQI_PATCH_VERSION})
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CPACK_SYSTEM_NAME "mac")
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CPACK_SYSTEM_NAME "linux")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CPACK_SYSTEM_NAME win64)
else()
set(CPACK_SYSTEM_NAME win32)
endif()
endif()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_SYSTEM_NAME}")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${EXTENSION_DESCRIPTION})
if(UNIX)
set(CPACK_GENERATOR "TGZ")
elseif(WIN32)
set(CPACK_GENERATOR "ZIP")
endif()
include(CPack)
endif()
13 changes: 0 additions & 13 deletions Dockerfile

This file was deleted.

2 changes: 2 additions & 0 deletions SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ ExternalProject_Add(${proj}
SOURCE_DIR ${DCMQI_SOURCE_DIR}
BINARY_DIR ${DCMQI_BINARY_DIR}/${PROJECT_NAME_LC}-build
PREFIX ${PROJECT_NAME_LC}-prefix
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
INSTALL_COMMAND ""
DEPENDS
${DCMQI_DEPENDENCIES}
Expand Down
10 changes: 4 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ before_build:
- ps: |
$client = new-object System.Net.WebClient;
$client.DownloadFile("http://slicer.kitware.com/midas3/download/item/270309/dicom3tools_winexe_1.00.snapshot.20161218101718.zip", "C:\dicom3tools.zip")
$client.DownloadFile("https://github.com/fedorov/zlib/releases/download/zlib-dcmqi-1.2.3-VS12-Win64-Release/zlib-dcmqi.zip", "C:\zlib-dcmqi.zip")
$client.DownloadFile("https://github.com/QIICR/dcmtk/releases/download/DCMTK-dcmqi-3.6.1_20161102-VS12-Win64-Release-v0.0.8/DCMTK-dcmqi.zip", "C:\DCMTK-dcmqi.zip")
$client.DownloadFile("https://github.com/fedorov/ITK-dcmqi/releases/download/ITK-dcmqi-VS12-Win64-Release-v0.0.23/ITK-dcmqi.zip", "C:\ITK-dcmqi.zip")
$client.DownloadFile("https://github.com/qiicr/zlib-dcmqi/releases/download/zlib-dcmqi-1.2.3-VS12-Win64-Release-static/zlib-dcmqi.zip", "C:\zlib-dcmqi.zip")
$client.DownloadFile("https://github.com/qiicr/dcmtk-dcmqi/releases/download/DCMTK-dcmqi-3.6.1_20161102-VS12-Win64-Release-v0.0.11-static/DCMTK-dcmqi.zip", "C:\DCMTK-dcmqi.zip")
$client.DownloadFile("https://github.com/qiicr/ITK-dcmqi/releases/download/ITK-dcmqi-VS12-Win64-Release-v0.0.25-static/ITK-dcmqi.zip", "C:\ITK-dcmqi.zip")
# Extract
- |
7z x C:\dicom3tools.zip -oC:\dicom3tools
Expand Down Expand Up @@ -57,6 +57,4 @@ artifacts:
- path: dcmqi-build
name: dcmqi
type: zip
cache:
- C:\ProgramData\chocolatey\bin
- C:\ProgramData\chocolatey\lib

66 changes: 23 additions & 43 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,37 @@
machine:
# XXX: btrfs circleCI fix, see: https://github.com/docker/docker/issues/9939 and https://github.com/Sabayon/docker-stage3-base-amd64/commit/8c1bf737113a278dd2f
pre:
- sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.0-circleci'
- sudo chmod 0755 /usr/bin/docker
services:
- docker
python:
version: 2.7.11
dependencies:
cache_directories:
- "~/dcmqi-build/zlib"
- "~/dcmqi-build/zlib-build"
- "~/dcmqi-build/ITK"
- "~/dcmqi-build/ITK-build"
- "~/dcmqi-build/DCMTK"
- "~/dcmqi-build/DCMTK-build"
- "~/dcmqi-build/SlicerExecutionModel"
- "~/dcmqi-build/SlicerExecutionModel-build"
- dicom3tools_1.00.snapshot.20160721064406
pre:
# Install tools required to run DCMQI "doc" tests
- npm install jsonlint -g
- npm install ajv-cli -g
# Install xutils-dev package providing "imake"
- sudo apt-get update
- sudo apt-get install xutils-dev
# If needed, download and build dicom3tools
- |
dicom3tools_version=dicom3tools_1.00.snapshot.20160721064406
if [[ ! -e $dicom3tools_version ]]; then
wget --no-check-certificate http://slicer.kitware.com/midas3/download/item/270310/dicom3tools_1.00.snapshot.20160721064406.tar.bz2 -O dicom3tools.tar.bz2 \
&& tar xjf dicom3tools.tar.bz2 \
&& (cd $dicom3tools_version/ \
&& ./Configure \
&& imake -I./config -DUseQIICRID \
&& make -j$(grep -c processor /proc/cpuinfo) World > /dev/null 2>&1)
else
echo "Reusing "
fi
cd $dicom3tools_version && sudo make install
# Install Ninja
- wget --no-check-certificate https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip
- unzip ninja-linux.zip && sudo cp ninja /usr/local/bin/ && sudo chmod 755 /usr/local/bin/ninja
# Use scikit-ci-addons to streamline installation of CMake
- pip install scikit-ci-addons==0.11.0
- ci_addons circle/install_cmake 3.6.2
- "~/dcmqi/build"

post:
- mkdir -p ~/dcmqi-build && cd ~/dcmqi-build && cmake -G Ninja ../dcmqi && ninja
- cd docker && make dcmqi
# Install package required by convert.py
- pip install lxml==3.6.4
- |
cd ~/dcmqi-build/dcmqi-build && \
ctest -j4 -D ExperimentalTest -VV --no-compress-output && \
python ../../dcmqi/util/junit/convert.py \
~/dcmqi-build/dcmqi-build/ \
../../dcmqi/util/junit/conv.xsl > ~/dcmqi-build/BaseTest.xml
cd docker && make dcmqi.test && \
python ../util/junit/convert.py \
../build/dcmqi-build/ \
../util/junit/conv.xsl > ../build/BaseTest.xml
test:
post:
- mkdir -p ${CIRCLE_TEST_REPORTS}/junit
- cp ~/dcmqi-build/BaseTest.xml ${CIRCLE_TEST_REPORTS}/junit
- cp ~/dcmqi/build/BaseTest.xml ${CIRCLE_TEST_REPORTS}/junit

deployment:
release: # just a label
branch: master
commands:
- |
[ "$DOCKER_EMAIL" != "" ] \
&& docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS \
&& docker push qiicr/dcmqi:`git describe --exact-match 2> /dev/null || echo "latest"` \
|| echo "skipping docker push"
84 changes: 84 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#
# Parameters
#

# Name of the docker executable
DOCKER = docker

# Docker organization to pull the images from
ORG = qiicr

# Directories
ROOT_DIR = $(shell pwd)/..
BUILD_DIR = build
DOCKER_DIR = $(ROOT_DIR)/docker
TMP = /tmp

dicom3tools_version=dicom3tools_1.00.snapshot.20160721064406

#
# Targets
#

image: dcmqi dcmqi.test

# Pull dockcross image
prereq.pull_dockcross:
$(DOCKER) pull dockcross/manylinux-x64
$(DOCKER) run --rm dockcross/manylinux-x64 > $(TMP)/dockcross
chmod u+x $(TMP)/dockcross

# Download and build dicom3tools
prereq.build_dicom3tools: prereq.pull_dockcross
mkdir -p $(ROOT_DIR)/$(BUILD_DIR)
cd $(ROOT_DIR)/$(BUILD_DIR) \
&& [ ! -e $(dicom3tools_version) ] \
&& wget --no-check-certificate http://slicer.kitware.com/midas3/download/item/270310/dicom3tools_1.00.snapshot.20160721064406.tar.bz2 -O dicom3tools.tar.bz2 \
&& tar xjf dicom3tools.tar.bz2 \
&& cd $(dicom3tools_version)/ \
&& $(TMP)/dockcross ./Configure \
&& $(TMP)/dockcross imake -I./config -DUseQIICRID \
&& ( $(TMP)/dockcross make -j$(grep -c processor /proc/cpuinfo) World > /dev/null 2>&1 )\
|| echo "Reusing "

# Download and install "ajv" and "jsonlint" tools
prereq.install_npm_packages: prereq.pull_dockcross
mkdir -p $(ROOT_DIR)/$(BUILD_DIR)
# If needed, download node
cd $(ROOT_DIR)/$(BUILD_DIR) && \
[ ! -e node-v6.9.5-linux-x64 ] && \
wget --no-check-certificate https://nodejs.org/dist/v6.9.5/node-v6.9.5-linux-x64.tar.xz && \
tar xf node-v6.9.5-linux-x64.tar.xz || true
# Install tools required to run DCMQI "doc" tests
cd $(ROOT_DIR) && \
$(TMP)/dockcross bash -c "export PATH=/work/build/node-v6.9.5-linux-x64/bin:$$PATH && npm install jsonlint -g && npm install ajv-cli -g"

# Configure, build and package
dcmqi.generate_package: prereq.pull_dockcross
cd $(ROOT_DIR) && \
$(TMP)/dockcross cmake -B$(BUILD_DIR) -H. -GNinja -DCMAKE_BUILD_TYPE:STRING=Release && \
$(TMP)/dockcross bash -c "export PATH=/work/build/node-v6.9.5-linux-x64/bin:/work/build/$(dicom3tools_version)/appsrc/dcfile:$$PATH && ninja -C$(BUILD_DIR) -v" && \
$(TMP)/dockcross ninja -C$(BUILD_DIR)/dcmqi-build package

# Build "dcmqi" docker image
dcmqi.docker_image:
tar -xzvf $(ROOT_DIR)/$(BUILD_DIR)/dcmqi-build/dcmqi-linux.tar.gz -C $(DOCKER_DIR)/dcmqi
cd $(DOCKER_DIR) && \
docker build -t $(ORG)/dcmqi:`git describe --exact-match 2> /dev/null || echo "latest"` \
--build-arg IMAGE=$(ORG)/dcmqi \
--build-arg VCS_REF=`git describe --exact-match 2> /dev/null || git rev-parse --short HEAD` \
--build-arg VCS_URL=`git config --get remote.origin.url` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
dcmqi

dcmqi: prereq.build_dicom3tools prereq.install_npm_packages dcmqi.generate_package dcmqi.docker_image

dcmqi.test:
cd $(ROOT_DIR) && \
$(TMP)/dockcross bash -c "export PATH=/work/build/node-v6.9.5-linux-x64/bin:/work/build/$(dicom3tools_version)/appsrc/dcfile:/opt/python/cp27-cp27mu/bin/:$$PATH && cd /work/build/dcmqi-build && ctest -j4 -D ExperimentalTest -VV --no-compress-output"

dcmqi.clean:
rm -rf $(ROOT_DIR)/$(BUILD_DIR)
rm -rf $(DOCKER_DIR)/dcmqi/dcmqi-linux

.PHONY: image dcmqi dcmqi.% prereq.%
19 changes: 19 additions & 0 deletions docker/dcmqi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM centos:5
MAINTAINER http://github.com/QIICR

COPY imagefiles/docker_entry.sh /dcmqi/
COPY dcmqi-linux/bin/* /usr/bin/

WORKDIR /work
ENTRYPOINT ["/bin/bash","/dcmqi/docker_entry.sh"]

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
28 changes: 28 additions & 0 deletions docker/dcmqi/imagefiles/docker_entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

case "$1" in
itkimage2paramap|paramap2itkimage|itkimage2segimage|segimage2itkimage|tid1500reader|tid1500writer)
$1 "${@:2}"
;;
*)
echo "ERROR: Unknown command"
echo ""
cat >&2 <<ENDHELP
Usage: docker run [-v <HOST_DIR>:<CONTAINER_DIR>] qiicr/dcmqi <command> [args]
Run the given dcmqi *command*.
Available commands are:
itkimage2paramap
paramap2itkimage
itkimage2segimage
segimage2itkimage
tid1500reader
tid1500writer
For *command* help use: docker run qiicr/dcmqi <command> --help
ENDHELP
exit 1
;;
esac

0 comments on commit 7f40682

Please sign in to comment.