Skip to content

Commit

Permalink
download libs: smarter common script
Browse files Browse the repository at this point in the history
  • Loading branch information
arturoc committed Oct 9, 2016
1 parent 13ca32a commit acbd8cf
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 55 deletions.
3 changes: 1 addition & 2 deletions scripts/android/download_libs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR
../dev/download_libs.sh -p android -a armv7 -o
../dev/download_libs.sh -p android -a x86
../dev/download_libs.sh -p android $@
120 changes: 93 additions & 27 deletions scripts/dev/download_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,35 @@ set -e
VER=master
PLATFORM=""
ARCH=""
OVERWRITE=0
OVERWRITE=1

while [[ $# -gt 1 ]]; do
printHelp(){
cat << EOF
Usage: download_libs.sh [OPTIONS]
Options:
-v, --version VERSION OF version to download the libraries for. Defaults to master
-p, --platform PLATFORM Platorm among: android, emscritpen, ios, linux, linux64, linuxarmv6l, linuxarmv7l, msys2, osx, tvos, vs
If not specified tries to autodetect the platform.
-a, --arch ARCH Architecture:
vs: 32 or 64
msys2: 32
android: armv7 or x86 (if not specified will download both)
linux: 64, armv6l or armv7l
-n, --no-overwrite Merge new libraries with exisiting ones, use only to download same version for different platforms
If not set deletes any existing libraries
-h, --help Shows this message
EOF
}

download(){
echo "Downloading $1"
wget ci.openframeworks.cc/libs/$1
}


while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-v|--version)
Expand All @@ -20,36 +46,74 @@ while [[ $# -gt 1 ]]; do
ARCH="$2"
shift # past argument
;;
-o|--overwrite)
OVERWRITE=1
-n|--no-overwrite)
OVERWRITE=0
;;
-h|--help)
printHelp
exit 0
;;
*)
# unknown option
echo "Error: invalid argument: $key"
printHelp
exit 1
;;
esac
shift # past argument or value
done

if [ "$PLATFORM" == "" ]; then
OS=$(uname)
if [ "$OS" == "Linux" ]; then
PLATFORM="linux"
elif [ "$OS" == "Darwin" ]; then
PLATFORM="osx"
else
# otherwise we are on windows and will download 32bit msys2
PLATFORM="msys2"
ARCH=32
fi
fi

if [ "$ARCH" == "" ]; then
if [ "$PLATFORM" == "linux" ]; then
ARCH=$(uname -m)
if [ "$ARCH" == "x86_64" ]; then
GCC_MAJOR_GT_4=$(expr `gcc -dumpversion | cut -f1 -d.` \> 4)
if [ $GCC_MAJOR_GT_4 -eq 1 ]; then
ARCH=64gcc5
else
ARCH=64
fi
elif [ "$ARCH" == "i686" ] || [ "$ARCH" == "i386" ]; then
echo "32bit linux is not officially supported anymore but compiling \
the libraries using the build script in apothecary/scripts \
should compile all the dependencies without problem"
exit 1
fi
elif [ "$PLATFORM" == "msys2" ]; then
ARCH=32
fi
fi

#VER=$1
#PLATFORM=$2
#ARCH=$3
#if [ $# -eq 4 ]; then
# OVERWRITE=$4
#else
# OVERWRITE=1
#fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR

if [ "$PLATFORM" == "msys2" ] || [ "$PLATFORM" == "vs" ]; then
PKG=openFrameworksLibs_${VER}_${PLATFORM}${ARCH}.zip
if [ "$ARCH" == "" ] && [ "$PLATFORM" == "vs" ]; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}32.zip openFrameworksLibs_${VER}_${PLATFORM}64.zip"
elif [ "$PLATFORM" == "msys2" ] || [ "$PLATFORM" == "vs" ]; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}${ARCH}.zip"
elif [ "$ARCH" == "" ] && [[ "$PLATFORM" == "osx" || "$PLATFORM" == "ios" || "$PLATFORM" == "tvos" ]]; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}1.tar.bz2 openFrameworksLibs_${VER}_${PLATFORM}2.tar.bz2"
elif [ "$ARCH" == "" ] && [ "$PLATFORM" == "android" ]; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}armv7.tar.bz2 openFrameworksLibs_${VER}_${PLATFORM}x86.tar.bz2"
else
PKG=openFrameworksLibs_${VER}_${PLATFORM}${ARCH}.tar.bz2
PKGS="openFrameworksLibs_${VER}_${PLATFORM}${ARCH}.tar.bz2"
fi
cd $SCRIPT_DIR
echo "Downloading $PKG from $PWD"
wget ci.openframeworks.cc/libs/$PKG

for PKG in $PKGS; do
download $PKG
done

cd ../../
mkdir -p libs
Expand All @@ -65,11 +129,13 @@ if [ $OVERWRITE -eq 1 ]; then
done
fi

echo "Uncompressing libraries $PLATFORM $ARCH"
if [ "$PLATFORM" == "msys2" ] || [ "$PLATFORM" == "vs" ]; then
unzip -qo ../scripts/dev/$PKG
else
tar xjf ../scripts/dev/$PKG
fi

rm ../scripts/dev/$PKG
for PKG in $PKGS; do
echo "Uncompressing libraries ${PLATFORM}${ARCH} from $PKG"
if [ "$PLATFORM" == "msys2" ] || [ "$PLATFORM" == "vs" ]; then
unzip -qo ../scripts/dev/$PKG
rm ../scripts/dev/$PKG
else
tar xjf ../scripts/dev/$PKG
rm ../scripts/dev/$PKG
fi
done
2 changes: 1 addition & 1 deletion scripts/emscripten/download_libs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR
../dev/download_libs.sh -p emscripten -o
../dev/download_libs.sh -p emscripten $@
6 changes: 2 additions & 4 deletions scripts/ios/download_libs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR
../dev/download_libs.sh -p tvos -a 1 -o
../dev/download_libs.sh -p tvos -a 2
../dev/download_libs.sh -p ios -a 1
../dev/download_libs.sh -p ios -a 2
../dev/download_libs.sh -p tvos -o
../dev/download_libs.sh -p ios
17 changes: 1 addition & 16 deletions scripts/linux/download_libs.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
#!/usr/bin/env bash
if [ $# -gt 0 ]; then
ARCH=$1
else
ARCH=$(uname -m)
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR

export LC_ALL=C
if [ "$ARCH" == "x86_64" ]; then
GCC_MAJOR_GT_4=$(expr `gcc -dumpversion | cut -f1 -d.` \> 4)
if [ $GCC_MAJOR_GT_4 -eq 1 ]; then
ARCH=64gcc5
else
ARCH=64
fi
fi
../dev/download_libs.sh -p linux -a $ARCH -o
../dev/download_libs.sh -p linux $@
2 changes: 1 addition & 1 deletion scripts/msys2/download_libs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR
../dev/download_libs.sh -p msys2 -a 32
../dev/download_libs.sh -p msys2 $@
3 changes: 1 addition & 2 deletions scripts/osx/download_libs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR
../dev/download_libs.sh -p osx -a 1 -o
../dev/download_libs.sh -p osx -a 2
../dev/download_libs.sh -p osx $@
3 changes: 1 addition & 2 deletions scripts/vs/download_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ cd $SCRIPT_DIR
if [ ! -z ${BITS+x} ]; then
../dev/download_libs.sh -p vs -a $BITS -o
else
../dev/download_libs.sh -p vs -a 32 -o
../dev/download_libs.sh -p vs -a 64
../dev/download_libs.sh -p vs $@
fi

0 comments on commit acbd8cf

Please sign in to comment.