autobuild 1.21.0 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +25 -0
  3. data/.github/workflows/test.yml +30 -0
  4. data/.rubocop.yml +14 -7
  5. data/autobuild.gemspec +1 -1
  6. data/bin/autobuild +1 -1
  7. data/lib/autobuild/build_logfile.rb +1 -2
  8. data/lib/autobuild/config.rb +5 -5
  9. data/lib/autobuild/environment.rb +28 -45
  10. data/lib/autobuild/exceptions.rb +11 -5
  11. data/lib/autobuild/import/archive.rb +31 -22
  12. data/lib/autobuild/import/cvs.rb +6 -6
  13. data/lib/autobuild/import/darcs.rb +4 -4
  14. data/lib/autobuild/import/git-lfs.rb +4 -4
  15. data/lib/autobuild/import/git.rb +139 -66
  16. data/lib/autobuild/import/hg.rb +7 -7
  17. data/lib/autobuild/import/svn.rb +15 -9
  18. data/lib/autobuild/importer.rb +33 -37
  19. data/lib/autobuild/mail_reporter.rb +5 -2
  20. data/lib/autobuild/package.rb +14 -12
  21. data/lib/autobuild/packages/autotools.rb +3 -8
  22. data/lib/autobuild/packages/cmake.rb +11 -8
  23. data/lib/autobuild/packages/dummy.rb +0 -4
  24. data/lib/autobuild/packages/gnumake.rb +1 -1
  25. data/lib/autobuild/packages/orogen.rb +11 -4
  26. data/lib/autobuild/packages/pkgconfig.rb +2 -2
  27. data/lib/autobuild/packages/python.rb +1 -2
  28. data/lib/autobuild/packages/ruby.rb +5 -5
  29. data/lib/autobuild/parallel.rb +7 -16
  30. data/lib/autobuild/pkgconfig.rb +1 -0
  31. data/lib/autobuild/progress_display.rb +5 -9
  32. data/lib/autobuild/rake_task_extension.rb +6 -0
  33. data/lib/autobuild/reporting.rb +7 -7
  34. data/lib/autobuild/subcommand.rb +24 -23
  35. data/lib/autobuild/timestamps.rb +3 -3
  36. data/lib/autobuild/utility.rb +3 -3
  37. data/lib/autobuild/version.rb +1 -1
  38. data/lib/autobuild.rb +0 -3
  39. metadata +5 -4
  40. data/.travis.yml +0 -21
@@ -17,9 +17,9 @@ module Autobuild
17
17
  # @option options [String] :branch (default) the branch to track
18
18
  def initialize(repository, options = {})
19
19
  hgopts, _common = Kernel.filter_options options,
20
- branch: 'default'
20
+ branch: 'default'
21
21
  sourceopts, common = Kernel.filter_options options,
22
- :repository_id, :source_id
22
+ :repository_id, :source_id
23
23
 
24
24
  super(common)
25
25
  @branch = hgopts[:branch]
@@ -48,8 +48,8 @@ module Autobuild
48
48
  def validate_importdir(package)
49
49
  unless File.directory?(File.join(package.importdir, '.hg'))
50
50
  raise ConfigException.new(package, 'import'),
51
- "while importing #{package.name}, "\
52
- "#{package.importdir} is not a hg repository"
51
+ "while importing #{package.name}, "\
52
+ "#{package.importdir} is not a hg repository"
53
53
  end
54
54
  end
55
55
 
@@ -61,9 +61,9 @@ module Autobuild
61
61
  end
62
62
  validate_importdir(package)
63
63
  package.run(:import, Autobuild.tool('hg'), 'pull',
64
- repository, retry: true, working_directory: package.importdir)
64
+ repository, retry: true, working_directory: package.importdir)
65
65
  package.run(:import, Autobuild.tool('hg'), 'update',
66
- branch, working_directory: package.importdir)
66
+ branch, working_directory: package.importdir)
67
67
  true # no easy to know if package was updated, keep previous behavior
68
68
  end
69
69
 
@@ -72,7 +72,7 @@ module Autobuild
72
72
  FileUtils.mkdir_p(base_dir) unless File.directory?(base_dir)
73
73
 
74
74
  package.run(:import, Autobuild.tool('hg'), 'clone',
75
- '-u', branch, repository, package.importdir, retry: true)
75
+ '-u', branch, repository, package.importdir, retry: true)
76
76
  end
77
77
  end
78
78
 
@@ -14,9 +14,11 @@ module Autobuild
14
14
  # Autobuild.programs['svn'] = 'my_svn_tool'
15
15
  def initialize(svnroot, options = {})
16
16
  svnroot = [*svnroot].join("/")
17
- svnopts, common = Kernel.filter_options options,
17
+ svnopts, common = Kernel.filter_options(
18
+ options,
18
19
  :svnup => [], :svnco => [], :revision => nil,
19
20
  :repository_id => "svn:#{svnroot}"
21
+ )
20
22
  common[:repository_id] = svnopts.delete(:repository_id)
21
23
  relocate(svnroot, svnopts)
22
24
  super(common.merge(repository_id: svnopts[:repository_id]))
@@ -67,7 +69,7 @@ module Autobuild
67
69
  revision = svninfo.grep(/^Revision: /).first
68
70
  unless revision
69
71
  raise ConfigException.new(package, 'import'),
70
- "cannot get SVN information for #{package.importdir}"
72
+ "cannot get SVN information for #{package.importdir}"
71
73
  end
72
74
  revision =~ /Revision: (\d+)/
73
75
  Integer($1)
@@ -79,7 +81,9 @@ module Autobuild
79
81
  # @return [String]
80
82
  # @raises (see svn_info)
81
83
  def vcs_fingerprint(package)
82
- Digest::SHA1.hexdigest(svn_info(package).grep(/^(URL|Revision):/).sort.join("\n"))
84
+ Digest::SHA1.hexdigest(
85
+ svn_info(package).grep(/^(URL|Revision):/).sort.join("\n")
86
+ )
83
87
  end
84
88
 
85
89
  # Returns the URL of the remote SVN repository
@@ -93,7 +97,7 @@ module Autobuild
93
97
  url = svninfo.grep(/^URL: /).first
94
98
  unless url
95
99
  raise ConfigException.new(package, 'import'),
96
- "cannot get SVN information for #{package.importdir}"
100
+ "cannot get SVN information for #{package.importdir}"
97
101
  end
98
102
  url.chomp =~ /URL: (.+)/
99
103
  $1
@@ -165,8 +169,9 @@ module Autobuild
165
169
  Hash.new
166
170
  end
167
171
 
168
- options, other_options = Kernel.filter_options options,
169
- working_directory: package.importdir, retry: true
172
+ options, other_options = Kernel.filter_options(
173
+ options, working_directory: package.importdir, retry: true
174
+ )
170
175
  options = options.merge(other_options)
171
176
  package.run(:import, Autobuild.tool(:svn), *args, options, &block)
172
177
  end
@@ -203,7 +208,8 @@ module Autobuild
203
208
 
204
209
  unless svninfo.grep(/is not a working copy/).empty?
205
210
  raise ConfigException.new(package, 'import'),
206
- "#{package.importdir} does not appear to be a Subversion working copy"
211
+ "#{package.importdir} does not appear to be a "\
212
+ "Subversion working copy"
207
213
  end
208
214
  svninfo
209
215
  ensure
@@ -241,8 +247,8 @@ module Autobuild
241
247
 
242
248
  def checkout(package, _options = Hash.new) # :nodoc:
243
249
  run_svn(package, 'co', "--non-interactive", *@options_co,
244
- svnroot, package.importdir,
245
- working_directory: nil)
250
+ svnroot, package.importdir,
251
+ working_directory: nil)
246
252
  end
247
253
  end
248
254
 
@@ -203,7 +203,8 @@ module Autobuild
203
203
 
204
204
  patches_fingerprint_string = patches_fingerprint(package)
205
205
  if patches_fingerprint_string
206
- Digest::SHA1.hexdigest(vcs_fingerprint_string + patches_fingerprint_string)
206
+ Digest::SHA1.hexdigest(vcs_fingerprint_string +
207
+ patches_fingerprint_string)
207
208
  elsif patches.empty?
208
209
  vcs_fingerprint_string
209
210
  end
@@ -211,16 +212,19 @@ module Autobuild
211
212
 
212
213
  # basic fingerprint of the package and its dependencies
213
214
  def vcs_fingerprint(package)
214
- #each importer type should implement its own
215
- Autoproj.warn "Fingerprint in #{package.name} has not been implemented for this type of packages, results should be discarded"
216
- return nil
215
+ # each importer type should implement its own
216
+ Autoproj.warn "Fingerprint in #{package.name} has not been implemented "\
217
+ "for this type of packages, results should be discarded"
218
+ nil
217
219
  end
218
220
 
219
221
  # fingerprint for patches associated to this package
220
222
  def patches_fingerprint(package)
221
223
  cur_patches = currently_applied_patches(package)
222
- cur_patches.map(&:shift) #leave only level and source information
223
- Digest::SHA1.hexdigest(cur_patches.sort.flatten.join("")) if !patches.empty? && cur_patches
224
+ cur_patches.map(&:shift) # leave only level and source information
225
+ if !patches.empty? && cur_patches
226
+ Digest::SHA1.hexdigest(cur_patches.sort.flatten.join(""))
227
+ end
224
228
  end
225
229
 
226
230
  # Sets the number of times update / checkout should be retried before giving
@@ -314,12 +318,10 @@ module Autobuild
314
318
  end
315
319
 
316
320
  # Enumerate the post-import hooks for this importer
317
- def each_post_hook(error: false)
321
+ def each_post_hook(error: false, &block)
318
322
  return enum_for(__method__, error: false) unless block_given?
319
323
 
320
- self.class.each_post_hook(error: error) do |callback|
321
- yield(callback)
322
- end
324
+ self.class.each_post_hook(error: error, &block)
323
325
 
324
326
  post_hooks.each do |hook|
325
327
  yield(hook.callback) if hook.always || !error
@@ -357,9 +359,9 @@ module Autobuild
357
359
  raise last_error
358
360
  else raise
359
361
  end
360
- rescue ::Exception => original_error
362
+ rescue ::Exception => e
361
363
  message = Autobuild.color('update failed', :red)
362
- last_error = original_error
364
+ last_error = e
363
365
  # If the package is patched, it might be that the update
364
366
  # failed because we needed to unpatch first. Try it out
365
367
  #
@@ -378,11 +380,11 @@ module Autobuild
378
380
  rescue Interrupt
379
381
  raise
380
382
  rescue ::Exception
381
- raise original_error
383
+ raise e
382
384
  end
383
385
  end
384
386
 
385
- retry_count = update_retry_count(original_error, retry_count)
387
+ retry_count = update_retry_count(e, retry_count)
386
388
  raise unless retry_count
387
389
 
388
390
  package.message "update failed in #{package.importdir}, "\
@@ -399,20 +401,20 @@ module Autobuild
399
401
  fallback(e, package, :import, package)
400
402
  end
401
403
 
402
- def perform_checkout(package, options = Hash.new)
404
+ def perform_checkout(package, **options)
403
405
  last_error = nil
404
406
  package.progress_start "checking out %s", :done_message => 'checked out %s' do
405
407
  retry_count = 0
406
408
  begin
407
- checkout(package, options)
409
+ checkout(package, **options)
408
410
  execute_post_hooks(package)
409
411
  rescue Interrupt
410
412
  if last_error then raise last_error
411
413
  else raise
412
414
  end
413
- rescue ::Exception => original_error
414
- last_error = original_error
415
- retry_count = update_retry_count(original_error, retry_count)
415
+ rescue ::Exception => e
416
+ last_error = e
417
+ retry_count = update_retry_count(e, retry_count)
416
418
  raise unless retry_count
417
419
 
418
420
  package.message "checkout of %s failed, "\
@@ -456,31 +458,26 @@ module Autobuild
456
458
  # ID is given will, in this mode, reset the repository to the requested ID
457
459
  # (if that does not involve losing commits). Otherwise, it will only
458
460
  # ensure that the requested commit ID is present in the current HEAD.
459
- def import(package, options = Hash.new)
461
+ def import( # rubocop:disable Metrics/ParameterLists
462
+ package, *old_boolean,
463
+ ignore_errors: false, checkout_only: false, allow_interactive: true, **options
464
+ )
460
465
  # Backward compatibility
461
- unless options.kind_of?(Hash)
462
- options = options
466
+ unless old_boolean.empty?
467
+ old_boolean = old_boolean.first
463
468
  Autoproj.warn "calling #import with a boolean as second argument "\
464
469
  "is deprecated, switch to the named argument interface instead"
465
- Autoproj.warn " e.g. call import(package, only_local: #{options})"
470
+ Autoproj.warn " e.g. call import(package, only_local: #{old_boolean})"
466
471
  Autoproj.warn " #{caller(1..1).first}"
467
- options = Hash[only_local: options]
472
+ options[:only_local] = old_boolean
468
473
  end
469
474
 
470
- options = Kernel.validate_options options,
471
- only_local: false,
472
- reset: false,
473
- checkout_only: false,
474
- ignore_errors: false,
475
- allow_interactive: true
476
- ignore_errors = options.delete(:ignore_errors)
477
-
478
475
  importdir = package.importdir
479
476
  if File.directory?(importdir)
480
477
  package.isolate_errors(mark_as_failed: false,
481
478
  ignore_errors: ignore_errors) do
482
- if !options[:checkout_only] && package.update?
483
- perform_update(package, options)
479
+ if !checkout_only && package.update?
480
+ perform_update(package, checkout_only: false, **options)
484
481
  elsif Autobuild.verbose
485
482
  package.message "%s: not updating"
486
483
  end
@@ -488,12 +485,11 @@ module Autobuild
488
485
 
489
486
  elsif File.exist?(importdir)
490
487
  raise ConfigException.new(package, 'import'),
491
- "#{importdir} exists but is not a directory"
488
+ "#{importdir} exists but is not a directory"
492
489
  else
493
490
  package.isolate_errors(mark_as_failed: true,
494
491
  ignore_errors: ignore_errors) do
495
- perform_checkout(package,
496
- allow_interactive: options[:allow_interactive])
492
+ perform_checkout(package, allow_interactive: allow_interactive)
497
493
  true
498
494
  end
499
495
  end
@@ -22,8 +22,11 @@ if Autobuild::HAS_RMAIL
22
22
  end
23
23
 
24
24
  attr_reader :from_email, :to_email, :smtp_hostname, :smtp_port,
25
- :subject, :only_errors
25
+ :subject, :only_errors
26
+
26
27
  def initialize(config)
28
+ super()
29
+
27
30
  @from_email = (config[:from] || default_mail)
28
31
  @to_email = (config[:to] || default_mail)
29
32
  @subject =
@@ -78,7 +81,7 @@ if Autobuild::HAS_RMAIL
78
81
  to_email.each do |email|
79
82
  mail.header.to = email
80
83
  smtp.send_mail(RMail::Serialize.write('', mail),
81
- from_email, email)
84
+ from_email, email)
82
85
  end
83
86
  end
84
87
 
@@ -64,7 +64,7 @@ module Autobuild
64
64
  # Some statistics about the commands that have been run
65
65
  attr_reader :statistics
66
66
 
67
- EnvOp = Struct.new :type, :name, :values
67
+ EnvOp = Struct.new :type, :name, :values # rubocop:disable Lint/StructNewOverride
68
68
 
69
69
  # List of environment values added by this package with {#env_add},
70
70
  # {#env_add_path} or {#env_set}
@@ -150,6 +150,7 @@ module Autobuild
150
150
  @imported = false
151
151
  @prepared = false
152
152
  @built = false
153
+ @disabled = nil
153
154
 
154
155
  if Hash === spec
155
156
  name, depends = spec.to_a.first
@@ -402,8 +403,8 @@ module Autobuild
402
403
  def isolate_errors(options = Hash.new)
403
404
  options = Hash[mark_as_failed: true] unless options.kind_of?(Hash)
404
405
  options = validate_options options,
405
- mark_as_failed: true,
406
- ignore_errors: Autobuild.ignore_errors
406
+ mark_as_failed: true,
407
+ ignore_errors: Autobuild.ignore_errors
407
408
 
408
409
  # Don't do anything if we already have failed
409
410
  if failed?
@@ -448,12 +449,12 @@ module Autobuild
448
449
  # be done there as well.
449
450
  #
450
451
  # (see Importer#import)
451
- def import(options = Hash.new)
452
- options = Hash[only_local: options] unless options.respond_to?(:to_hash)
452
+ def import(*old_boolean, **options)
453
+ options = { only_local: old_boolean.first } unless old_boolean.empty?
453
454
 
454
455
  @import_invoked = true
455
456
  if @importer
456
- result = @importer.import(self, options)
457
+ result = @importer.import(self, **options)
457
458
  elsif update?
458
459
  message "%s: no importer defined, doing nothing"
459
460
  end
@@ -495,12 +496,12 @@ module Autobuild
495
496
  end
496
497
  end
497
498
  if suffix.empty?
498
- return msg
499
+ msg
499
500
  elsif prefix_style.empty?
500
- return (prefix + suffix).join(" ")
501
+ (prefix + suffix).join(" ")
501
502
  else
502
503
  colorized_prefix = Autobuild.color(prefix.join(" "), *prefix_style)
503
- return [colorized_prefix, *suffix].join(" ")
504
+ [colorized_prefix, *suffix].join(" ")
504
505
  end
505
506
  end
506
507
 
@@ -527,7 +528,7 @@ module Autobuild
527
528
  args[0] = process_formatting_string(args[0], :bold)
528
529
  done_message = process_formatting_string(done_message) if done_message
529
530
  Autobuild.progress_start(self, *args,
530
- done_message: done_message, **raw_options, &block)
531
+ done_message: done_message, **raw_options, &block)
531
532
  end
532
533
 
533
534
  def progress(*args)
@@ -686,10 +687,11 @@ module Autobuild
686
687
  pkg = Autobuild::Package[pkg_name]
687
688
  unless (fingerprint = memo[pkg.name])
688
689
  fingerprint = pkg.fingerprint(recursive: true, memo: memo)
689
- return unless fingerprint
690
+ break unless fingerprint
690
691
  end
691
692
  fingerprint
692
693
  end
694
+ return unless dependency_fingerprints
693
695
 
694
696
  memo[name] = Digest::SHA1.hexdigest(
695
697
  self_fingerprint + dependency_fingerprints.join(""))
@@ -837,7 +839,7 @@ module Autobuild
837
839
  end
838
840
 
839
841
  # Make sure that this package will be ignored in the build
840
- def disable(phases = Autobuild.all_phases)
842
+ def disable(_phases = Autobuild.all_phases)
841
843
  @disabled = true
842
844
  end
843
845
 
@@ -25,13 +25,8 @@ module Autobuild
25
25
  # To override this default behaviour on a per-package basis, use Autotools#use
26
26
  #
27
27
  class Autotools < Configurable
28
- attr_accessor :using
29
- attr_accessor :configureflags
30
- attr_accessor :aclocal_flags
31
- attr_accessor :autoheader_flags
32
- attr_accessor :autoconf_flags
33
- attr_accessor :automake_flags
34
- attr_accessor :bear_flags
28
+ attr_accessor :using, :configureflags, :aclocal_flags, :autoheader_flags,
29
+ :autoconf_flags, :automake_flags, :bear_flags
35
30
 
36
31
  @builddir = 'build'
37
32
  @@enable_bear_globally = false
@@ -278,7 +273,7 @@ module Autobuild
278
273
  file conffile => "#{conffile}#{confext}"
279
274
  elsif using[:autoconf]
280
275
  raise PackageException.new(self, 'prepare'),
281
- "neither configure.ac nor configure.in present in #{srcdir}"
276
+ "neither configure.ac nor configure.in present in #{srcdir}"
282
277
  end
283
278
 
284
279
  file conffile do
@@ -25,6 +25,7 @@ module Autobuild
25
25
  end
26
26
 
27
27
  attr_writer :full_reconfigures
28
+
28
29
  def full_reconfigures?
29
30
  @full_reconfigures
30
31
  end
@@ -36,8 +37,7 @@ module Autobuild
36
37
  # It can be overriden on a per-package basis with CMake.generator=
37
38
  attr_accessor :generator
38
39
 
39
- attr_reader :prefix_path
40
- attr_reader :module_path
40
+ attr_reader :prefix_path, :module_path
41
41
 
42
42
  # Whether files that are not within CMake's install manifest but are
43
43
  # present in the prefix should be deleted. Note that the contents of
@@ -63,6 +63,7 @@ module Autobuild
63
63
 
64
64
  # a key => value association of defines for CMake
65
65
  attr_reader :defines
66
+
66
67
  # The list of all -D options that should be passed on to CMake
67
68
  def all_defines
68
69
  additional_defines = Hash[
@@ -81,6 +82,7 @@ module Autobuild
81
82
  # Sets a generator explicitely for this component. See #generator and
82
83
  # CMake.generator
83
84
  attr_writer :generator
85
+
84
86
  # The CMake generator to use. You must choose one that generates
85
87
  # Makefiles. If not set for this package explicitely, it is using the
86
88
  # global value CMake.generator.
@@ -267,7 +269,7 @@ module Autobuild
267
269
  run('doc', Autobuild.tool(:doxygen), doxyfile)
268
270
  end
269
271
 
270
- def common_utility_handling(utility, target, start_msg, done_msg)
272
+ def common_utility_handling(utility, target, *args, start_msg, done_msg)
271
273
  utility.source_ref_dir = builddir
272
274
  utility.task do
273
275
  progress_start start_msg, :done_message => done_msg do
@@ -277,7 +279,7 @@ module Autobuild
277
279
  run(utility.name,
278
280
  Autobuild.tool(:make),
279
281
  "-j#{parallel_build_level}",
280
- target,
282
+ target, *args,
281
283
  working_directory: builddir)
282
284
  end
283
285
  yield if block_given?
@@ -295,7 +297,7 @@ module Autobuild
295
297
 
296
298
  def with_tests(target = 'test', &block)
297
299
  common_utility_handling(
298
- test_utility, target,
300
+ test_utility, target, "ARGS=-V",
299
301
  "running tests for %s",
300
302
  "successfully ran tests for %s", &block)
301
303
  end
@@ -320,7 +322,7 @@ module Autobuild
320
322
  end
321
323
  end
322
324
 
323
- def import(options = Hash.new)
325
+ def import(**options)
324
326
  super
325
327
 
326
328
  Dir.glob(File.join(srcdir, "*.pc.in")) do |file|
@@ -410,7 +412,7 @@ module Autobuild
410
412
  in_dir(builddir) do
411
413
  unless File.file?(File.join(srcdir, 'CMakeLists.txt'))
412
414
  raise ConfigException.new(self, 'configure'),
413
- "#{srcdir} contains no CMakeLists.txt file"
415
+ "#{srcdir} contains no CMakeLists.txt file"
414
416
  end
415
417
 
416
418
  command = ["cmake"]
@@ -545,7 +547,8 @@ module Autobuild
545
547
 
546
548
  def self_fingerprint
547
549
  return unless (base = super)
548
- all_defines = self.class.defines.merge(self.defines).sort_by(&:first)
550
+
551
+ all_defines = self.class.defines.merge(defines).sort_by(&:first)
549
552
  Digest::SHA1.hexdigest(base + all_defines.join(""))
550
553
  end
551
554
  end