Merge "Speed up m command autocompletion" am: a56bce6ef1

Original change: https://android-review.googlesource.com/c/platform/build/+/2272251

Change-Id: I5c617649b184c2e48962993e38d88bd9b0755c87
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2022-10-28 21:20:31 +00:00
committed by Automerger Merge Worker
2 changed files with 10 additions and 6 deletions

View File

@@ -41,3 +41,9 @@ droidcore-unbundled: $(MODULE_INFO_JSON)
$(call dist-for-goals, general-tests, $(MODULE_INFO_JSON))
$(call dist-for-goals, droidcore-unbundled, $(MODULE_INFO_JSON))
# On every build, generate an all_modules.txt file to be used for autocompleting
# the m command. After timing this using $(shell date +"%s.%3N"), it only adds
# 0.01 seconds to the internal master build, and will only rerun on builds that
# rerun kati.
$(file >$(PRODUCT_OUT)/all_modules.txt,$(subst $(space),$(newline),$(ALL_MODULES)))

View File

@@ -1551,12 +1551,10 @@ function verifymodinfo() {
fi
}
# List all modules for the current device, as cached in module-info.json. If any build change is
# made and it should be reflected in the output, you should run 'refreshmod' first.
# List all modules for the current device, as cached in all_modules.txt. If any build change is
# made and it should be reflected in the output, you should run `m nothing` first.
function allmod() {
verifymodinfo || return 1
python3 -c "import json; print('\n'.join(sorted(json.load(open('$ANDROID_PRODUCT_OUT/module-info.json')).keys())))"
cat $ANDROID_PRODUCT_OUT/all_modules.txt 2>/dev/null
}
# Return the Bazel label of a Soong module if it is converted with bp2build.
@@ -1735,7 +1733,7 @@ function installmod() {
function _complete_android_module_names() {
local word=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(QUIET_VERIFYMODINFO=true allmod | grep -E "^$word") )
COMPREPLY=( $(allmod | grep -E "^$word") )
}
# Print colored exit condition