-
Notifications
You must be signed in to change notification settings - Fork 1
/
_mx
258 lines (224 loc) · 11.3 KB
/
_mx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#compdef mx
# mx [global options] command [command options]
# main dispatcher
_mx() {
local curcontext="$curcontext" state line
typeset -A opt_args
local dynamic_imports
# options for passing to _arguments: mx -
typeset -a _mx_optional_arguments
_mx_optional_arguments=(
'-v[enable verbose output]'
'-V[enable VERY verbose output]'
'--no-warning[disable warning messages]'
"-y[answer 'y' to all questions asked]"
"-n[answer 'n' to all questions asked]"
'(-p --primary-suite-path)'{-p,--primary-suite-path}'=[set the primary suite directory]:path:_files -/'
'--dbg=[make Java processes wait on <port> for a debugger]:port:'
'-d[alias for "-dbg 8000"]'
'--attach=[Connect to existing server running at \[<address>:\]<port>]:host\:port:'
'--backup-modified[backup generated files if they pre-existed and are modified]'
'--cp-pfx=[class path prefix]:arg:'
'--cp-sfx=[class path suffix]:arg:'
'*-J-[Java VM arguments (e.g. "-J-dsa")]:arg:'
'*--J @-[Java VM arguments (e.g. "--J @-dsa")]:args:'
'-P-[prefix Java VM arguments (e.g. "-P-dsa")]:arg:'
'--Jp @-[prefix Java VM arguments (e.g. --Jp @-dsa)]:args:'
'-A[suffix Java VM arguments (e.g. "-A-dsa")]:arg:'
'--Ja @-[suffix Java VM arguments (e.g. --Ja @-dsa)]:args:'
'--user-home=[users home directory]:path:_files -/'
'--java-home=[primary JDK directory (must be JDK 7 or later)]:path:_files -/'
'--jacoco=[instruments selected classes using JaCoCo]: :(off on append)'
'--extra-java-homes=[secondary JDK directories separated by ":"]:paths:_dir_list'
'--strict-compliance[observe Java compliance for projects that set it explicitly]'
'--ignore-project[name of project to ignore]:name:'
'--kill-with-sigquit[send sigquit first before killing child processes]'
'--suite[limit command to the given suite]:name:'
'--suitemodel[mechanism for locating imported suites]:arg:'
'--primary[limit command to primary suite]'
'(--dy --dynamicimports)'{--dy,--dynamicimports}'=[dynamically import suite <name>]:name:'
'--no-download-progress[disable download progress meter]'
'--version[print version and exit]'
'--mx-tests[load mxtests suite (mx debugging)]'
'--jdk=[<tag\:compliance> JDK to use for the "java" command]:tag_compliance:'
'--version-conflict-resolution=[resolution mechanism used when a suite is imported with different versions]: :(suite none latest latest_all ignore)'
'(-c --max-cpus)'{-c,--max-cpus}'=[the maximum number of cpus to use during build]:cpus:'
'--strip-jars[Produce and use stripped jars in all mx commands.]'
'--timeout=[timeout (in seconds) for command]:secs:'
'--ptimeout=[timeout (in seconds) for subprocesses]:secs:'
'--vmprefix[prefix for running the VM (e.g. "gdb --args")]:prefix:'
'--gdb[alias for --vmprefix "gdb --args"]'
'--lldb[alias for --vmprefix "lldb --"]'
)
# options for passing to _arguments: mx benchmark <suite:benchmark> -
typeset -a _mx_benchmark_options_arguments
_mx_benchmark_options_arguments=(
'--results-file=[Path to JSON output file with benchmark results.]:results_file:_files'
'--machine-name=[Abstract name of the target machine.]:machine_name:'
'--machine-node=[Machine node the benchmark is executed on.]:machine_node:'
'--triggering-suite=[Name of the suite that triggered this benchmark, used to extract commit info of the corresponding repo.]:triggering_suite:'
'--ignore-suite-commit-info=[A comma-separated list of suite dependencies whose commit info must not be included.]:ignore_suite_commit_info:'
'(-)--list[Print the list of all available benchmark suites or all benchmarks available in a suite.]'
'--[Specify benchmark args. e.g. -- --keep-scratch]'
)
# options for passing to _arguments: mx benchmark <suite:benchmark> -- -
typeset -a _mx_benchmark_suite_options_arguments
_mx_benchmark_suite_options_arguments=(
'*--[Specify benchmark suite args. e.g. -- -n 5]' # * allows to have 2 -- arguments
'--jmh-jar=[JMR jar file]:jmh_jar:_files'
'--jmh-name=:jmh_name:'
'--keep-scratch[Do not delete scratch directory after benchmark execution.]'
'--no-scratch[Do not execute benchmark in scratch directory.]'
)
_mx_benchmark_caching_policy() {
# Rebuild if cache is older than 24 hours.
local -a oldp
oldp=( "$1"(Nmh+24) )
(( $#oldp ))
}
# mx <mx-options> benchmark suite:bench <benchmark-options> -- <suite-options> -- <extra-options>
# - Completions are cached for 24 hours
# - Supports dynamic imports
_mx_benchmark() {
local context state state_descr line
typeset -A opt_args
_arguments -C \
'(- 1)'{-h,--help} \
'(- 1)--list[Print the list of all available benchmark suites.]' \
': :->mx_benchmark_suite' \
'*:: :->mx_benchmark_options'
case $state in
mx_benchmark_suite)
# completes suite:bench
local _suite=""
if compset -P 1 '*:'; then
_suite=${IPREFIX%%:*}
fi
local _results _mx_benchmark_cache="mx/benchmark/${PWD##*/}/"
if [ -n "$_suite" ] ; then
_mx_benchmark_cache+="$_suite"
else
_mx_benchmark_cache+="suites"
fi
local dy_param=""
if [ -n "$dynamic_imports" ] ; then
dy_param="--dy=$dynamic_imports"
# dynamic imports may add bench-suites
_mx_benchmark_cache+="#$(echo $dynamic_imports | sha1sum | cut -f1 -d " ")"
fi
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
[[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _mx_benchmark_caching_policy
unset _results
if ( [[ ${+_results} -eq 0 ]] || _cache_invalid $_mx_benchmark_cache ) \
&& ! _retrieve_cache $_mx_benchmark_cache; then
_results=(${${(f)"$(_call_program suite-benchmark mx $dy_param benchmark $_suite --list | grep -vE '^($|([[:blank:]]{2,}-)|\w)' | tr -d ' ')"}})
# TODO(peterssen): Handle suites without :bench
[[ $#_results -gt 0 ]] && _store_cache $_mx_benchmark_cache _results
fi
if [[ -n "$_suite" ]]; then
compadd $_results
else
compadd -S ":" $_results
fi
;;
mx_benchmark_options)
dashdash=0
for ((i = (($CURRENT - 1)); i > 1 ; i--)); do
if [[ $words[$i] == -- ]] ; then
((dashdash++))
fi
done
case $dashdash in
0) _arguments "$_mx_benchmark_options_arguments[@]" ;;
1) _arguments "$_mx_benchmark_suite_options_arguments[@]" ;;
esac
;;
esac
}
# mx makegraaljdk [-h] [-f] [-a <path>] [-b] <path>
_mx_makegraaljdk() {
local context state state_descr line
typeset -A opt_args
_arguments \
'1: :_files -/' \
'(-)'{-h,--help}'[show this help message and exit]' \
'(-f --force)'{-f,--force}'[overwrite existing GraalJDK]' \
'(-a --archive)'{-a,--archive}'=[<path> name of archive to create]:archive:_files' \
'(-b --bootstrap)'{-b,--bootstrap}'[execute a bootstrap of the created GraalJDK]'
}
# options for passing to _arguments: mx jaotc <options>
typeset -a _mx_jaotc_options_arguments
_mx_jaotc_options_arguments=(
'--output=[<file> Output file name]:output_file:_files'
'--class-name=[<class names> List of classes to compile]'
'--jar=[<jarfiles> List of jar files to compile]:jars:_files -f *.jar'
'--module=[<modules> List of modules to compile]'
'--directory=[<dirs> List of directories where to search for files to compile]:directory:_dir_list'
'--search-path=[<dirs> List of directories where to search for specified files]:search_path:_dir_list'
'--compile-commands=[<file> Name of file with compile commands]:compile_commands:_files'
'--compile-for-tiered[Generate profiling code for tiered compilation]'
'--compile-with-assertions[Compile with java assertions]'
'--compile-threads=[<number> Number of compilation threads to be used]:compile_threads:'
'--ignore-errors[Ignores all exceptions thrown during class loading]'
'--exit-on-error[Exit on compilation errors]'
'--info[Print information during compilation]'
'--verbose[Print verbose information]'
'--debug[Print debug information]'
'(-)'{-\?,-h,--help}'[Print this help message]'
'(-)--version[Version information]'
'--linker-path=[Full path to linker executable]:linker_path:_files'
'*-J-[Pass <flag> directly to the runtime system (e.g. "-J-dsa")]:arg:'
)
# mx jaotc [-h] [-f] [-a <path>] [-b] <path>
_mx_jaotc() {
local context state state_descr line
typeset -A opt_args
_arguments -C \
"$_mx_jaotc_options_arguments[@]" \
':: :_files'
}
_mx_commands() {
# options for passing to _arguments: main mx commands
typeset -a _commands
_commands=(
'benchmark:run benchmark suite with given name'
'build:builds the artifacts of one or more dependencies'
'checkstyle:run Checkstyle on the Java sources'
'clean:remove all class files, images, and executables'
'eclipseformat:run the Eclipse Code Formatter on the Java sources'
'eclipseinit:(re)generate Eclipse project configurations and working sets'
'envs:print environment variables and their values'
'findbugs:run FindBugs against non-test Java projects'
'gate:run the tests used to validate a push'
'help:show detailed help for mx or a given command'
'ideclean:remove all IDE project configurations'
'ideinit:(re)generate IDE project configurations'
'intellijinit:(re)generate IntelliJ project configurations'
'jaotc:run AOT compiler'
'makegraaljdk:make a JDK with Graal as the default top level JIT'
'netbeansinit:(re)generate NetBeans project configurations'
'unittest:run the JUnit tests'
'update:update mx to the latest version'
'version:print mx version'
)
_describe 'command' _commands
}
_arguments \
"$_mx_optional_arguments[@]" \
'1: :_mx_commands' \
'*:: :->command_args'
dynamic_imports=${(v)opt_args[(i)--dy|--dynamicimports]}
case $state in
command_args)
case $words[1] in
help) _arguments '1: :_mx_commands' ;;
benchmark) _mx_benchmark ;;
makegraaljdk) _mx_makegraaljdk ;;
jaotc) _mx_jaotc ;;
# Add mx commands here
esac
;;
esac
} # end _mx
# Run the main dispatcher
_mx "$@"