ALLOW_RULES_IN_PRODUCT_CONFIG

If ALLOW_RULES_IN_PRODUCT_CONFIG is set, pass it to kati via
.KATI_ALLOW_RULES, to issue warnings or errors about rules
during product configuration.

Test: CHECK_FOR_RULES=true ./build/make/tools/product_config/test.sh
Test: ALLOW_RULES_IN_PRODUCT_CONFIG=error m nothing
Test: ALLOW_RULES_IN_PRODUCT_CONFIG=warning m nothing
Test: m nothing
Change-Id: I35dd9ffe4ec71f97beaa8b8a2f10d80502088af2
This commit is contained in:
Joe Onorato 2021-02-21 22:22:13 -08:00
parent fbabf70394
commit 749c1955a2
3 changed files with 49 additions and 5 deletions

View file

@ -146,6 +146,11 @@ load_all_product_makefiles := true
endif
endif
ifneq ($(ALLOW_RULES_IN_PRODUCT_CONFIG),)
_product_config_saved_KATI_ALLOW_RULES := $(.KATI_ALLOW_RULES)
.KATI_ALLOW_RULES := $(ALLOW_RULES_IN_PRODUCT_CONFIG)
endif
ifeq ($(load_all_product_makefiles),true)
# Import all product makefiles.
$(call import-products, $(all_product_makefiles))
@ -172,6 +177,11 @@ $(foreach makefile,$(ARTIFACT_PATH_REQUIREMENT_PRODUCTS),\
)
endif
ifneq ($(ALLOW_RULES_IN_PRODUCT_CONFIG),)
.KATI_ALLOW_RULES := $(_saved_KATI_ALLOW_RULES)
_product_config_saved_KATI_ALLOW_RULES :=
endif
ifneq ($(filter dump-products, $(MAKECMDGOALS)),)
$(dump-products)
endif

View file

@ -38,7 +38,11 @@ public class OutputChecker {
"PRODUCTS\\..*\\.PRODUCT_ENFORCE_PACKAGES_EXIST_ALLOW_LIST",
// This is generated by this tool, but comes later in the make build system.
"INTERNAL_PRODUCT");
"INTERNAL_PRODUCT",
// This can be set temporarily by product_config.mk
".KATI_ALLOW_RULES"
);
private final FlatConfig mConfig;
private final TreeMap<String, Variable> mVariables;

View file

@ -52,14 +52,16 @@ failed_baseline_checks=
for product in $products ; do
for variant in $variants ; do
echo
echo Checking to see if $product-$variant works with make
TARGET_PRODUCT=$product TARGET_BUILD_VARIANT=$variant build/soong/soong_ui.bash --dumpvar-mode TARGET_PRODUCT &> /dev/null
echo "Checking: lunch $product-$variant"
TARGET_PRODUCT=$product \
TARGET_BUILD_VARIANT=$variant \
build/soong/soong_ui.bash --dumpvar-mode TARGET_PRODUCT &> /dev/null
exit_status=$?
if_signal_exit $exit_status
if [ $exit_status -ne 0 ] ; then
echo Combo fails with make, skipping product-config test run for $product-$variant
echo "*** Combo fails with make, skipping product-config test run for $product-$variant"
else
echo Running product-config for $product-$variant
rm -rf out/config/$product-$variant
TARGET_PRODUCT=$product TARGET_BUILD_VARIANT=$variant product-config \
--ckati_bin $CKATI_BIN \
@ -69,6 +71,28 @@ for product in $products ; do
if [ $exit_status -ne 0 ] ; then
failed_baseline_checks="$failed_baseline_checks $product-$variant"
fi
if [ "$CHECK_FOR_RULES" != "" ] ; then
# This is a little bit of sleight of hand for good output formatting at the
# expense of speed. We've already run the command once without
# ALLOW_RULES_IN_PRODUCT_CONFIG, so we know it passes there. We run it again
# with ALLOW_RULES_IN_PRODUCT_CONFIG=error to see if it fails, but that will
# cause it to only print the first error. But we want to see all of them,
# so if it fails we run it a third time with ALLOW_RULES_IN_PRODUCT_CONFIG=warning,
# so we can see all the warnings.
TARGET_PRODUCT=$product \
TARGET_BUILD_VARIANT=$variant \
ALLOW_RULES_IN_PRODUCT_CONFIG=error \
build/soong/soong_ui.bash --dumpvar-mode TARGET_PRODUCT &> /dev/null
exit_status=$?
if_signal_exit $exit_status
if [ $exit_status -ne 0 ] ; then
TARGET_PRODUCT=$product \
TARGET_BUILD_VARIANT=$variant \
ALLOW_RULES_IN_PRODUCT_CONFIG=warning \
build/soong/soong_ui.bash --dumpvar-mode TARGET_PRODUCT > /dev/null
failed_rule_checks="$failed_rule_checks $product-$variant"
fi
fi
fi
done
done
@ -88,3 +112,9 @@ for combo in $failed_baseline_checks ; do
echo " ... $combo"
done
echo -n "Rules checks "
if [ "$failed_rule_checks" = "" ] ; then echo PASSED ; else echo FAILED ; fi
for combo in $failed_rule_checks ; do
echo " ... $combo"
done