#!/usr/bin/env bash set -e set -o pipefail cd "$(dirname "${BASH_SOURCE[0]}")/.." function usage { echo "Usage: $0 [target]" echo "" echo " -c, --clean-target Removes all files in the target directory instead of overwriting them" echo " -s, --skip [name] Skips vendoring the given dependency" exit 1 } CLEAN_TARGET=false ARGS=() while [[ $# -gt 0 ]] ; do case "$1" in -c|--clean-target) CLEAN_TARGET=true ; shift ;; -s|--skip) shift ; DEP="$1" ; shift ; declare SKIP_$DEP=true ;; *) ARGS+=("$1") ; shift ;; esac ; done set -- "${ARGS[@]}" if [ -z "$1" ]; then usage ; fi TARGET="$1" if [ "$CLEAN_TARGET" = true ] ; then echo ">> Cleaning target directory..." rm -rf "$TARGET" fi echo ">> Creating target directory..." mkdir -p "$TARGET" TARGET=$(cd "`pwd`/$TARGET"; pwd) echo ">> Copying source files..." rsync -rR $(git ls-files \ "include" \ "src" \ "platform/default" \ "platform/android/mbgl" \ "platform/android/src" \ "platform/android/MapboxGLAndroidSDK/src/main" \ ) "$TARGET" echo ">> Copying vendored files..." rsync -rR $(git ls-files \ "vendor/expected" \ "vendor/nunicode" \ ) "$TARGET" echo ">> Copying Mason dependencies..." cmake -DMASON_PLATFORM=android -P scripts/standalone.cmake 2>&1 | while read DEPENDENCY ; do DEPENDENCY=($DEPENDENCY) SKIP=SKIP_${DEPENDENCY[0]} if [ "${!SKIP:-false}" = true ]; then continue ; fi DESTINATION="$TARGET/vendor/${DEPENDENCY[0]}" mkdir -p "$DESTINATION" echo " - ${DEPENDENCY[0]}" cp -r "${DEPENDENCY[1]}/" "$DESTINATION" rm "$DESTINATION/mason.ini" echo "${DEPENDENCY[2]}" > "$DESTINATION/version.txt" done cp cmake/core-files.txt cmake/filesource-files.txt "$TARGET/src" cp platform/android/*-files.txt "$TARGET/platform/android"