1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-07 03:11:53 +01:00
workload-automation/wa/commands/templates/uiauto/uiauto_build_script
Marc Bonnici 75878e2f27 uiauto/build_scripts: Update to use python3
Ensure we are invoking python3 when attempting to import `wa` and
update the printing syntax to be compatible.
2019-09-06 11:02:13 +01:00

40 lines
1.1 KiB
Bash

#!/bin/bash
# CD into build dir if possible - allows building from any directory
script_path='.'
if `readlink -f $$0 &>/dev/null`; then
script_path=`readlink -f $$0 2>/dev/null`
fi
script_dir=`dirname $$script_path`
cd $$script_dir
# Ensure gradelw exists before starting
if [[ ! -f gradlew ]]; then
echo 'gradlew file not found! Check that you are in the right directory.'
exit 9
fi
# Copy base class library from wlauto dist
libs_dir=app/libs
base_class=`python3 -c "import os, wa; print(os.path.join(os.path.dirname(wa.__file__), 'framework', 'uiauto', 'uiauto.aar'))"`
mkdir -p $$libs_dir
cp $$base_class $$libs_dir
# Build and return appropriate exit code if failed
# gradle build
./gradlew clean :app:assembleDebug
exit_code=$$?
if [[ $$exit_code -ne 0 ]]; then
echo "ERROR: 'gradle build' exited with code $$exit_code"
exit $$exit_code
fi
# If successful move APK file to workload folder (overwrite previous)
rm -f ../$package_name
if [[ -f app/build/apk/$package_name.apk ]]; then
cp app/build/apk/$package_name.apk ../$package_name.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9
fi