Commit c701a39e authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[bash-completion] Support some gm.py completion

Support the various combinations of arch-mode-target that gm.py
understands, and also completion of cctests.

Bug: v8:11567
No-Try: true
Change-Id: I05285a93253f4225889e949890f5352bbc173c91
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2774708
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73639}
parent 433bee6b
......@@ -118,3 +118,21 @@ _maybe_setup_gdb_completions() {
}
_maybe_setup_gdb_completions
unset _maybe_setup_gdb_completions
_get_gm_flags() {
"$v8_source/tools/dev/gm.py" --print-completions
# cctest ignore directory structure, it's always "cctest/filename".
find "$v8_source/test/cctest/" -type f -name 'test-*' | \
xargs basename -a -s ".cc" | \
while read -r item; do echo "cctest/$item/*"; done
}
_gm_flag() {
local targets=$(_get_gm_flags)
COMPREPLY=($(compgen -W "$targets" -- "${COMP_WORDS[COMP_CWORD]}"))
return 0
}
# gm might be an alias, based on https://v8.dev/docs/build-gn#gm.
complete -F _gm_flag gm.py gm
......@@ -170,6 +170,17 @@ def PrintHelpAndExit():
print(HELP)
sys.exit(0)
def PrintCompletionsAndExit():
for a in ARCHES:
print("%s" % a)
for m in MODES:
print("%s" % m)
print("%s.%s" % (a, m))
for t in TARGETS:
print("%s" % t)
print("%s.%s.%s" % (a, m, t))
sys.exit(0)
def _Call(cmd, silent=False):
if not silent: print("# %s" % cmd)
return subprocess.call(cmd, shell=True)
......@@ -377,6 +388,8 @@ class ArgumentParser(object):
def ParseArg(self, argstring):
if argstring in ("-h", "--help", "help"):
PrintHelpAndExit()
if argstring == "--print-completions":
PrintCompletionsAndExit()
arches = []
modes = []
targets = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment