autoproj 2.10.2 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9816c7630ddb1758579428da56d50fcfd6e655ff69d9daddbe860c4f8d8c9501
4
- data.tar.gz: ec2228ff0857f8a4d78fc7ee512a6ec50c2b02dec8bc15af725a43b8a97ddf31
3
+ metadata.gz: 27b34232b7064fe41e6ffbf64a366c8177bd07176890ae94d4d2fb38cb6a9007
4
+ data.tar.gz: 6f10cee97b778a086dbe009dd19a7af9c3e416b9a18b18f1e7a8ae090a7dbda1
5
5
  SHA512:
6
- metadata.gz: 362c3cc73ce68418dc18fa0f018523de0a0b0ea27f6f72fc56d7cf8c820dae1d1eacdf759bae614ad5bf547973a44f6e7cadbe1863df1d75fc2673cec124c855
7
- data.tar.gz: 877354416b6ab05061f99c630ea535aeb6cbabd529682a0b85d051567687a58430e49b4b4c2c61f857edcc193d6220c202972f0deadd2ba59d0bd42ada907ff6
6
+ metadata.gz: b01c93d7197d16bebd63aa83deba8c761950a848526b5ce23f06e90f0b7904ea07924b71ef3d428148779cc6ea83b577033e0b069e6b3c396f21feec2f249f3e
7
+ data.tar.gz: 99e5701cb311313f771d413c20eb6b37f9da8975636caf17c480cdfe695fe3d50f293f3c19260e17253540be3c5bda04e844391750df108321c4e2db9d6b1671
@@ -45,7 +45,7 @@ Layout/AlignParameters:
45
45
  Layout/DotPosition:
46
46
  Enabled: false
47
47
 
48
- Layout/FirstParameterIndentation:
48
+ Layout/IndentFirstArgument:
49
49
  Enabled: false
50
50
 
51
51
  Layout/IndentAssignment:
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
26
 
27
27
  s.add_runtime_dependency "bundler"
28
- s.add_runtime_dependency "autobuild", ">= 1.14.0"
28
+ s.add_runtime_dependency "autobuild", ">= 1.19.0"
29
29
  s.add_runtime_dependency "backports", '~> 3.0'
30
30
  s.add_runtime_dependency "utilrb", '~> 3.0.0', ">= 3.0.0"
31
31
  s.add_runtime_dependency "thor", '~> 0.20.0'
@@ -40,5 +40,6 @@ Gem::Specification.new do |s|
40
40
  s.add_development_dependency "simplecov"
41
41
  s.add_development_dependency "aruba"
42
42
  s.add_development_dependency "tty-cursor"
43
+ s.add_development_dependency "timecop"
43
44
  end
44
45
 
@@ -242,54 +242,54 @@ module Autoproj
242
242
  opt.on '--debug', 'Run in debug mode' do
243
243
  @autoproj_options << '--debug'
244
244
  end
245
- opt.on '--gem-source=URL', String, "use this source for RubyGems "\
246
- "instead of rubygems.org" do |url|
245
+ opt.on '--gem-source=URL', String, 'use this source for RubyGems '\
246
+ 'instead of rubygems.org' do |url|
247
247
  @gem_source = url
248
248
  end
249
- opt.on '--gems-path=PATH', "install gems under this path instead "\
250
- "of ~/.autoproj/gems" do |path|
249
+ opt.on '--gems-path=PATH', 'install gems under this path instead '\
250
+ 'of ~/.autoproj/gems' do |path|
251
251
  self.gems_install_path = path
252
252
  end
253
253
  opt.on '--public-gems', "install gems in the default gem location" do
254
254
  self.install_gems_in_gem_user_dir
255
255
  end
256
- opt.on '--version=VERSION_CONSTRAINT', String, 'use the provided "\
257
- "string as a version constraint for autoproj' do |version|
256
+ opt.on '--version=VERSION_CONSTRAINT', String, 'use the provided '\
257
+ 'string as a version constraint for autoproj' do |version|
258
258
  if @gemfile
259
259
  raise "cannot give both --version and --gemfile"
260
260
  end
261
261
  @gemfile = default_gemfile_contents(version)
262
262
  end
263
- opt.on '--gemfile=PATH', String, 'use the given Gemfile to install "\
264
- "autoproj instead of the default' do |path|
263
+ opt.on '--gemfile=PATH', String, 'use the given Gemfile to install '\
264
+ 'autoproj instead of the default' do |path|
265
265
  if @gemfile
266
266
  raise "cannot give both --version and --gemfile"
267
267
  end
268
268
  @gemfile = File.read(path)
269
269
  end
270
- opt.on '--seed-config=PATH', String, 'path to a seed file that "\
271
- "should be used to initialize the configuration' do |path|
270
+ opt.on '--seed-config=PATH', String, 'path to a seed file that '\
271
+ 'should be used to initialize the configuration' do |path|
272
272
  @config.merge!(YAML.load(File.read(path)))
273
273
  end
274
- opt.on '--prefer-os-independent-packages', 'prefer OS-independent "\
275
- "packages (such as a RubyGem) over their OS-packaged equivalent "\
276
- "(e.g. the thor gem vs. the ruby-thor debian package)' do
274
+ opt.on '--prefer-os-independent-packages', 'prefer OS-independent '\
275
+ 'packages (such as a RubyGem) over their OS-packaged equivalent '\
276
+ '(e.g. the thor gem vs. the ruby-thor debian package)' do
277
277
  @prefer_indep_over_os_packages = true
278
278
  end
279
- opt.on '--[no-]color', 'do not use colored output (enabled by "\
280
- "default if the terminal supports it)' do |color|
279
+ opt.on '--[no-]color', 'do not use colored output (enabled by '\
280
+ 'default if the terminal supports it)' do |color|
281
281
  if color then @autoproj_options << "--color"
282
282
  else @autoproj_options << '--no-color'
283
283
  end
284
284
  end
285
- opt.on '--[no-]progress', 'do not use progress output (enabled by "\
286
- "default if the terminal supports it)' do |progress|
285
+ opt.on '--[no-]progress', 'do not use progress output (enabled by '\
286
+ 'default if the terminal supports it)' do |progress|
287
287
  if progress then @autoproj_options << "--progress"
288
288
  else @autoproj_options << '--no-progress'
289
289
  end
290
290
  end
291
- opt.on '--[no-]interactive', 'if non-interactive, use default "\
292
- "answer for questions' do |flag|
291
+ opt.on '--[no-]interactive', 'if non-interactive, use default '\
292
+ 'answer for questions' do |flag|
293
293
  if flag then @autoproj_options << "--interactive"
294
294
  else @autoproj_options << "--no-interactive"
295
295
  end
@@ -242,54 +242,54 @@ module Autoproj
242
242
  opt.on '--debug', 'Run in debug mode' do
243
243
  @autoproj_options << '--debug'
244
244
  end
245
- opt.on '--gem-source=URL', String, "use this source for RubyGems "\
246
- "instead of rubygems.org" do |url|
245
+ opt.on '--gem-source=URL', String, 'use this source for RubyGems '\
246
+ 'instead of rubygems.org' do |url|
247
247
  @gem_source = url
248
248
  end
249
- opt.on '--gems-path=PATH', "install gems under this path instead "\
250
- "of ~/.autoproj/gems" do |path|
249
+ opt.on '--gems-path=PATH', 'install gems under this path instead '\
250
+ 'of ~/.autoproj/gems' do |path|
251
251
  self.gems_install_path = path
252
252
  end
253
253
  opt.on '--public-gems', "install gems in the default gem location" do
254
254
  self.install_gems_in_gem_user_dir
255
255
  end
256
- opt.on '--version=VERSION_CONSTRAINT', String, 'use the provided "\
257
- "string as a version constraint for autoproj' do |version|
256
+ opt.on '--version=VERSION_CONSTRAINT', String, 'use the provided '\
257
+ 'string as a version constraint for autoproj' do |version|
258
258
  if @gemfile
259
259
  raise "cannot give both --version and --gemfile"
260
260
  end
261
261
  @gemfile = default_gemfile_contents(version)
262
262
  end
263
- opt.on '--gemfile=PATH', String, 'use the given Gemfile to install "\
264
- "autoproj instead of the default' do |path|
263
+ opt.on '--gemfile=PATH', String, 'use the given Gemfile to install '\
264
+ 'autoproj instead of the default' do |path|
265
265
  if @gemfile
266
266
  raise "cannot give both --version and --gemfile"
267
267
  end
268
268
  @gemfile = File.read(path)
269
269
  end
270
- opt.on '--seed-config=PATH', String, 'path to a seed file that "\
271
- "should be used to initialize the configuration' do |path|
270
+ opt.on '--seed-config=PATH', String, 'path to a seed file that '\
271
+ 'should be used to initialize the configuration' do |path|
272
272
  @config.merge!(YAML.load(File.read(path)))
273
273
  end
274
- opt.on '--prefer-os-independent-packages', 'prefer OS-independent "\
275
- "packages (such as a RubyGem) over their OS-packaged equivalent "\
276
- "(e.g. the thor gem vs. the ruby-thor debian package)' do
274
+ opt.on '--prefer-os-independent-packages', 'prefer OS-independent '\
275
+ 'packages (such as a RubyGem) over their OS-packaged equivalent '\
276
+ '(e.g. the thor gem vs. the ruby-thor debian package)' do
277
277
  @prefer_indep_over_os_packages = true
278
278
  end
279
- opt.on '--[no-]color', 'do not use colored output (enabled by "\
280
- "default if the terminal supports it)' do |color|
279
+ opt.on '--[no-]color', 'do not use colored output (enabled by '\
280
+ 'default if the terminal supports it)' do |color|
281
281
  if color then @autoproj_options << "--color"
282
282
  else @autoproj_options << '--no-color'
283
283
  end
284
284
  end
285
- opt.on '--[no-]progress', 'do not use progress output (enabled by "\
286
- "default if the terminal supports it)' do |progress|
285
+ opt.on '--[no-]progress', 'do not use progress output (enabled by '\
286
+ 'default if the terminal supports it)' do |progress|
287
287
  if progress then @autoproj_options << "--progress"
288
288
  else @autoproj_options << '--no-progress'
289
289
  end
290
290
  end
291
- opt.on '--[no-]interactive', 'if non-interactive, use default "\
292
- "answer for questions' do |flag|
291
+ opt.on '--[no-]interactive', 'if non-interactive, use default '\
292
+ 'answer for questions' do |flag|
293
293
  if flag then @autoproj_options << "--interactive"
294
294
  else @autoproj_options << "--no-interactive"
295
295
  end
@@ -25,6 +25,17 @@ def teardown
25
25
  super
26
26
  end
27
27
 
28
+ def generate_local_gemfile
29
+ path = expand_path("Gemfile.local")
30
+ File.open(path, 'w') do |io|
31
+ io.write <<~GEMFILE
32
+ source "https://rubygems.org"
33
+ gem "autoproj", path: "#{File.expand_path("../../", __dir__)}"
34
+ GEMFILE
35
+ end
36
+ path
37
+ end
38
+
28
39
  def run_command_and_stop(*args, fail_on_error: true, **kwargs)
29
40
  cmd = run_command(*args, **kwargs)
30
41
  cmd.stop
@@ -38,6 +49,10 @@ def run_command(*args, **kwargs)
38
49
  @aruba_api.run_command(*args, **kwargs)
39
50
  end
40
51
 
52
+ def cd(*args) # also defined by Rake
53
+ @aruba_api.cd(*args)
54
+ end
55
+
41
56
  def chmod(*args) # also defined by Rake
42
57
  @aruba_api.chmod(*args)
43
58
  end
@@ -185,10 +185,24 @@ def import_package(name, workspace: Autoproj.workspace, &block)
185
185
  def python_package(name, workspace: Autoproj.workspace)
186
186
  package_common(:python, name, workspace: workspace) do |pkg|
187
187
  pkg.internal_dependency 'python'
188
+ pkg.post_import do
189
+ pkg.depends_on 'python-setuptools' if pkg.install_mode?
190
+ end
188
191
  yield(pkg) if block_given?
189
192
  end
190
193
  end
191
194
 
195
+ def common_make_default_test_task(pkg)
196
+ unless pkg.test_utility.source_dir
197
+ test_dir = File.join(pkg.srcdir, 'test')
198
+ if File.directory?(test_dir)
199
+ pkg.test_utility.source_dir = File.join(pkg.builddir, 'test', 'results')
200
+ end
201
+ end
202
+
203
+ pkg.with_tests if pkg.test_utility.source_dir
204
+ end
205
+
192
206
  def common_make_based_package_setup(pkg)
193
207
  unless pkg.has_doc? && pkg.doc_dir
194
208
  pkg.with_doc do
@@ -198,14 +212,11 @@ def common_make_based_package_setup(pkg)
198
212
  end
199
213
 
200
214
  unless pkg.test_utility.has_task?
201
- unless pkg.test_utility.source_dir
202
- test_dir = File.join(pkg.srcdir, 'test')
203
- if File.directory?(test_dir)
204
- pkg.test_utility.source_dir = File.join(pkg.builddir, 'test', 'results')
205
- end
215
+ pkg.post_import do
216
+ common_make_default_test_task(pkg)
206
217
  end
207
-
208
- pkg.with_tests if pkg.test_utility.source_dir
218
+ # BACKWARD COMPATIBILITY ONLY. REMOVE FOR AUTOPROJ 3.0
219
+ common_make_default_test_task(pkg)
209
220
  end
210
221
  end
211
222
 
@@ -264,6 +275,18 @@ def env_add(name, value)
264
275
  Autoproj.env.add(name, value)
265
276
  end
266
277
 
278
+ def ruby_package_default_test_task(pkg)
279
+ unless pkg.test_utility.source_dir
280
+ test_dir = File.join(pkg.srcdir, 'test')
281
+ if File.directory?(test_dir)
282
+ pkg.test_utility.source_dir = File.join(pkg.srcdir, '.test-results')
283
+ FileUtils.mkdir_p pkg.test_utility.source_dir
284
+ end
285
+ end
286
+
287
+ pkg.with_tests if pkg.test_utility.source_dir
288
+ end
289
+
267
290
  # Defines a Ruby package
268
291
  #
269
292
  # Example:
@@ -284,15 +307,11 @@ def ruby_package(name, workspace: Autoproj.workspace)
284
307
  pkg.with_doc if !pkg.has_doc? && pkg.rake_doc_task
285
308
 
286
309
  unless pkg.test_utility.has_task?
287
- unless pkg.test_utility.source_dir
288
- test_dir = File.join(pkg.srcdir, 'test')
289
- if File.directory?(test_dir)
290
- pkg.test_utility.source_dir = File.join(pkg.srcdir, '.test-results')
291
- FileUtils.mkdir_p pkg.test_utility.source_dir
292
- end
310
+ pkg.post_import do
311
+ ruby_package_default_test_task(pkg)
293
312
  end
294
-
295
- pkg.with_tests if pkg.test_utility.source_dir
313
+ # BACKWARD COMPATIBILITY ONLY. REMOVE FOR AUTOPROJ 3.0
314
+ ruby_package_default_test_task(pkg)
296
315
  end
297
316
 
298
317
  yield(pkg) if block_given?
@@ -6,12 +6,11 @@ module Autoproj
6
6
  else
7
7
  ArgumentError
8
8
  end
9
-
9
+
10
10
  # Yields, and if the given block raises a ConfigError with no file assigned,
11
11
  # add that file to both the object and the exception message
12
12
  def self.in_file(file, exception_t = ConfigError)
13
13
  yield
14
-
15
14
  rescue exception_t => e
16
15
  if exception_t != ConfigError
17
16
  raise ConfigError.new(file), "in #{file}: #{e.message}", e.backtrace
@@ -28,21 +27,33 @@ class << self
28
27
  attr_reader :post_import_blocks
29
28
  end
30
29
 
30
+ # Enumerate the post-import blocks registered for the given package
31
+ #
32
+ # @param [PackageDefinition] pkg
33
+ # @see post_import
31
34
  def self.each_post_import_block(pkg, &block)
35
+ # We use Autobuild packages as keys
36
+ pkg = pkg.autobuild if pkg.respond_to?(:autobuild)
37
+
32
38
  @post_import_blocks[nil].each(&block)
33
- if @post_import_blocks.has_key?(pkg)
34
- @post_import_blocks[pkg].each(&block)
35
- end
39
+ @post_import_blocks[pkg]&.each(&block)
36
40
  end
37
41
 
42
+ # Register a block that should be called after a set of package(s) have
43
+ # been imported
44
+ #
45
+ # @overload post_import(&block) register the block for all packages
46
+ # @overload post_import(*packages, &block)
47
+ # @param [Array<Autobuild::Package,PackageDefinition>] packages
38
48
  def self.post_import(*packages, &block)
39
49
  if packages.empty?
40
50
  @post_import_blocks[nil] << block
41
51
  else
42
52
  packages.each do |pkg|
53
+ # We use Autobuild packages as keys
54
+ pkg = pkg.autobuild if pkg.respond_to?(:autobuild)
43
55
  @post_import_blocks[pkg] << block
44
56
  end
45
57
  end
46
58
  end
47
59
  end
48
-
@@ -29,6 +29,7 @@ def run(selected_packages, **options)
29
29
  super(selected_packages,
30
30
  ignore_errors: options[:keep_going],
31
31
  checkout_only: true,
32
+ report: false,
32
33
  **options)
33
34
 
34
35
  parallel = build_options[:parallel] || ws.config.parallel_build_level
@@ -1,24 +1,10 @@
1
- require 'autoproj/cli/inspection_tool'
1
+ require 'autoproj/cli/utility'
2
2
 
3
3
  module Autoproj
4
4
  module CLI
5
- class Doc < InspectionTool
6
- def validate_options(packages, options)
7
- packages, options = super
8
- if options[:no_deps_shortcut]
9
- options[:deps] = false
10
- end
11
- return packages, options
12
- end
13
-
14
- def run(user_selection, deps: true)
15
- initialize_and_load
16
- packages, _ =
17
- finalize_setup(user_selection, recursive: deps)
18
- packages.each do |pkg|
19
- ws.manifest.find_autobuild_package(pkg).disable_phases('import', 'prepare', 'install')
20
- end
21
- Autobuild.apply(packages, "autoproj-doc", ['doc'])
5
+ class Doc < Utility
6
+ def initialize(ws = Workspace.default, name: 'doc')
7
+ super
22
8
  end
23
9
  end
24
10
  end
@@ -1,5 +1,6 @@
1
1
  require 'thor'
2
2
  require 'tty/color'
3
+ require 'autoproj/cli/main_doc'
3
4
  require 'autoproj/cli/main_test'
4
5
  require 'autoproj/cli/main_plugin'
5
6
  require 'autoproj/cli/main_global'
@@ -37,6 +38,10 @@ class Main < Thor
37
38
  stop_on_unknown_option! :exec
38
39
  check_unknown_options! except: :exec
39
40
 
41
+ def self.exit_on_failure?
42
+ true
43
+ end
44
+
40
45
  class << self
41
46
  # @api private
42
47
  #
@@ -183,15 +188,6 @@ def status(*packages)
183
188
  run_autoproj_cli(:status, :Status, Hash[], *packages)
184
189
  end
185
190
 
186
- desc 'doc [PACKAGES]', 'generate API documentation for packages that support it'
187
- option :deps, type: :boolean, default: true,
188
- desc: 'control whether documentation should be generated only for the packages given on the command line, or also for their dependencies. -n is a shortcut for --no-deps'
189
- option :no_deps_shortcut, hide: true, aliases: '-n', type: :boolean,
190
- desc: 'provide -n for --no-deps'
191
- def doc(*packages)
192
- run_autoproj_cli(:doc, :Doc, Hash[], *packages)
193
- end
194
-
195
191
  desc 'update [PACKAGES]', 'update packages'
196
192
  option :aup, default: false, hide: true, type: :boolean,
197
193
  desc: 'behave like aup'
@@ -360,6 +356,9 @@ def reconfigure
360
356
  desc 'test', 'interface for running tests'
361
357
  subcommand 'test', MainTest
362
358
 
359
+ desc 'doc', 'interface for generating documentation'
360
+ subcommand 'doc', MainDoc
361
+
363
362
  desc 'show [PACKAGES]', 'show informations about package(s)'
364
363
  option :mainline, type: :string,
365
364
  desc: "compare to the given baseline. if 'true', the comparison will ignore any override, otherwise it will take into account overrides only up to the given package set"
@@ -0,0 +1,86 @@
1
+ module Autoproj
2
+ module CLI
3
+ class MainDoc < Thor
4
+ namespace 'doc'
5
+
6
+ default_command 'exec'
7
+
8
+ no_commands do
9
+ def report(report_options = Hash.new)
10
+ options = self.options.merge(parent_options)
11
+ extra_options = Hash.new
12
+ if Autobuild::Subprocess.transparent_mode = options[:tool]
13
+ Autobuild.silent = true
14
+ Autobuild.color = false
15
+ report_options[:silent] = true
16
+ report_options[:on_package_failures] = :exit_silent
17
+ extra_options[:silent] = true
18
+ end
19
+ Autoproj.report(**Hash[debug: options[:debug]].merge(report_options)) do
20
+ yield(extra_options)
21
+ end
22
+ end
23
+ end
24
+
25
+ desc 'enable [PACKAGES]', 'enable docs for the given packages (or for all packages if none are given)'
26
+ option :deps, type: :boolean, default: false,
27
+ desc: 'controls whether the dependencies of the packages given on the command line should be enabled as well (the default is not)'
28
+ def enable(*packages)
29
+ require 'autoproj/cli/doc'
30
+ report(silent: true) do
31
+ cli = Doc.new
32
+ args = cli.validate_options(packages, options)
33
+ cli.enable(*args)
34
+ end
35
+ end
36
+
37
+ desc 'disable [PACKAGES]', 'disable docs for the given packages (or for all packages if none are given)'
38
+ option :deps, type: :boolean, default: false,
39
+ desc: 'controls whether the dependencies of the packages given on the command line should be disabled as well (the default is not)'
40
+ def disable(*packages)
41
+ require 'autoproj/cli/doc'
42
+ report(silent: true) do
43
+ cli = Doc.new
44
+ args = cli.validate_options(packages, options)
45
+ cli.disable(*args)
46
+ end
47
+ end
48
+
49
+ desc 'list [PACKAGES]', 'show doc enable/disable status for the given packages (or all packages if none are given)'
50
+ option :deps, type: :boolean, default: true,
51
+ desc: 'controls whether the dependencies of the packages given on the command line should be disabled as well (the default is not)'
52
+ def list(*packages)
53
+ require 'autoproj/cli/doc'
54
+ report(silent: true) do
55
+ cli = Doc.new
56
+ args = cli.validate_options(packages, options)
57
+ cli.list(*args)
58
+ end
59
+ end
60
+
61
+ desc 'exec [PACKAGES]', 'generate documentation for the given packages, or all if no packages are given on the command line'
62
+ option :deps, type: :boolean, default: false,
63
+ desc: 'controls whether to generate documentation of the dependencies of the packages given on the command line (the default is not)'
64
+ option :no_deps_shortcut, hide: true, aliases: '-n', type: :boolean,
65
+ desc: 'provide -n for --no-deps'
66
+ option :parallel, aliases: :p, type: :numeric,
67
+ desc: 'maximum number of parallel jobs'
68
+ option :tool, type: :boolean, default: false,
69
+ desc: "run in tool mode, which do not redirect the subcommand's outputs"
70
+ option :color, type: :boolean, default: TTY::Color.color?,
71
+ desc: 'enables or disables colored display (enabled by default if the terminal supports it)'
72
+ option :progress, type: :boolean, default: TTY::Color.color?,
73
+ desc: 'enables or disables progress display (enabled by default if the terminal supports it)'
74
+ def exec(*packages)
75
+ require 'autoproj/cli/doc'
76
+ options = self.options.merge(parent_options)
77
+ report do |extra_options|
78
+ cli = Doc.new
79
+ options.delete(:tool)
80
+ args = cli.validate_options(packages, options.merge(extra_options))
81
+ cli.run(*args)
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end