d326cc5c411ac17f1a2befa1e717d221b2bbbf35
- Author
- Frederick Zhang <frederick888@tsundere.moe>
- Committer
- Frederick Zhang <frederick888@tsundere.moe>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/cargo/_cargo b/plugins/cargo/_cargo
2index 54e709ca099928e7adc5467adf368020f3ef658e..3eb3acb969b01272108fda40b6a5d5270fe96931 100644
3--- a/plugins/cargo/_cargo
4+++ b/plugins/cargo/_cargo
5@@ -31,7 +31,7 @@ case $state in
6 '--no-default-features[do not build the default features]' \
7 '--no-run[compile but do not run]' \
8 '(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \
9- '--target=[target triple]' \
10+ '--target=[target triple]: :_get_targets' \
11 '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
12 '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
13 '--color=:colorization option:(auto always never)' \
14@@ -48,7 +48,7 @@ case $state in
15 '--no-default-features[do not build the default features]' \
16 '(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \
17 '--release=[build in release mode]' \
18- '--target=[target triple]' \
19+ '--target=[target triple]: :_get_targets' \
20 '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
21 '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
22 '--color=:colorization option:(auto always never)' \
23@@ -61,7 +61,7 @@ case $state in
24 '(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \
25 '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
26 '--release[whether or not to clean release artifacts]' \
27- '--target=[target triple(default:all)]' \
28+ '--target=[target triple(default:all)]: :_get_targets' \
29 '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
30 '--color=:colorization option:(auto always never)' \
31 ;;
32@@ -79,7 +79,7 @@ case $state in
33 '(-p, --package)'{-p,--package}'=[package to document]' \
34 '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
35 '--release[build artifacts in release mode, with optimizations]' \
36- '--target=[build for the target triple]' \
37+ '--target=[build for the target triple]: :_get_targets' \
38 '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
39 '--color=:colorization option:(auto always never)' \
40 ;;
41@@ -276,7 +276,7 @@ case $state in
42 '--profile=[profile to build the selected target for]' \
43 '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
44 '--release[build artifacts in release mode, with optimizations]' \
45- '--target=[target triple which compiles will be for]' \
46+ '--target=[target triple which compiles will be for]: :_get_targets' \
47 '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
48 "${command_scope_spec[@]}" \
49 ;;
50@@ -294,7 +294,7 @@ case $state in
51 '(-p, --package)'{-p,--package}'=[package to document]' \
52 '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
53 '--release[build artifacts in release mode, with optimizations]' \
54- '--target=[build for the target triple]' \
55+ '--target=[build for the target triple]: :_get_targets' \
56 '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
57 "${command_scope_spec[@]}" \
58 ;;
59@@ -323,7 +323,7 @@ case $state in
60 '(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \
61 '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
62 '--release[build artifacts in release mode, with optimizations]' \
63- '--target=[target triple]' \
64+ '--target=[target triple]: :_get_targets' \
65 '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
66 '--color=:colorization option:(auto always never)' \
67 '1: :_test_names' \
68@@ -484,6 +484,37 @@ _benchmark_names()
69 _get_names_from_array "bench"
70 }
71
72+#Gets the target names from config files
73+_get_targets()
74+{
75+ local CURRENT_PATH
76+ if [[ $(uname -o) = "Cygwin" && -f "$PWD"/Cargo.toml ]]; then
77+ CURRENT_PATH=$PWD
78+ else
79+ CURRENT_PATH=$(_locate_manifest)
80+ fi
81+ if [[ -z "$CURRENT_PATH" ]]; then
82+ return 1
83+ fi
84+ local -a TARGETS
85+ local -a FIND_PATHS=( "/" )
86+ local -a FLINES
87+ local FIND_PATH FLINE
88+ while [[ "$CURRENT_PATH" != "/" ]]; do
89+ FIND_PATHS+=( "$CURRENT_PATH" )
90+ CURRENT_PATH=$(dirname $CURRENT_PATH)
91+ done
92+ for FIND_PATH in ${FIND_PATHS[@]}; do
93+ if [[ -f "$FIND_PATH"/.cargo/config ]]; then
94+ FLINES=( `grep "$FIND_PATH"/.cargo/config -e "^\[target\."` )
95+ for FLINE in ${FLINES[@]}; do
96+ TARGETS+=(`sed 's/^\[target\.\(.*\)\]$/\1/' <<< $FLINE`)
97+ done
98+ fi
99+ done
100+ _describe 'target' TARGETS
101+}
102+
103 # These flags are mutally exclusive specifiers for the scope of a command; as
104 # they are used in multiple places without change, they are expanded into the