summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-06-27 15:01:54 -0700
committerChris Loer <chris.loer@mapbox.com>2018-07-03 10:03:05 -0700
commit251f5e605f1f1bb3e56115f8cef66cacabfd9d83 (patch)
tree55c81152898be05016ed8a55e975e0998719191d /scripts
parent71a72d269a3f0de6f3cdb7780d2bf44f6a4e2c21 (diff)
downloadqtlocation-mapboxgl-251f5e605f1f1bb3e56115f8cef66cacabfd9d83.tar.gz
[core, vendor] Create vendored nunicode 1.8.
- Version bump to 1.8 necessary for "unaccent" functionality - Qt now depends on nunicode, ruling out use of precompiled binaries
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vendor/common.sh31
-rwxr-xr-xscripts/vendor/nunicode.sh70
2 files changed, 101 insertions, 0 deletions
diff --git a/scripts/vendor/common.sh b/scripts/vendor/common.sh
new file mode 100755
index 0000000000..3679152218
--- /dev/null
+++ b/scripts/vendor/common.sh
@@ -0,0 +1,31 @@
+
+set -eu
+
+VENDOR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../../vendor"; pwd)
+CXX=${CXX:-clang++}
+CC=${CC:-clang}
+
+function download {
+ if [ ! -f "$VENDOR/.cache/$NAME-$VERSION.tar.gz" ]; 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"
+ fi
+}
+
+function init {
+ rm -rf "$VENDOR/$NAME"
+ mkdir -p "$VENDOR/$NAME"
+ echo $VERSION > "$VENDOR/$NAME/version.txt"
+ cd "$VENDOR/$NAME"
+}
+
+function extract {
+ echo ">> Unpacking files from $VENDOR/.cache/$NAME-$VERSION.tar.gz..."
+ tar xzf "$VENDOR/.cache/$NAME-$VERSION.tar.gz" --strip-components=${STRIP_COMPONENTS:-1} -C "$VENDOR/$NAME" $@
+}
+
+function file_list {
+ (cd "$VENDOR/$NAME" && find $@ | sort > "$VENDOR/$NAME/files.txt")
+}
diff --git a/scripts/vendor/nunicode.sh b/scripts/vendor/nunicode.sh
new file mode 100755
index 0000000000..61a921cadd
--- /dev/null
+++ b/scripts/vendor/nunicode.sh
@@ -0,0 +1,70 @@
+#!/usr/bin/env bash
+source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
+
+NAME=nunicode
+VERSION=1.8
+ROOT=alekseyt-nunicode-246bb27014ab
+
+download "https://bitbucket.org/alekseyt/nunicode/get/$VERSION.tar.gz"
+init
+extract "$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
+cat <<CONFIG >> config.h
+
+// Hardcoded defines for vendored copy
+#define NU_WITH_UTF8
+#define NU_WITH_TOUPPER
+#define NU_WITH_TOLOWER
+#define NU_WITH_UNACCENT
+#define NU_WITH_Z_COLLATION
+CONFIG
+tail -n +3 libnu/config.h >> config.h
+mv config.h libnu/config.h
+
+# List all files we want to extract
+FILES=(
+ libnu/strcoll.h
+ libnu/strcoll.c
+
+ libnu/ducet.h
+ libnu/ducet.c
+
+ libnu/unaccent.h
+ libnu/tounaccent.c
+
+ libnu/casemap.h
+ libnu/toupper.c
+ libnu/tolower.c
+
+ libnu/strings.h
+ libnu/strings.c
+
+ libnu/utf8.h
+ libnu/utf8.c
+)
+
+# Find dependencies for all of these files
+echo ">> Finding dependencies..."
+ALL=()
+for FILE in "${FILES[@]}"; do
+ ALL+=($($CC -std=c11 -Ilibnu -c "$FILE" -M | sed -e 's/^[a-z0-9._-]*: *//;s/ *\\$//'))
+done
+
+# Remove duplicates
+IFS=$'\n' ALL=($(sort <<< "${ALL[*]}" | uniq | sed -n '/^libnu\//p'))
+unset IFS
+
+echo ">> Copying files..."
+
+mkdir -p include/libnu src/libnu/gen
+for FILE in "${ALL[@]}"; do
+ [[ "$FILE" = *.h ]] && DIR="include" || DIR="src"
+ # Copy file and replace #include "*.h" with #include <libnu/*.h> so that we can separate
+ # includes and source-only files.
+ sed 's/^#include \"\([^\"]*.h\)\"/#include <libnu\/\1>/' "$FILE" > "$DIR/$FILE"
+done
+
+rm -rf libnu
+file_list include src -name "*.h" -o -name "*.c" -not -path "*/gen/*"