run-android: set build abis depending on connected devices abis

This commit is contained in:
Anton Iakimov 2023-08-24 16:09:43 +02:00
parent 2e63ee8baf
commit ebd38295c6
No known key found for this signature in database
GPG Key ID: DEA1FE58DD8BF7FA
2 changed files with 43 additions and 0 deletions

View File

@ -272,6 +272,8 @@ run-re-frisk: ##@run Start re-frisk server
# TODO: Migrate this to a Nix recipe, much the same way as nix/mobile/android/targets/release-android.nix
run-android: export TARGET := android
# INFO: If it's empty (no devices attached, parsing issues, script error) - for Nix it's the same as not set.
run-android: export ANDROID_ABI_INCLUDE ?= $(shell ./scripts/adb_devices_arch.sh)
run-android: ##@run Build Android APK and start it on the device
npx react-native run-android --appIdSuffix debug

41
scripts/adb_devices_abis.sh Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -e
typeset -a abis
SCRIPT_NAME=$(basename $0)
function log() {
echo "${SCRIPT_NAME} ${1}: ${2}" >&2
}
# make sure server is running, otherwise sdb will show devices offline
adb start-server
while IFS= read line; do
read -a arr <<< "${line}"
device_name="${arr[0]}"
device_status=${arr[1]}
log "DEBUG" "device_name=${device_name}"
log "DEBUG" "device_status=${device_status}"
if [[ "${device_status}" != "device" ]]; then
continue
fi
device_product_abi=$(adb -s ${device_name} shell -n getprop ro.product.cpu.abi)
log "DEBUG" "device_product_abi=${device_product_abi}"
if [[ ! ${abis[*]} =~ ${device_product_abi} ]]; then
abis+=("${device_product_abi}")
fi
done <<< "$(adb devices | tail -n+2)"
if [[ ! "${abis[*]}" ]]; then
log "ERROR" "no devices found. Check 'adb devices -l' output and share with Infra team if needed."
exit 3
fi
log "DEBUG" "resulting abis:"
IFS=\;; echo "${abis[*]}"