check-flagged-apis.sh: speed up build step

Instead of building the entire SDK, explicitly build the
api-versions.xml files.

Bug: 334870672
Test: croot && build/tools/check-flagged-apis/check-flagged-apis.sh
Change-Id: Ib165c0acd4766ad3000aaf17220050d5e66ddf2c
diff --git a/tools/check-flagged-apis/check-flagged-apis.sh b/tools/check-flagged-apis/check-flagged-apis.sh
index 3399583..d93d04f 100755
--- a/tools/check-flagged-apis/check-flagged-apis.sh
+++ b/tools/check-flagged-apis/check-flagged-apis.sh
@@ -20,18 +20,27 @@
 source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../shell_utils.sh
 require_top
 
+PUBLIC_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_public_generated-api-versions.xml
+SYSTEM_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_system_generated-api-versions.xml
+SYSTEM_SERVER_XML_VERSONS=out/target/common/obj/PACKAGING/api_versions_system_server_generated-api-versions.xml
+MODULE_LIB_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_module_lib_generated-api-versions.xml
+
 function m() {
     $(gettop)/build/soong/soong_ui.bash --build-mode --all-modules --dir="$(pwd)" "$@"
 }
 
 function build() {
-    m sdk dist && m \
+    m \
         check-flagged-apis \
         all_aconfig_declarations \
         frameworks-base-api-current.txt \
         frameworks-base-api-system-current.txt \
         frameworks-base-api-system-server-current.txt \
-        frameworks-base-api-module-lib-current.txt
+        frameworks-base-api-module-lib-current.txt \
+        $PUBLIC_XML_VERSIONS \
+        $SYSTEM_XML_VERSIONS \
+        $SYSTEM_SERVER_XML_VERSONS \
+        $MODULE_LIB_XML_VERSIONS
 }
 
 function aninja() {
@@ -50,7 +59,7 @@
     check-flagged-apis \
         --api-signature $(path_to_api_signature_file "frameworks-base-api-current.txt") \
         --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
-        --api-versions $(gettop)/out/dist/data/api-versions.xml
+        --api-versions $PUBLIC_XML_VERSIONS
     (( errors += $? ))
 
     echo
@@ -58,7 +67,7 @@
     check-flagged-apis \
         --api-signature $(path_to_api_signature_file "frameworks-base-api-system-current.txt") \
         --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
-        --api-versions $(gettop)/out/dist/system-data/api-versions.xml
+        --api-versions $SYSTEM_XML_VERSIONS
     (( errors += $? ))
 
     echo
@@ -66,7 +75,7 @@
     check-flagged-apis \
         --api-signature $(path_to_api_signature_file "frameworks-base-api-system-server-current.txt") \
         --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
-        --api-versions $(gettop)/out/dist/system-server-data/api-versions.xml
+        --api-versions $SYSTEM_SERVER_XML_VERSONS
     (( errors += $? ))
 
     echo
@@ -74,7 +83,7 @@
     check-flagged-apis \
         --api-signature $(path_to_api_signature_file "frameworks-base-api-module-lib-current.txt") \
         --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
-        --api-versions $(gettop)/out/dist/module-lib-data/api-versions.xml
+        --api-versions $MODULE_LIB_XML_VERSIONS
     (( errors += $? ))
 
     return $errors