[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: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#73639}
This commit is contained in:
parent
433bee6bc2
commit
c701a39e34
@ -118,3 +118,21 @@ _maybe_setup_gdb_completions() {
|
|||||||
}
|
}
|
||||||
_maybe_setup_gdb_completions
|
_maybe_setup_gdb_completions
|
||||||
unset _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)
|
print(HELP)
|
||||||
sys.exit(0)
|
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):
|
def _Call(cmd, silent=False):
|
||||||
if not silent: print("# %s" % cmd)
|
if not silent: print("# %s" % cmd)
|
||||||
return subprocess.call(cmd, shell=True)
|
return subprocess.call(cmd, shell=True)
|
||||||
@ -377,6 +388,8 @@ class ArgumentParser(object):
|
|||||||
def ParseArg(self, argstring):
|
def ParseArg(self, argstring):
|
||||||
if argstring in ("-h", "--help", "help"):
|
if argstring in ("-h", "--help", "help"):
|
||||||
PrintHelpAndExit()
|
PrintHelpAndExit()
|
||||||
|
if argstring == "--print-completions":
|
||||||
|
PrintCompletionsAndExit()
|
||||||
arches = []
|
arches = []
|
||||||
modes = []
|
modes = []
|
||||||
targets = []
|
targets = []
|
||||||
|
Loading…
Reference in New Issue
Block a user