Skip to content

Commit

Permalink
ENH: Split testing data tarball form source tarball.
Browse files Browse the repository at this point in the history
This is based off VTK:

  https://gitlab.kitware.com/vtk/vtk/commit/bf5cf3cf8f

but a single data tarball is generated.  The source and data tarballs are
split, and the data can be extracted in the source tree.  BUILD_TESTING is OFF
by default in the source tarball when the testing data is not present.

Suggested-by: Brad King <brad.king@kitware.com>

ITK-3355

Change-Id: I96fb33d20ca832d6ec14b52e44625185a4e68bd8
  • Loading branch information
thewtex committed Jun 1, 2015
1 parent 4bcaa24 commit c01ad3b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .ExternalData/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.ExternalData
=============

The ITK ``.ExternalData`` directory is an object store for the
CMake ExternalData module that ITK uses to manage test input
and baseline data.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,18 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ITK_REQUIRED_LINK_FLAGS}
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${ITK_REQUIRED_LINK_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${ITK_REQUIRED_LINK_FLAGS}")

#-----------------------------------------------------------------------------
if(NOT EXISTS "${ITK_SOURCE_DIR}/.ExternalData/README.rst")
# This file is always present in version-controlled source trees
# so we must have been extracted from a source tarball with no
# data objects needed for testing. Turn off tests by default
# since enabling them requires network access or manual data
# store configuration.
option(BUILD_TESTING "Build the testing tree." OFF)
endif()
include(CTest)

include( CppcheckTargets )
include(CppcheckTargets)

# Setup build locations.
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
Expand Down
41 changes: 31 additions & 10 deletions Utilities/Maintenance/SourceTarball.bash
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,39 @@ index_data_objects() {
}

load_data_objects() {
find_data_objects "$1" |
find_data_objects "$@" |
index_data_objects
return_pipe_status
}

load_data_files() {
git ls-tree -r "$1" -- '.ExternalData' |
git update-index --index-info
return_pipe_status
}

git_archive_tgz() {
out="$2.tar.gz" && tmp="$out.tmp$$" &&
git -c core.autocrlf=false archive $verbose --format=tar --prefix=$2/ $1 |
if test -n "$3"; then prefix="$3"; else prefix="$2"; fi &&
git -c core.autocrlf=false archive $verbose --format=tar --prefix=$prefix/ $1 |
gzip -9 > "$tmp" &&
mv "$tmp" "$out" &&
info "Wrote $out"
}

git_archive_txz() {
out="$2.tar.xz" && tmp="$out.tmp$$" &&
git -c core.autocrlf=false archive $verbose --format=tar --prefix=$2/ $1 |
if test -n "$3"; then prefix="$3"; else prefix="$2"; fi &&
git -c core.autocrlf=false archive $verbose --format=tar --prefix=$prefix/ $1 |
xz -9 > "$tmp" &&
mv "$tmp" "$out" &&
info "Wrote $out"
}

git_archive_zip() {
out="$2.zip" && tmp="$out.tmp$$" &&
git -c core.autocrlf=true archive $verbose --format=zip --prefix=$2/ $1 > "$tmp" &&
if test -n "$3"; then prefix="$3"; else prefix="$2"; fi &&
git -c core.autocrlf=true archive $verbose --format=zip --prefix=$prefix/ $1 > "$tmp" &&
mv "$tmp" "$out" &&
info "Wrote $out"
}
Expand Down Expand Up @@ -156,18 +165,30 @@ fi

# Create temporary git index to construct source tree
export GIT_INDEX_FILE="$(pwd)/tmp-$$-index" &&
trap "rm -rf '$GIT_INDEX_FILE'" EXIT &&
trap "rm -f '$GIT_INDEX_FILE'" EXIT &&

info "Loading tree from $commit..." &&
result=0 &&

info "Loading source tree from $commit..." &&
rm -f "$GIT_INDEX_FILE" &&
git read-tree -m -i $commit &&
git rm -rf -q --cached '.ExternalData' &&
tree=$(git write-tree) &&

info "Generating source archive(s)..." &&
for fmt in $formats; do
git_archive_$fmt $tree "InsightToolkit-$version" || result=1
done &&

info "Loading data for $commit..." &&
rm -f "$GIT_INDEX_FILE" &&
load_data_objects $commit &&

info "Generating source archive..." &&
load_data_files $commit &&
tree=$(git write-tree) &&
result=0 &&

info "Generating data archive(s)..." &&
for fmt in $formats; do
git_archive_$fmt $tree "InsightToolkit-$version" || result=1
git_archive_$fmt $tree "InsightData-$version" "InsightToolkit-$version" || result=1
done &&

exit $result

0 comments on commit c01ad3b

Please sign in to comment.