Use the right directory for the csv file.
And return an error if absent.
Test: appcompat.sh
Bug: 77513322
(cherry picked from commit 3b23f7568077a10cb3dfd0bb7d1c5f4c035d65dc)
Change-Id: Iada6095a8a992805779993d48524f1654f523de9
Merged-In: I212df0f9eac323fa6b5e2cf272684a31bf14cdea
diff --git a/tools/veridex/appcompat.sh b/tools/veridex/appcompat.sh
index 46d62db9..99537a4 100755
--- a/tools/veridex/appcompat.sh
+++ b/tools/veridex/appcompat.sh
@@ -57,8 +57,20 @@
ANDROID_HOST_OUT=${OUT}/host/linux-x86
fi
+extra_flags=
+
+# If --api-flags is not passed directly, take it from the build.
+if [[ "$@" != "*--api-flags=*" ]]; then
+ file="${OUT}/soong/hiddenapi/hiddenapi-flags.csv"
+ if [ ! -f $file ]; then
+ echo "Missing API flags file $file"
+ exit 1
+ fi
+ extra_flags="--api-flags=$file"
+fi
+
${ANDROID_HOST_OUT}/bin/veridex \
--core-stubs=${PACKAGING}/core_dex_intermediates/classes.dex:${PACKAGING}/oahl_dex_intermediates/classes.dex \
- --api-flags=${PACKAGING}/hiddenapi-flags.csv \
+ $extra_flags \
$@