@@ -8,7 +8,8 @@ helpFunction() {
88 echo -e " \t-o Optional output path with the expected name of the aar file"
99 echo -e " \t-r Flag to build in release mode"
1010 echo -e " \t-m Option to select the gradle module to build. Default is sdk"
11- echo -e " \t-t Option to to select an android target to build against. Default will build for all targets."
11+ echo -e " \t-t Select a target architecture to build for. Default will build for all known Android targets."
12+ echo -e " \t-l Build for the local architecture. Incompatible with '-t'."
1213 exit 1
1314}
1415
@@ -20,14 +21,16 @@ scripts_dir=$(
2021is_release=' false'
2122gradle_module=' sdk'
2223only_target=' '
24+ local_target=' '
2325output=' '
2426
25- while getopts ' :rp:m:t:o :' ' opt' ; do
27+ while getopts ' :rp:m:t:lo :' ' opt' ; do
2628 case ${opt} in
2729 ' r' ) is_release=' true' ;;
2830 ' p' ) sdk_path=" $OPTARG " ;;
2931 ' m' ) gradle_module=" $OPTARG " ;;
3032 ' t' ) only_target=" $OPTARG " ;;
33+ ' l' ) local_target=' true' ;;
3134 ' o' ) output=" $OPTARG " ;;
3235 ? ) helpFunction ;;
3336 esac
@@ -38,6 +41,17 @@ if [ -z "$sdk_path" ]; then
3841 helpFunction
3942fi
4043
44+ if [ -n " $local_target " ]; then
45+ if [ -n " $only_target " ]; then
46+ echo " Cannot specifiy both '-l' and '-t'." >&2
47+ exit 1
48+ fi
49+
50+ only_target=" $( uname -m) -linux-android"
51+ # On ARM MacOS, `uname -m` returns arm64, but the toolchain is called aarch64
52+ only_target=" ${only_target/ arm64/ aarch64} "
53+ fi
54+
4155if [ -z " $only_target " ]; then
4256 echo " no target provided, build for all targets"
4357 target_command=()
5367
5468if [ " $gradle_module " = " crypto" ]; then
5569 # # NDK is needed for https://crates.io/crates/olm-sys
56- if [ -z " $ANDROID_NDK " ]; then
70+ if [ -z " $ANDROID_NDK " && -z " $ANDROID_HOME " ]; then
5771 echo " please set the ANDROID_NDK environment variable to your Android NDK installation"
5872 exit 1
5973 fi
@@ -80,9 +94,10 @@ shift $((OPTIND - 1))
8094
8195moveFunction () {
8296 if [ -z " $output " ]; then
83- echo " No output path provided, keep the generated path "
97+ echo -e " \nSUCCESS: Output AAR file is ' $1 ' "
8498 else
8599 mv " $1 " " $output "
100+ echo -e " \nSUCCESS: Output AAR file is '$output '"
86101 fi
87102}
88103
0 commit comments