diff options
Diffstat (limited to '.vars.rc.do')
-rwxr-xr-x[-rw-r--r--] | .vars.rc.do | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/.vars.rc.do b/.vars.rc.do index f9ccc80..8cddd9e 100644..100755 --- a/.vars.rc.do +++ b/.vars.rc.do @@ -1,11 +1,20 @@ #!/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 +unset ANDROID_SDK BUILD_TOOLS BUILD_TOOLS_VER JAVAC KEYSTORE KEYSTORE_ARGS \ + KEYSTORE_PASS KOTLINC MANIFEST MAVEN_REPO MIN_SDK_VER PLATFORM \ + TARGET_SDK_VER verbose -ANDROID_VER=android-33-ext5 +MANIFEST=AndroidManifest.xml +redo-ifchange "$MANIFEST" +MIN_SDK_VER=$(xmllint --xpath "string(/manifest/uses-sdk/@*[local-name()='minSdkVersion'])" "$MANIFEST") +TARGET_SDK_VER=$(xmllint --xpath "string(/manifest/uses-sdk/@*[local-name()='targetSdkVersion'])" "$MANIFEST") BUILD_TOOLS_VER=33.0.2 APKSIGNER_SIGN_ARGS=() +D8_ARGS=(--min-api "$MIN_SDK_VER") +declare -A MAVEN_REPO +MAVEN_REPO[central]=https://repo1.maven.org/maven2 +MAVEN_REPO[google]=https://dl.google.com/dl/android/maven2 if [ -e config.rc ]; then redo-ifchange config.rc @@ -23,8 +32,7 @@ if [[ ! ( $BUILD_TOOLS || $PLATFORM ) && ! $ANDROID_SDK ]]; then fi BUILD_TOOLS=${BUILD_TOOLS-$ANDROID_SDK/build-tools/$BUILD_TOOLS_VER} -PLATFORM=${PLATFORM-$ANDROID_SDK/platforms/$ANDROID_VER} -KOTLIN=${KOTLIN-/usr/share/kotlin} +PLATFORM=${PLATFORM-$ANDROID_SDK/platforms/android-$TARGET_SDK_VER} KEYSTORE=${KEYSTORE-$HOME/.android/debug.keystore} KEYSTORE_PASS=${KEYSTORE_PASS-pass:android} @@ -46,8 +54,22 @@ JAVAC=$(check '$JAVAC or javac' "$JAVAC" javac) || exit KOTLINC=$(check '$KOTLINC or kotlinc' "$KOTLINC" kotlinc) || exit { + d8() ( + set -e + android=$PLATFORM/android.jar d8_jar=$BUILD_TOOLS/lib/d8.jar + dest=$1 + shift + redo-ifchange "$d8_jar" "$android" + tmp=$(mktemp -d) + trap 'rm -rf "$tmp"' EXIT + java -Xmx2G -cp "$d8_jar" com.android.tools.r8.D8 "${D8_ARGS[@]}" \ + --classpath "$android" --output "$tmp" "$@" + mv "$tmp/classes.dex" "$dest" + ) printf "# generated by %s\n" "$0" - declare -p APKSIGNER_SIGN_ARGS BUILD_TOOLS JAVAC KEYSTORE KEYSTORE_PASS KOTLIN KOTLINC PLATFORM + declare -p APKSIGNER_SIGN_ARGS BUILD_TOOLS D8_ARGS JAVAC KEYSTORE \ + KEYSTORE_PASS KOTLINC MANIFEST MAVEN_REPO PLATFORM + declare -fp d8 } >"$3" if [[ $verbose ]]; then |