autoproj 2.13.0 → 2.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +25 -0
- data/.github/workflows/test.yml +30 -0
- data/.rubocop.yml +79 -91
- data/.rubocop_todo.yml +1473 -0
- data/Gemfile +9 -9
- data/Rakefile +24 -24
- data/autoproj.gemspec +24 -22
- data/bin/alocate +4 -4
- data/bin/alog +5 -7
- data/bin/amake +4 -4
- data/bin/aup +4 -4
- data/bin/autoproj +3 -3
- data/bin/autoproj_bootstrap +224 -199
- data/bin/autoproj_bootstrap.in +7 -8
- data/bin/autoproj_install +223 -198
- data/bin/autoproj_install.in +6 -7
- data/lib/autoproj/aruba_minitest.rb +6 -11
- data/lib/autoproj/autobuild.rb +9 -6
- data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
- data/lib/autoproj/autobuild_extensions/dsl.rb +64 -34
- data/lib/autoproj/autobuild_extensions/git.rb +27 -26
- data/lib/autoproj/autobuild_extensions/package.rb +23 -22
- data/lib/autoproj/autobuild_extensions/python.rb +18 -0
- data/lib/autoproj/autobuild_extensions/svn.rb +1 -2
- data/lib/autoproj/base.rb +1 -1
- data/lib/autoproj/bash_completion.rb +5 -6
- data/lib/autoproj/build_option.rb +22 -24
- data/lib/autoproj/cli/base.rb +26 -26
- data/lib/autoproj/cli/bootstrap.rb +14 -16
- data/lib/autoproj/cli/build.rb +10 -7
- data/lib/autoproj/cli/cache.rb +11 -11
- data/lib/autoproj/cli/clean.rb +10 -10
- data/lib/autoproj/cli/commit.rb +7 -8
- data/lib/autoproj/cli/doc.rb +2 -2
- data/lib/autoproj/cli/envsh.rb +1 -2
- data/lib/autoproj/cli/exec.rb +60 -20
- data/lib/autoproj/cli/inspection_tool.rb +13 -7
- data/lib/autoproj/cli/locate.rb +30 -41
- data/lib/autoproj/cli/log.rb +7 -7
- data/lib/autoproj/cli/main.rb +213 -204
- data/lib/autoproj/cli/main_doc.rb +22 -21
- data/lib/autoproj/cli/main_global.rb +44 -19
- data/lib/autoproj/cli/main_plugin.rb +18 -18
- data/lib/autoproj/cli/main_test.rb +28 -27
- data/lib/autoproj/cli/manifest.rb +7 -7
- data/lib/autoproj/cli/osdeps.rb +12 -11
- data/lib/autoproj/cli/patcher.rb +2 -3
- data/lib/autoproj/cli/query.rb +17 -18
- data/lib/autoproj/cli/reconfigure.rb +1 -2
- data/lib/autoproj/cli/reset.rb +9 -12
- data/lib/autoproj/cli/show.rb +38 -39
- data/lib/autoproj/cli/status.rb +45 -39
- data/lib/autoproj/cli/switch_config.rb +5 -6
- data/lib/autoproj/cli/tag.rb +12 -11
- data/lib/autoproj/cli/test.rb +7 -7
- data/lib/autoproj/cli/update.rb +35 -37
- data/lib/autoproj/cli/utility.rb +11 -10
- data/lib/autoproj/cli/version.rb +42 -40
- data/lib/autoproj/cli/versions.rb +14 -15
- data/lib/autoproj/cli/watch.rb +33 -37
- data/lib/autoproj/cli/which.rb +16 -20
- data/lib/autoproj/cli.rb +4 -2
- data/lib/autoproj/configuration.rb +77 -85
- data/lib/autoproj/default.osdeps +18 -3
- data/lib/autoproj/environment.rb +42 -23
- data/lib/autoproj/exceptions.rb +9 -3
- data/lib/autoproj/find_workspace.rb +20 -25
- data/lib/autoproj/git_server_configuration.rb +40 -44
- data/lib/autoproj/gitorious.rb +1 -1
- data/lib/autoproj/installation_manifest.rb +64 -29
- data/lib/autoproj/local_package_set.rb +13 -11
- data/lib/autoproj/manifest.rb +137 -130
- data/lib/autoproj/metapackage.rb +2 -6
- data/lib/autoproj/ops/atomic_write.rb +7 -6
- data/lib/autoproj/ops/build.rb +4 -6
- data/lib/autoproj/ops/cache.rb +41 -43
- data/lib/autoproj/ops/cached_env.rb +5 -4
- data/lib/autoproj/ops/configuration.rb +525 -507
- data/lib/autoproj/ops/import.rb +76 -64
- data/lib/autoproj/ops/install.rb +217 -191
- data/lib/autoproj/ops/loader.rb +77 -76
- data/lib/autoproj/ops/main_config_switcher.rb +36 -45
- data/lib/autoproj/ops/phase_reporting.rb +4 -4
- data/lib/autoproj/ops/snapshot.rb +250 -247
- data/lib/autoproj/ops/tools.rb +76 -78
- data/lib/autoproj/ops/watch.rb +6 -6
- data/lib/autoproj/ops/which.rb +17 -14
- data/lib/autoproj/options.rb +13 -2
- data/lib/autoproj/os_package_installer.rb +102 -92
- data/lib/autoproj/os_package_query.rb +7 -13
- data/lib/autoproj/os_package_resolver.rb +189 -140
- data/lib/autoproj/os_repository_installer.rb +4 -4
- data/lib/autoproj/os_repository_resolver.rb +8 -6
- data/lib/autoproj/package_definition.rb +12 -13
- data/lib/autoproj/package_managers/apt_dpkg_manager.rb +19 -11
- data/lib/autoproj/package_managers/bundler_manager.rb +186 -129
- data/lib/autoproj/package_managers/debian_version.rb +25 -21
- data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
- data/lib/autoproj/package_managers/gem_manager.rb +68 -77
- data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
- data/lib/autoproj/package_managers/manager.rb +8 -3
- data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
- data/lib/autoproj/package_managers/pip_manager.rb +30 -28
- data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
- data/lib/autoproj/package_managers/port_manager.rb +2 -3
- data/lib/autoproj/package_managers/shell_script_manager.rb +47 -25
- data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
- data/lib/autoproj/package_managers/yum_manager.rb +12 -15
- data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
- data/lib/autoproj/package_manifest.rb +28 -74
- data/lib/autoproj/package_selection.rb +187 -187
- data/lib/autoproj/package_set.rb +144 -113
- data/lib/autoproj/python.rb +297 -0
- data/lib/autoproj/query_base.rb +20 -14
- data/lib/autoproj/reporter.rb +19 -19
- data/lib/autoproj/repository_managers/apt.rb +102 -68
- data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
- data/lib/autoproj/ros_condition_parser.rb +84 -0
- data/lib/autoproj/ros_package_manifest.rb +125 -0
- data/lib/autoproj/shell_completion.rb +16 -13
- data/lib/autoproj/source_package_query.rb +29 -36
- data/lib/autoproj/system.rb +32 -21
- data/lib/autoproj/test.rb +127 -104
- data/lib/autoproj/variable_expansion.rb +7 -9
- data/lib/autoproj/vcs_definition.rb +35 -32
- data/lib/autoproj/version.rb +1 -1
- data/lib/autoproj/workspace.rb +142 -108
- data/lib/autoproj/zsh_completion.rb +8 -9
- data/lib/autoproj.rb +55 -55
- data/samples/autoproj/init.rb +1 -2
- metadata +80 -46
- data/.travis.yml +0 -24
@@ -0,0 +1,297 @@
|
|
1
|
+
require "open3"
|
2
|
+
require "rubygems"
|
3
|
+
|
4
|
+
module Autoproj
|
5
|
+
module Python
|
6
|
+
# Get the python version for a given python executable
|
7
|
+
# @return [String] The python version as <major>.<minor>
|
8
|
+
def self.get_python_version(python_bin)
|
9
|
+
unless File.exist?(python_bin)
|
10
|
+
raise ArgumentError, "Autoproj::Python.get_python_version executable "\
|
11
|
+
"'#{python_bin}' does not exist"
|
12
|
+
end
|
13
|
+
|
14
|
+
cmd = "#{python_bin} -c \"import sys;"\
|
15
|
+
"version=sys.version_info[:3]; "\
|
16
|
+
"print('{0}.{1}'.format(*version))\"".strip
|
17
|
+
|
18
|
+
msg, status = Open3.capture2e(cmd)
|
19
|
+
if status.success?
|
20
|
+
msg.strip
|
21
|
+
|
22
|
+
else
|
23
|
+
raise "Autoproj::Python.get_python_version identification"\
|
24
|
+
" of python version for '#{python_bin}' failed: #{msg}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.get_pip_version(pip_bin)
|
29
|
+
unless File.exist?(pip_bin)
|
30
|
+
raise ArgumentError, "Autoproj::Python.get_pip_version executable "\
|
31
|
+
"'#{pip_bin}' does not exist"
|
32
|
+
end
|
33
|
+
|
34
|
+
cmd = "#{pip_bin} --version"
|
35
|
+
|
36
|
+
msg, status = Open3.capture2e(cmd)
|
37
|
+
if status.success?
|
38
|
+
msg.split(" ")[1]
|
39
|
+
|
40
|
+
else
|
41
|
+
raise "Autoproj::Python.get_pip_version identification"\
|
42
|
+
" of pip version for '#{pip_bin}' failed: #{msg}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.validate_version(version, version_constraint)
|
47
|
+
if version_constraint
|
48
|
+
dependency = Gem::Dependency.new("python", version_constraint)
|
49
|
+
dependency.match?("python", version)
|
50
|
+
else
|
51
|
+
true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Validate that a given python executable's version fulfills
|
56
|
+
# a given version constraint
|
57
|
+
# @param [String] python_bin the python executable
|
58
|
+
# @param [String] version_constraint version constraint, e.g., <3.8, >= 3.7, 3.6
|
59
|
+
# @return [String,Bool] Version and validation result, i.e.,
|
60
|
+
# True if binary fulfills the version constraint, false otherwise
|
61
|
+
def self.validate_python_version(python_bin, version_constraint)
|
62
|
+
version = get_python_version(python_bin)
|
63
|
+
[version, validate_version(version, version_constraint)]
|
64
|
+
end
|
65
|
+
|
66
|
+
# Find python given a version constraint
|
67
|
+
# @return [String,String] path to python executable and python version
|
68
|
+
def self.find_python(ws: Autoproj.workspace,
|
69
|
+
version: ws.config.get("python_version", nil))
|
70
|
+
finders = [
|
71
|
+
-> { Autobuild.programs["python"] },
|
72
|
+
-> { `which python3`.strip },
|
73
|
+
-> { `which python`.strip }
|
74
|
+
]
|
75
|
+
|
76
|
+
finders.each do |finder|
|
77
|
+
python_bin = finder.call
|
78
|
+
if python_bin && !python_bin.empty?
|
79
|
+
python_version, valid = validate_python_version(python_bin, version)
|
80
|
+
return python_bin, python_version if valid
|
81
|
+
end
|
82
|
+
end
|
83
|
+
raise "Autoproj::Python.find_python_bin: failed to find python" \
|
84
|
+
" for version '#{version}'"
|
85
|
+
end
|
86
|
+
|
87
|
+
# Get information about the python executable from autoproj config,
|
88
|
+
# but ensure the version constraint matches
|
89
|
+
#
|
90
|
+
# @return [String, String] Return path and version if the constraints
|
91
|
+
# are fulfilled nil otherwise
|
92
|
+
|
93
|
+
def self.get_python_from_config(ws: Autoproj.workspace, version: nil)
|
94
|
+
config_bin = ws.config.get("python_executable", nil)
|
95
|
+
return unless config_bin
|
96
|
+
|
97
|
+
config_version = ws.config.get("python_version", nil)
|
98
|
+
config_version ||= get_python_version(config_bin)
|
99
|
+
|
100
|
+
# If a version constraint is given, ensure fulfillment
|
101
|
+
if validate_version(config_version, version)
|
102
|
+
[config_bin, config_version]
|
103
|
+
else
|
104
|
+
raise "python_executable in autoproj config with " \
|
105
|
+
"version '#{config_version}' does not match "\
|
106
|
+
"version constraints '#{version}'"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.custom_resolve_python(bin: nil,
|
111
|
+
version: nil)
|
112
|
+
version, valid = validate_python_version(bin, version)
|
113
|
+
if valid
|
114
|
+
[bin, version]
|
115
|
+
else
|
116
|
+
raise "Autoproj::Python.resolve_python: requested python"\
|
117
|
+
"executable '#{bin}' does not satisfy version"\
|
118
|
+
"constraints '#{version}'"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.auto_resolve_python(ws: Autoproj.workspace,
|
123
|
+
version: nil)
|
124
|
+
version_constraint = version
|
125
|
+
resolvers = [
|
126
|
+
-> { get_python_from_config(ws: ws, version: version_constraint) },
|
127
|
+
-> { find_python(ws: ws, version: version_constraint) }
|
128
|
+
]
|
129
|
+
|
130
|
+
bin = nil
|
131
|
+
resolvers.each do |resolver|
|
132
|
+
bin, version = resolver.call
|
133
|
+
if bin && File.exist?(bin) && version
|
134
|
+
Autoproj.debug "Autoproj::Python.resolve_python: " \
|
135
|
+
"found python '#{bin}' version '#{version}'"
|
136
|
+
break
|
137
|
+
end
|
138
|
+
rescue RuntimeError => e
|
139
|
+
Autoproj.debug "Autoproj::Python.resolve_python: " \
|
140
|
+
"resolver failed: #{e}"
|
141
|
+
end
|
142
|
+
|
143
|
+
unless bin
|
144
|
+
msg = "Autoproj::Python.resolve_python: " \
|
145
|
+
"failed to find a python executable"
|
146
|
+
if version_constraint
|
147
|
+
msg += " satisfying version constraint '#{version_constraint}'"
|
148
|
+
end
|
149
|
+
raise msg
|
150
|
+
end
|
151
|
+
[bin, version]
|
152
|
+
end
|
153
|
+
|
154
|
+
# Resolve the python executable according to a given version constraint
|
155
|
+
# @param [Autoproj.workspace] ws Autoproj workspace
|
156
|
+
# @param [String] bin Path to the python executable that shall be used,
|
157
|
+
# first fallback is the python_executable set in Autoproj's configuration,
|
158
|
+
# second fallback is a full search
|
159
|
+
# @param [String] version version constraint
|
160
|
+
# @return [String,String] python path and python version
|
161
|
+
def self.resolve_python(ws: Autoproj.workspace,
|
162
|
+
bin: nil,
|
163
|
+
version: nil)
|
164
|
+
if bin
|
165
|
+
custom_resolve_python(bin: bin, version: version)
|
166
|
+
else
|
167
|
+
auto_resolve_python(ws: ws, version: version)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def self.remove_python_shims(prefix_dir)
|
172
|
+
shim_path = File.join(prefix_dir, "bin", "python")
|
173
|
+
FileUtils.rm shim_path if File.exist?(shim_path)
|
174
|
+
end
|
175
|
+
|
176
|
+
def self.remove_pip_shims(prefix_dir)
|
177
|
+
shim_path = File.join(prefix_dir, "bin", "pip")
|
178
|
+
FileUtils.rm shim_path if File.exist?(shim_path)
|
179
|
+
end
|
180
|
+
|
181
|
+
def self.rewrite_python_shims(python_executable, prefix_dir)
|
182
|
+
shim_path = File.join(prefix_dir, "bin")
|
183
|
+
unless File.exist?(shim_path)
|
184
|
+
FileUtils.mkdir_p shim_path
|
185
|
+
Autoproj.warn "Autoproj::Python.rewrite_python_shims: creating "\
|
186
|
+
"#{shim_path} - "\
|
187
|
+
"are you operating on a valid autoproj workspace?"
|
188
|
+
end
|
189
|
+
|
190
|
+
python_path = File.join(shim_path, "python")
|
191
|
+
File.open(python_path, "w") do |io|
|
192
|
+
io.puts "#! /bin/sh"
|
193
|
+
io.puts "exec #{python_executable} \"$@\""
|
194
|
+
end
|
195
|
+
FileUtils.chmod 0o755, python_path
|
196
|
+
python_path
|
197
|
+
end
|
198
|
+
|
199
|
+
def self.rewrite_pip_shims(python_executable, prefix_dir)
|
200
|
+
shim_path = File.join(prefix_dir, "bin")
|
201
|
+
unless File.exist?(shim_path)
|
202
|
+
FileUtils.mkdir_p shim_path
|
203
|
+
Autoproj.warn "Autoproj::Python.rewrite_pip_shims: creating "\
|
204
|
+
"#{shim_path} - "\
|
205
|
+
"are you operating on a valid autoproj workspace?"
|
206
|
+
end
|
207
|
+
pip_path = File.join(shim_path, "pip")
|
208
|
+
File.open(pip_path, "w") do |io|
|
209
|
+
io.puts "#! /bin/sh"
|
210
|
+
io.puts "exec #{python_executable} -m pip \"$@\""
|
211
|
+
end
|
212
|
+
FileUtils.chmod 0o755, pip_path
|
213
|
+
pip_path
|
214
|
+
end
|
215
|
+
|
216
|
+
# Activate configuration for python in the autoproj configuration
|
217
|
+
# @return [String,String] python path and python version
|
218
|
+
def self.activate_python(ws: Autoproj.workspace,
|
219
|
+
bin: nil,
|
220
|
+
version: nil)
|
221
|
+
bin, version = resolve_python(ws: ws, bin: bin, version: version)
|
222
|
+
ws.config.set("python_executable", bin, true)
|
223
|
+
ws.config.set("python_version", version, true)
|
224
|
+
|
225
|
+
ws.osdep_suffixes << "python#{$1}" if version =~ /^([0-9]+)\./
|
226
|
+
|
227
|
+
rewrite_python_shims(bin, ws.dot_autoproj_dir)
|
228
|
+
rewrite_pip_shims(bin, ws.dot_autoproj_dir)
|
229
|
+
[bin, version]
|
230
|
+
end
|
231
|
+
|
232
|
+
def self.deactivate_python(ws: Autoproj.workspace)
|
233
|
+
remove_python_shims(ws.dot_autoproj_dir)
|
234
|
+
remove_pip_shims(ws.dot_autoproj_dir)
|
235
|
+
ws.config.reset("python_executable")
|
236
|
+
ws.config.reset("python_version")
|
237
|
+
end
|
238
|
+
|
239
|
+
# Allow to update the PYTHONPATH for package if autoproj configuration
|
240
|
+
# USE_PYTHON is set to true.
|
241
|
+
# Then tries to guess the python binary from Autobuild.programs['python']
|
242
|
+
# and system's default setting
|
243
|
+
# @param [Autobuild::Package] pkg
|
244
|
+
# @param [Autoproj.workspace] ws Autoproj workspace
|
245
|
+
# @param [String] bin Path to a custom python version
|
246
|
+
# @param [String] version version constraint for python executable
|
247
|
+
# @return tuple of [executable, version, site-packages path] if set,
|
248
|
+
# otherwise nil
|
249
|
+
def self.activate_python_path(pkg,
|
250
|
+
ws: Autoproj.workspace,
|
251
|
+
bin: nil,
|
252
|
+
version: nil)
|
253
|
+
return unless ws.config.get("USE_PYTHON", nil)
|
254
|
+
|
255
|
+
bin, version = resolve_python(ws: ws, bin: bin, version: version)
|
256
|
+
path = File.join(pkg.prefix, "lib",
|
257
|
+
"python#{version}", "site-packages")
|
258
|
+
pkg.env_add_path "PYTHONPATH", path
|
259
|
+
|
260
|
+
[bin, version, path]
|
261
|
+
end
|
262
|
+
|
263
|
+
def self.assert_python_activated(ws: Autoproj.workspace)
|
264
|
+
return true if ws.config.get("USE_PYTHON")
|
265
|
+
|
266
|
+
raise ConfigError,
|
267
|
+
"Your current package selection requires the use of python," \
|
268
|
+
" but this is either unspecified or has been denied,"\
|
269
|
+
" see setting of USE_PYTHON in your workspace configuration." \
|
270
|
+
" Either remove all packages depending on pip packages " \
|
271
|
+
" from the workspace layout (manifest) or " \
|
272
|
+
" call 'autoproj reconfigure' to change the setting."
|
273
|
+
end
|
274
|
+
|
275
|
+
def self.setup_python_configuration_options(ws: Autoproj.workspace)
|
276
|
+
ws.config.declare "USE_PYTHON", "boolean",
|
277
|
+
default: "no",
|
278
|
+
doc: ["Do you want to activate python?"]
|
279
|
+
|
280
|
+
if ws.config.get("USE_PYTHON")
|
281
|
+
unless ws.config.has_value_for?("python_executable")
|
282
|
+
remove_python_shims(ws.dot_autoproj_dir)
|
283
|
+
remove_pip_shims(ws.dot_autoproj_dir)
|
284
|
+
python_bin, = auto_resolve_python(ws: ws)
|
285
|
+
end
|
286
|
+
|
287
|
+
ws.config.declare "python_executable", "string",
|
288
|
+
default: python_bin.to_s,
|
289
|
+
doc: ["Select the path to the python executable"]
|
290
|
+
|
291
|
+
activate_python(ws: ws)
|
292
|
+
else
|
293
|
+
deactivate_python(ws: ws)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
data/lib/autoproj/query_base.rb
CHANGED
@@ -10,6 +10,7 @@ module Autoproj
|
|
10
10
|
attr_reader :fields
|
11
11
|
# The expected value
|
12
12
|
attr_reader :value
|
13
|
+
|
13
14
|
# Whether the match can be partial
|
14
15
|
attr_predicate :partial?, true
|
15
16
|
|
@@ -19,7 +20,9 @@ module Autoproj
|
|
19
20
|
#
|
20
21
|
# Use {.all}
|
21
22
|
class All
|
22
|
-
def match(pkg)
|
23
|
+
def match(pkg)
|
24
|
+
true
|
25
|
+
end
|
23
26
|
end
|
24
27
|
|
25
28
|
# Get a query that matches anything
|
@@ -57,13 +60,14 @@ module Autoproj
|
|
57
60
|
# @api private
|
58
61
|
#
|
59
62
|
# Parse a single field in a query (i.e. a FIELD[=~]VALUE string)
|
60
|
-
#
|
63
|
+
#
|
61
64
|
# This is NOT meant to be used directly. Subclasses are supposed to
|
62
65
|
# redefine .parse to create the relevant match object.
|
63
66
|
def self.parse(str, allowed_fields: [], default_fields: Hash.new)
|
64
|
-
if parsed = /[=~]/.match(str)
|
65
|
-
field
|
66
|
-
|
67
|
+
if (parsed = /[=~]/.match(str))
|
68
|
+
field = parsed.pre_match
|
69
|
+
value = parsed.post_match
|
70
|
+
partial = (parsed[0] == "~")
|
67
71
|
else
|
68
72
|
raise ArgumentError, "invalid query string '#{str}', expected FIELD and VALUE separated by either = or ~"
|
69
73
|
end
|
@@ -71,17 +75,17 @@ module Autoproj
|
|
71
75
|
field = default_fields[field] || field
|
72
76
|
|
73
77
|
# Validate the query key
|
74
|
-
|
78
|
+
unless allowed_fields.include?(field)
|
75
79
|
raise ArgumentError, "'#{field}' is not a known query key"
|
76
80
|
end
|
77
81
|
|
78
|
-
fields = field.split(
|
79
|
-
|
82
|
+
fields = field.split(".")
|
83
|
+
[fields, value, partial]
|
80
84
|
end
|
81
85
|
|
82
86
|
# Parse a complete query
|
83
87
|
def self.parse_query(query, *args)
|
84
|
-
query = query.split(
|
88
|
+
query = query.split(":")
|
85
89
|
query = query.map do |str|
|
86
90
|
parse(str, *args)
|
87
91
|
end
|
@@ -97,9 +101,11 @@ module Autoproj
|
|
97
101
|
def initialize(submatches)
|
98
102
|
@submatches = submatches
|
99
103
|
end
|
104
|
+
|
100
105
|
def each_subquery(&block)
|
101
106
|
@submatches.each(&block)
|
102
107
|
end
|
108
|
+
|
103
109
|
def match(pkg)
|
104
110
|
@submatches.map { |m| m.match(pkg) }.compact.max
|
105
111
|
end
|
@@ -110,19 +116,19 @@ module Autoproj
|
|
110
116
|
def initialize(submatches)
|
111
117
|
@submatches = submatches
|
112
118
|
end
|
119
|
+
|
113
120
|
def each_subquery(&block)
|
114
121
|
@submatches.each(&block)
|
115
122
|
end
|
123
|
+
|
116
124
|
def match(pkg)
|
117
125
|
matches = @submatches.map do |m|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
126
|
+
return unless (p = m.match(pkg))
|
127
|
+
|
128
|
+
p
|
122
129
|
end
|
123
130
|
matches.min
|
124
131
|
end
|
125
132
|
end
|
126
133
|
end
|
127
134
|
end
|
128
|
-
|
data/lib/autoproj/reporter.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "autobuild/reporting"
|
2
2
|
module Autoproj
|
3
3
|
class << self
|
4
4
|
attr_accessor :verbose
|
5
|
+
|
5
6
|
def silent?
|
6
7
|
Autobuild.silent?
|
7
8
|
end
|
9
|
+
|
8
10
|
def silent=(value)
|
9
11
|
Autobuild.silent = value
|
10
12
|
end
|
@@ -70,18 +72,18 @@ module Autoproj
|
|
70
72
|
secs = Time.now - @timer_start
|
71
73
|
return if secs < 1
|
72
74
|
|
73
|
-
[[60,
|
75
|
+
[[60, "sec"], [60, "min"], [24, "hour"], [1000, "day"]].map do |count, name|
|
74
76
|
if secs > 0
|
75
77
|
secs, n = secs.divmod(count)
|
76
78
|
next if (val = n.to_i) == 0
|
77
79
|
|
78
|
-
"#{val} #{val > 1 ? name
|
80
|
+
"#{val} #{val > 1 ? "#{name}s" : name}"
|
79
81
|
end
|
80
|
-
end.compact.reverse.join(
|
82
|
+
end.compact.reverse.join(" ")
|
81
83
|
end
|
82
84
|
|
83
85
|
def success
|
84
|
-
elapsed_string = elapsed_time ? " (took #{elapsed_time})" :
|
86
|
+
elapsed_string = elapsed_time ? " (took #{elapsed_time})" : ""
|
85
87
|
Autoproj.message("Command finished successfully at "\
|
86
88
|
"#{Time.now}#{elapsed_string}", :bold, :green)
|
87
89
|
if Autobuild.post_success_message
|
@@ -91,9 +93,9 @@ module Autoproj
|
|
91
93
|
end
|
92
94
|
|
93
95
|
def self.report(root_dir: nil, silent: nil, debug: Autobuild.debug,
|
94
|
-
|
95
|
-
|
96
|
-
|
96
|
+
on_package_success: :report,
|
97
|
+
on_package_failures: Autobuild::Reporting
|
98
|
+
.default_report_on_package_failures)
|
97
99
|
reporter = Autoproj::Reporter.new
|
98
100
|
Autobuild::Reporting << reporter
|
99
101
|
interrupted = nil
|
@@ -105,24 +107,22 @@ module Autoproj
|
|
105
107
|
|
106
108
|
package_failures =
|
107
109
|
Autobuild::Reporting.report(on_package_failures: :report_silent) do
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
interrupted = e
|
113
|
-
end
|
110
|
+
reporter.reset_timer
|
111
|
+
yield
|
112
|
+
rescue Interrupt => e
|
113
|
+
interrupted = e
|
114
114
|
end
|
115
115
|
|
116
|
-
|
117
116
|
if package_failures.empty?
|
118
117
|
raise interrupted if interrupted
|
119
118
|
|
120
119
|
Autobuild::Reporting.success if on_package_success == :report
|
121
|
-
|
120
|
+
[]
|
122
121
|
else
|
123
|
-
Autobuild::Reporting.report_finish_on_error(
|
124
|
-
|
125
|
-
interrupted_by: interrupted
|
122
|
+
Autobuild::Reporting.report_finish_on_error(
|
123
|
+
package_failures,
|
124
|
+
on_package_failures: on_package_failures, interrupted_by: interrupted
|
125
|
+
)
|
126
126
|
end
|
127
127
|
rescue CLI::CLIException, InvalidWorkspace, ConfigError => e
|
128
128
|
if silent_errors
|