OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Add programmable completion to some Chromium OS build scripts | 5 # Add programmable completion to some Chromium OS build scripts |
6 | 6 |
7 | 7 |
8 # Echo a list of -- flags that the current command accepts. The | 8 # Echo a list of -- flags that the current command accepts. The |
9 # function assumes that the command supports shflags' --help flag. | 9 # function assumes that the command supports shflags' --help flag. |
10 # | 10 # |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 # echo the existing target board sysroots | 66 # echo the existing target board sysroots |
67 # | 67 # |
68 _board_sysroots() | 68 _board_sysroots() |
69 { | 69 { |
70 local builddir=/build | 70 local builddir=/build |
71 if [ -d ${builddir} ]; then | 71 if [ -d ${builddir} ]; then |
72 echo $(command ls "${builddir}") | 72 echo $(command ls "${builddir}") |
73 fi | 73 fi |
74 } | 74 } |
75 | 75 |
| 76 _complete_board_sysroot_flag() |
| 77 { |
| 78 COMPREPLY=() |
| 79 local arg=$(_argeq --board) |
| 80 if [[ ${arg} == --board=* ]]; then |
| 81 COMPREPLY=( $(compgen -W "$(_board_sysroots)" -- ${arg#--board=}) ) |
| 82 return 0 |
| 83 fi |
| 84 return 1 |
| 85 } |
| 86 |
76 # Completion for --board= argument for existing board sysroots | 87 # Completion for --board= argument for existing board sysroots |
77 # | 88 # |
78 _board_sysroot() | 89 _board_sysroot() |
79 { | 90 { |
80 _flag_complete && return 0 | 91 _flag_complete && return 0 |
81 | 92 _complete_board_flag && return 0 |
82 COMPREPLY=() | |
83 local arg=$(_argeq --board) | |
84 if [[ ${arg} == --board=* ]]; then | |
85 COMPREPLY=( $(compgen -W "$(_board_sysroots)" -- ${arg#--board=}) ) | |
86 fi | |
87 } | 93 } |
88 | 94 |
89 complete -o bashdefault -o default -F _board_sysroot \ | 95 complete -o bashdefault -o default -F _board_sysroot \ |
90 build_autotest.sh \ | 96 build_autotest.sh \ |
91 build_image \ | 97 build_image \ |
92 build_packages \ | 98 build_packages \ |
93 image_to_usb.sh \ | 99 image_to_usb.sh \ |
94 mod_image_for_test.sh | 100 mod_image_for_test.sh |
95 | 101 |
96 | 102 |
(...skipping 15 matching lines...) Expand all Loading... |
112 | 118 |
113 COMPREPLY=() | 119 COMPREPLY=() |
114 local arg=$(_argeq --board) | 120 local arg=$(_argeq --board) |
115 if [[ ${arg} == --board=* ]]; then | 121 if [[ ${arg} == --board=* ]]; then |
116 COMPREPLY=( $(compgen -W "$(_board_overlays)" -- ${arg#--board=}) ) | 122 COMPREPLY=( $(compgen -W "$(_board_overlays)" -- ${arg#--board=}) ) |
117 fi | 123 fi |
118 } | 124 } |
119 | 125 |
120 complete -o bashdefault -o default -F _board_overlay setup_board | 126 complete -o bashdefault -o default -F _board_overlay setup_board |
121 | 127 |
| 128 # Completion for -c and -s argument for autotest script |
| 129 _ls_autotest() { |
| 130 local autotest_dir=../third_party/autotest/files |
| 131 ls --color=never -dBFH ${autotest_dir}/$1* 2>/dev/null |\ |
| 132 sed s/"..\/third_party\/autotest\/files\/"//g |
| 133 } |
| 134 |
| 135 _autotest_complete() |
| 136 { |
| 137 _flag_complete && return 0 |
| 138 |
| 139 local arg=$(_argeq -c) |
| 140 if [[ ${arg} == -c=* ]]; then |
| 141 COMPREPLY=($(compgen -W "$(_ls_autotest ${arg#-c=})")) |
| 142 return 0 |
| 143 fi |
| 144 |
| 145 arg=$(_argeq -s) |
| 146 if [[ ${arg} == -s=* ]]; then |
| 147 COMPREPLY=($(compgen -W "$(_ls_autotest ${arg#-s=})")) |
| 148 return 0 |
| 149 fi |
| 150 |
| 151 _complete_board_sysroot_flag && return 0 |
| 152 } |
| 153 |
| 154 complete -o bashdefault -o default -o nospace -F _autotest_complete autotest |
122 | 155 |
123 ### Local Variables: | 156 ### Local Variables: |
124 ### mode: shell-script | 157 ### mode: shell-script |
125 ### End: | 158 ### End: |
OLD | NEW |