From e26e45834d134693dd728f45cd9a76a08f91207f Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Thu, 10 Dec 2015 11:27:43 -0500 Subject: [PATCH 1/5] Delete build files after copying artifacts --- bin/compile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/compile b/bin/compile index cdfe807b..04695f1d 100755 --- a/bin/compile +++ b/bin/compile @@ -68,6 +68,10 @@ status "Copying binaries to 'bin'" mkdir -p $BUILD_DIR/.swift-bin find $BUILD_DIR/.build/release -type f -perm /a+x -exec cp {} $BUILD_DIR/.swift-bin \; +status "Cleaning up build files" +rm -rf $BUILD_DIR/.swift +rm -rf $BUILD_DIR/.build + # Setup application environment PROFILE_PATH="$BUILD_DIR/.profile.d/swift.sh" mkdir -p $BUILD_DIR/.profile.d From 51a282bffd7af5432fa572641b7c908d1efc7779 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Thu, 10 Dec 2015 11:38:02 -0500 Subject: [PATCH 2/5] Install Swift in the cache directory --- bin/compile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/compile b/bin/compile index 04695f1d..55bf0bde 100755 --- a/bin/compile +++ b/bin/compile @@ -34,7 +34,7 @@ BUILDPACK_PATH=$compile_buildpack_dir source $compile_buildpack_dir/compile-exte mkdir -p $CACHE_DIR # download and unpack swift -SWIFT_DIR=$BUILD_DIR/.swift +SWIFT_DIR=$CACHE_DIR/swift mkdir -p $SWIFT_DIR cd $SWIFT_DIR status "Installing Swift $SWIFT_VERSION" @@ -69,7 +69,6 @@ mkdir -p $BUILD_DIR/.swift-bin find $BUILD_DIR/.build/release -type f -perm /a+x -exec cp {} $BUILD_DIR/.swift-bin \; status "Cleaning up build files" -rm -rf $BUILD_DIR/.swift rm -rf $BUILD_DIR/.build # Setup application environment From 2cf694aeb4ecd50eb1c5368aa774310d9755e8a7 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Thu, 10 Dec 2015 12:12:29 -0500 Subject: [PATCH 3/5] Check cache for Swift and Clang before downloading --- bin/compile | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/bin/compile b/bin/compile index 55bf0bde..e0ed7031 100755 --- a/bin/compile +++ b/bin/compile @@ -34,24 +34,26 @@ BUILDPACK_PATH=$compile_buildpack_dir source $compile_buildpack_dir/compile-exte mkdir -p $CACHE_DIR # download and unpack swift -SWIFT_DIR=$CACHE_DIR/swift -mkdir -p $SWIFT_DIR -cd $SWIFT_DIR -status "Installing Swift $SWIFT_VERSION" -mkdir -p $SWIFT_NAME_VERSION -dependency=$($compile_buildpack_dir/compile-extensions/bin/download_dependency $SWIFT_NAME_VERSION.tar.gz /tmp) -echo "Downloaded Swift" | indent -tar xz -C $SWIFT_NAME_VERSION -f $dependency -SWIFT_PATH=$PWD/$(echo $SWIFT_NAME_VERSION/swift*) +if [[ ! -d "$CACHE_DIR/$SWIFT_VERSION" ]]; then + cd $CACHE_DIR + status "Installing Swift $SWIFT_VERSION" + mkdir -p $SWIFT_NAME_VERSION + dependency=$($compile_buildpack_dir/compile-extensions/bin/download_dependency $SWIFT_NAME_VERSION.tar.gz /tmp) + echo "Downloaded Swift" | indent + tar xz -C $SWIFT_NAME_VERSION -f $dependency +fi +SWIFT_PATH=$CACHE_DIR/$(echo $SWIFT_NAME_VERSION/swift*) # download and unpack clang -cd $CACHE_DIR -status "Installing Clang $CLANG_VERSION" -mkdir -p $CLANG_NAME_VERSION -dependency=$($compile_buildpack_dir/compile-extensions/bin/download_dependency $CLANG_NAME_VERSION.tar.xz /tmp) -echo "Downloaded Clang" | indent -echo $dependency | xz -d -c --files | tar x -C $CLANG_NAME_VERSION &> /dev/null -CLANG_PATH=$PWD/$(echo $CLANG_NAME_VERSION/clang*) +if [[ ! -d "$CACHE_DIR/$CLANG_NAME_VERSION" ]]; then + cd $CACHE_DIR + status "Installing Clang $CLANG_VERSION" + mkdir -p $CLANG_NAME_VERSION + dependency=$($compile_buildpack_dir/compile-extensions/bin/download_dependency $CLANG_NAME_VERSION.tar.xz /tmp) + echo "Downloaded Clang" | indent + echo $dependency | xz -d -c --files | tar x -C $CLANG_NAME_VERSION &> /dev/null +fi +CLANG_PATH=$CACHE_DIR/$(echo $CLANG_NAME_VERSION/clang*) export PATH="$SWIFT_PATH/usr/bin:$CLANG_PATH/bin:$PATH" From 761b394d3d742f390fdc889f3466825d586376c5 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Thu, 10 Dec 2015 12:16:29 -0500 Subject: [PATCH 4/5] Fix Swift cache path --- bin/compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index e0ed7031..42b2aac1 100755 --- a/bin/compile +++ b/bin/compile @@ -34,7 +34,7 @@ BUILDPACK_PATH=$compile_buildpack_dir source $compile_buildpack_dir/compile-exte mkdir -p $CACHE_DIR # download and unpack swift -if [[ ! -d "$CACHE_DIR/$SWIFT_VERSION" ]]; then +if [[ ! -d "$CACHE_DIR/$SWIFT_NAME_VERSION" ]]; then cd $CACHE_DIR status "Installing Swift $SWIFT_VERSION" mkdir -p $SWIFT_NAME_VERSION From 2c88ea6f61276c2d98ecef53b973252991a69e49 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Thu, 10 Dec 2015 14:57:34 -0500 Subject: [PATCH 5/5] Fix path when using cached Swift --- bin/compile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/compile b/bin/compile index 42b2aac1..e80981a1 100755 --- a/bin/compile +++ b/bin/compile @@ -32,10 +32,10 @@ source $compile_buildpack_dir/bin/common.sh BUILDPACK_PATH=$compile_buildpack_dir source $compile_buildpack_dir/compile-extensions/lib/common mkdir -p $CACHE_DIR +cd $CACHE_DIR # download and unpack swift if [[ ! -d "$CACHE_DIR/$SWIFT_NAME_VERSION" ]]; then - cd $CACHE_DIR status "Installing Swift $SWIFT_VERSION" mkdir -p $SWIFT_NAME_VERSION dependency=$($compile_buildpack_dir/compile-extensions/bin/download_dependency $SWIFT_NAME_VERSION.tar.gz /tmp) @@ -46,7 +46,6 @@ SWIFT_PATH=$CACHE_DIR/$(echo $SWIFT_NAME_VERSION/swift*) # download and unpack clang if [[ ! -d "$CACHE_DIR/$CLANG_NAME_VERSION" ]]; then - cd $CACHE_DIR status "Installing Clang $CLANG_VERSION" mkdir -p $CLANG_NAME_VERSION dependency=$($compile_buildpack_dir/compile-extensions/bin/download_dependency $CLANG_NAME_VERSION.tar.xz /tmp)