[build] add ability to extract zip files
This commit is contained in:
19
scripts/vendor/common.sh
vendored
19
scripts/vendor/common.sh
vendored
@@ -6,11 +6,11 @@ CXX=${CXX:-clang++}
|
||||
CC=${CC:-clang}
|
||||
|
||||
function download {
|
||||
if [ ! -f "$VENDOR/.cache/$NAME-$VERSION.tar.gz" ]; then
|
||||
if [ ! -f "$VENDOR/.cache/$NAME-$VERSION" ]; then
|
||||
echo ">> Downloading $1..."
|
||||
mkdir -p "$VENDOR/.cache"
|
||||
curl --retry 3 -f -S -L $1 -o "$VENDOR/.cache/$NAME-$VERSION.tar.gz.tmp"
|
||||
mv "$VENDOR/.cache/$NAME-$VERSION.tar.gz.tmp" "$VENDOR/.cache/$NAME-$VERSION.tar.gz"
|
||||
curl --retry 3 -f -S -L $1 -o "$VENDOR/.cache/$NAME-$VERSION.tmp"
|
||||
mv "$VENDOR/.cache/$NAME-$VERSION.tmp" "$VENDOR/.cache/$NAME-$VERSION"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -21,10 +21,17 @@ function init {
|
||||
cd "$VENDOR/$NAME"
|
||||
}
|
||||
|
||||
function extract {
|
||||
echo ">> Unpacking files from $VENDOR/.cache/$NAME-$VERSION.tar.gz..."
|
||||
function extract_gzip {
|
||||
echo ">> Unpacking files from $VENDOR/.cache/$NAME-$VERSION..."
|
||||
[ ! -z "$(tar --version | grep "GNU tar")" ] && WC="--wildcards" || WC=""
|
||||
tar xzf "$VENDOR/.cache/$NAME-$VERSION.tar.gz" $WC --strip-components=${STRIP_COMPONENTS:-1} -C "$VENDOR/$NAME" $@
|
||||
tar xzf "$VENDOR/.cache/$NAME-$VERSION" $WC --strip-components=${STRIP_COMPONENTS:-1} -C "$VENDOR/$NAME" $@
|
||||
}
|
||||
|
||||
function extract_zip {
|
||||
echo ">> Unpacking files from $VENDOR/.cache/$NAME-$VERSION..."
|
||||
unzip -qq "$VENDOR/.cache/$NAME-$VERSION" $@ -d "$VENDOR/.cache/staging"
|
||||
mv "$VENDOR/.cache/staging"/*/* "$VENDOR/$NAME"
|
||||
rm -rf "$VENDOR/.cache/staging"
|
||||
}
|
||||
|
||||
function file_list {
|
||||
|
||||
2
scripts/vendor/expected.sh
vendored
2
scripts/vendor/expected.sh
vendored
@@ -7,7 +7,7 @@ ROOT=expected-lite-$VERSION
|
||||
|
||||
download "https://github.com/martinmoene/expected-lite/archive/$VERSION.tar.gz"
|
||||
init
|
||||
extract "$ROOT/include" "$ROOT/LICENSE.txt"
|
||||
extract_gzip "$ROOT/include" "$ROOT/LICENSE.txt"
|
||||
mv include/nonstd/expected.hpp include
|
||||
rm -rf include/nonstd
|
||||
file_list include -name "*.hpp"
|
||||
|
||||
2
scripts/vendor/gtest.sh
vendored
2
scripts/vendor/gtest.sh
vendored
@@ -7,7 +7,7 @@ ROOT=googletest-release-1.8.0/googletest
|
||||
|
||||
download "https://github.com/google/googletest/archive/release-$VERSION.tar.gz"
|
||||
init
|
||||
STRIP_COMPONENTS=2 extract --exclude "gtest-all.cc" --exclude "gtest_main.cc" "$ROOT/include/*.h" "$ROOT/src" "$ROOT/LICENSE"
|
||||
STRIP_COMPONENTS=2 extract_gzip --exclude "gtest-all.cc" --exclude "gtest_main.cc" "$ROOT/include/*.h" "$ROOT/src" "$ROOT/LICENSE"
|
||||
|
||||
for FILE in $(find include src -name "*.h" -o -name "*.cc"); do
|
||||
sed -e 's/^#include \"src\/\([^\"]\{1,\}\)\"/#include "\1"/' \
|
||||
|
||||
2
scripts/vendor/nunicode.sh
vendored
2
scripts/vendor/nunicode.sh
vendored
@@ -7,7 +7,7 @@ ROOT=alekseyt-nunicode-246bb27014ab
|
||||
|
||||
download "https://bitbucket.org/alekseyt/nunicode/get/$VERSION.tar.gz"
|
||||
init
|
||||
extract "$ROOT/libnu/*.c" "$ROOT/libnu/*.h" "$ROOT/LICENSE"
|
||||
extract_gzip "$ROOT/libnu/*.c" "$ROOT/libnu/*.h" "$ROOT/LICENSE"
|
||||
|
||||
# Augment config.h with just the defines we need.
|
||||
head -n 2 libnu/config.h > config.h
|
||||
|
||||
Reference in New Issue
Block a user