diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2018-08-23 12:15:09 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2018-08-27 11:16:41 +0300 |
commit | 854805140f0a9a50f8c8b727f0f25cdfe52da73b (patch) | |
tree | a10fa3ffd14bc354adbdd39a9c889ba0d69a8073 | |
parent | d297bf10ef89e97da30e1a00dd49560e18bcb3f0 (diff) | |
download | qtlocation-mapboxgl-upstream/standalone-build-script.tar.gz |
[build] add script to generate a standalone version of Mapbox GLupstream/standalone-build-script
-rw-r--r-- | cmake/mason.cmake | 4 | ||||
-rw-r--r-- | scripts/standalone.cmake | 18 | ||||
-rwxr-xr-x | scripts/standalone.sh | 68 |
3 files changed, 88 insertions, 2 deletions
diff --git a/cmake/mason.cmake b/cmake/mason.cmake index 76d02b95b5..c0795d962c 100644 --- a/cmake/mason.cmake +++ b/cmake/mason.cmake @@ -208,8 +208,8 @@ endif() mason_detect_platform() -# Execute commands if CMake is run in command mode -if (CMAKE_ARGC) +# Execute commands if CMake is run in command mode\ +if (CMAKE_ARGC AND "${CMAKE_SCRIPT_MODE_FILE}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}/mason.cmake") # Collect remaining arguments for passing to mason_use set(_MASON_ARGS) foreach(I RANGE 4 ${CMAKE_ARGC}) diff --git a/scripts/standalone.cmake b/scripts/standalone.cmake new file mode 100644 index 0000000000..b8bcbfa03f --- /dev/null +++ b/scripts/standalone.cmake @@ -0,0 +1,18 @@ +include(cmake/mason.cmake) + +# include once for every platform to get all dependency defines +set(MBGL_PLATFORM "android") +include(cmake/mason-dependencies.cmake) +set(MBGL_PLATFORM "ios") +include(cmake/mason-dependencies.cmake) + +get_cmake_property(_VARS VARIABLES) +foreach (_VAR ${_VARS}) + if (_VAR MATCHES "^MASON_PACKAGE_.+_NAME$") + set(_PACKAGE "${${_VAR}}") + if (MASON_PACKAGE_${_PACKAGE}_HEADER_ONLY) + file(RELATIVE_PATH _PREFIX "${CMAKE_CURRENT_LIST_DIR}/.." "${MASON_PACKAGE_${_PACKAGE}_PREFIX}") + message("${_PACKAGE} ${_PREFIX} ${MASON_PACKAGE_${_PACKAGE}_VERSION}") + endif() + endif() +endforeach() diff --git a/scripts/standalone.sh b/scripts/standalone.sh new file mode 100755 index 0000000000..68d15752d8 --- /dev/null +++ b/scripts/standalone.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +function usage { + echo "Usage: $0 <args> [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" |