summaryrefslogtreecommitdiffstats
path: root/.vars.rc.do
diff options
context:
space:
mode:
Diffstat (limited to '.vars.rc.do')
-rw-r--r--.vars.rc.do57
1 files changed, 57 insertions, 0 deletions
diff --git a/.vars.rc.do b/.vars.rc.do
new file mode 100644
index 0000000..f9ccc80
--- /dev/null
+++ b/.vars.rc.do
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+set -e
+
+unset ANDROID_SDK ANDROID_VER BUILD_TOOLS BUILD_TOOLS_VER JAVAC KEYSTORE KEYSTORE_ARGS KEYSTORE_PASS KOTLIN KOTLINC PLATFORM verbose
+
+ANDROID_VER=android-33-ext5
+BUILD_TOOLS_VER=33.0.2
+APKSIGNER_SIGN_ARGS=()
+
+if [ -e config.rc ]; then
+ redo-ifchange config.rc
+ . ./config.rc
+else
+ redo-ifcreate config.rc
+fi
+
+if [[ ! ( $BUILD_TOOLS || $PLATFORM ) && ! $ANDROID_SDK ]]; then
+ cat <<-"EOF" >&2
+ $BUILD_TOOLS or $PLATFORM unset without setting $ANDROID_SDK.
+ Either set both $BUILD_TOOLS and $PLATFORM or set $ANDROID_SDK.
+ EOF
+ exit 1
+fi
+
+BUILD_TOOLS=${BUILD_TOOLS-$ANDROID_SDK/build-tools/$BUILD_TOOLS_VER}
+PLATFORM=${PLATFORM-$ANDROID_SDK/platforms/$ANDROID_VER}
+KOTLIN=${KOTLIN-/usr/share/kotlin}
+
+KEYSTORE=${KEYSTORE-$HOME/.android/debug.keystore}
+KEYSTORE_PASS=${KEYSTORE_PASS-pass:android}
+
+check() {
+ what=$1
+ shift
+ for p do
+ if command -v "$p" >/dev/null 2>&1; then
+ command -v "$p"
+ return
+ fi
+ done
+ echo "$what not set or found" >&2
+ return 1
+}
+
+JAVAC=$(check '$JAVAC or javac' "$JAVAC" javac) || exit
+KOTLINC=$(check '$KOTLINC or kotlinc' "$KOTLINC" kotlinc) || exit
+
+{
+ printf "# generated by %s\n" "$0"
+ declare -p APKSIGNER_SIGN_ARGS BUILD_TOOLS JAVAC KEYSTORE KEYSTORE_PASS KOTLIN KOTLINC PLATFORM
+} >"$3"
+
+if [[ $verbose ]]; then
+ echo "# Configuration regenerated:" >&2
+ cat "$3" >&2
+fi
+# vim:ft=bash