autobuild 1.18.1 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) 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 +8 -6
  6. data/bin/autobuild +1 -1
  7. data/lib/autobuild/build_logfile.rb +1 -2
  8. data/lib/autobuild/config.rb +18 -5
  9. data/lib/autobuild/configurable.rb +3 -1
  10. data/lib/autobuild/environment.rb +28 -45
  11. data/lib/autobuild/exceptions.rb +11 -5
  12. data/lib/autobuild/import/archive.rb +31 -22
  13. data/lib/autobuild/import/cvs.rb +6 -6
  14. data/lib/autobuild/import/darcs.rb +4 -4
  15. data/lib/autobuild/import/git-lfs.rb +4 -4
  16. data/lib/autobuild/import/git.rb +153 -68
  17. data/lib/autobuild/import/hg.rb +7 -7
  18. data/lib/autobuild/import/svn.rb +15 -9
  19. data/lib/autobuild/importer.rb +38 -38
  20. data/lib/autobuild/mail_reporter.rb +5 -2
  21. data/lib/autobuild/package.rb +45 -35
  22. data/lib/autobuild/packages/autotools.rb +3 -8
  23. data/lib/autobuild/packages/cmake.rb +16 -7
  24. data/lib/autobuild/packages/dummy.rb +0 -4
  25. data/lib/autobuild/packages/gnumake.rb +1 -1
  26. data/lib/autobuild/packages/orogen.rb +11 -4
  27. data/lib/autobuild/packages/pkgconfig.rb +2 -2
  28. data/lib/autobuild/packages/python.rb +6 -8
  29. data/lib/autobuild/packages/ruby.rb +5 -5
  30. data/lib/autobuild/parallel.rb +20 -21
  31. data/lib/autobuild/pkgconfig.rb +1 -0
  32. data/lib/autobuild/progress_display.rb +130 -49
  33. data/lib/autobuild/rake_task_extension.rb +16 -5
  34. data/lib/autobuild/reporting.rb +20 -7
  35. data/lib/autobuild/subcommand.rb +24 -23
  36. data/lib/autobuild/test_utility.rb +2 -1
  37. data/lib/autobuild/timestamps.rb +3 -3
  38. data/lib/autobuild/utility.rb +54 -8
  39. data/lib/autobuild/version.rb +1 -1
  40. data/lib/autobuild.rb +0 -3
  41. metadata +42 -26
  42. data/.travis.yml +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba0c35a9d6c2a15141684c9836ca9b5763b90dfdc46832a31d0f343a6837ef4d
4
- data.tar.gz: 3d5b3c22bdd6b3c082e9ed209a656b637274bd2054c8e211260ff28f8d058cd9
3
+ metadata.gz: 4bf4fb952c18b27c30e09e50c005f4e07e475c4d0c21c2cac3c81e4e62dc41a0
4
+ data.tar.gz: dbc32874e7cdf92e6dff9b18718a8922c6d602abe45701ee4dda17fccd04e684
5
5
  SHA512:
6
- metadata.gz: 12cd8fb953e0ce63ba4679dce12ab0e8fb46678815c6baab0db97c44097fd74fe5c684f43a2e6f0de04630cf0ee6cb70a9a34fbe94b88e390a062de65cf335fc
7
- data.tar.gz: aee8a423d0b011b6d17b70554a79527e67280a2004aa7b0709a4bce740d7ff3d6df4a5c2923f9f26e9d12971d8c2657cfda989952a7cfdfbda5e6516f0c82005
6
+ metadata.gz: 0d9408d8aa15779a19ceaae45feafb53cea942aef147becce39835abebf873717c0f9d4d9ed04f7a47052e31120b4c80ec1b480c002ceb4d40458bd0881f1bde
7
+ data.tar.gz: 8e84128190fcd911790ff20803d1965f955762affa1979bee79188dcff64a8799c4f4267d86985842008103a835004d7921794717c141e65fc97f6c8d46c638d
@@ -0,0 +1,25 @@
1
+ name: Rubocop
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ matrix:
11
+ ruby-version: ["2.7", "2.6", "2.5"]
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby ${{ matrix.ruby-version }}
16
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
17
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
18
+ # uses: ruby/setup-ruby@v1
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ - name: Install dependencies
23
+ run: bundle install
24
+ - name: Run rubocop
25
+ run: bundle exec rubocop
@@ -0,0 +1,30 @@
1
+ name: Unit Tests
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ matrix:
11
+ ruby-version: ["2.7", "2.6", "2.5"]
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby ${{ matrix.ruby-version }}
16
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
17
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
18
+ # uses: ruby/setup-ruby@v1
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ - name: Install dependencies
23
+ run: bundle install
24
+ - name: Run tests
25
+ run: bundle exec rake test
26
+ env:
27
+ GIT_AUTHOR_NAME: autobuild CI Git Identity
28
+ GIT_AUTHOR_EMAIL: autobuild@github.actions
29
+ GIT_COMMITTER_NAME: autobuild CI Git Identity
30
+ GIT_COMMITTER_EMAIL: autobuild@github.actions
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ inherit_gem:
2
2
  rubocop-rock: defaults.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: "2.3"
5
+ TargetRubyVersion: "2.5"
6
6
  Exclude:
7
7
  - lib/autobuild/packages/genom.rb
8
8
  - vendor/**/*
@@ -17,9 +17,6 @@ Style/TrivialAccessors:
17
17
  Naming/PredicateName:
18
18
  Enabled: false
19
19
 
20
- Lint/SplatKeywordArguments:
21
- Enabled: false
22
-
23
20
  Style/FrozenStringLiteralComment:
24
21
  Enabled: false
25
22
 
@@ -33,7 +30,7 @@ Naming/FileName:
33
30
 
34
31
 
35
32
 
36
- Layout/AlignParameters:
33
+ Layout/ParameterAlignment:
37
34
  Enabled: false
38
35
 
39
36
  Layout/DotPosition:
@@ -42,7 +39,7 @@ Layout/DotPosition:
42
39
  Layout/FirstParameterIndentation:
43
40
  Enabled: false
44
41
 
45
- Layout/IndentAssignment:
42
+ Layout/AssignmentIndentation:
46
43
  Enabled: false
47
44
 
48
45
  Layout/IndentationWidth:
@@ -96,7 +93,7 @@ Style/PerlBackrefs:
96
93
  Style/StringLiterals:
97
94
  Enabled: false
98
95
 
99
- Layout/IndentHeredoc:
96
+ Layout/HeredocIndentation:
100
97
  Enabled: false
101
98
 
102
99
  Metrics/LineLength:
@@ -104,4 +101,14 @@ Metrics/LineLength:
104
101
  Exclude:
105
102
  - test/**/*
106
103
 
104
+ Style/StringConcatenation:
105
+ Enabled: false
106
+
107
+ Style/StderrPuts:
108
+ Enabled: false
109
+
110
+ Style/GlobalStdStream:
111
+ Enabled: false
107
112
 
113
+ Style/OptionalBooleanParameter:
114
+ Enabled: false
data/autobuild.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'autobuild/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "autobuild"
7
7
  s.version = Autobuild::VERSION
8
- s.required_ruby_version = '>= 2.3.0'
8
+ s.required_ruby_version = '>= 2.5.0'
9
9
  s.authors = ["Sylvain Joyeux"]
10
10
  s.email = "sylvain.joyeux@m4x.org"
11
11
  s.summary = "Library to handle build systems and import mechanisms"
@@ -23,14 +23,16 @@ Gem::Specification.new do |s|
23
23
  s.files = `git ls-files -z`.split("\x0")
24
24
  .reject { |f| f.match(%r{^(test|spec|features)/}) }
25
25
 
26
- s.add_runtime_dependency 'pastel', '~> 0.7.0', '>= 0.7.0'
27
- s.add_runtime_dependency "rake", "~> 12.0", ">= 12.3.0"
28
- s.add_runtime_dependency 'tty-cursor', '~> 0.5.0'
29
- s.add_runtime_dependency 'tty-prompt', '~> 0.15.0'
30
- s.add_runtime_dependency 'tty-screen', '~> 0.6.4'
26
+ s.add_runtime_dependency "concurrent-ruby", "~> 1.1"
27
+ s.add_runtime_dependency "pastel", "~> 0.7.0"
28
+ s.add_runtime_dependency "rake", "~> 13.0"
29
+ s.add_runtime_dependency 'tty-cursor', '~> 0.7.0'
30
+ s.add_runtime_dependency 'tty-prompt', '~> 0.21.0'
31
+ s.add_runtime_dependency 'tty-screen', '~> 0.8.0'
31
32
  s.add_runtime_dependency "utilrb", "~> 3.0", ">= 3.0"
32
33
  s.add_development_dependency "fakefs"
33
34
  s.add_development_dependency "flexmock", '~> 2.0', ">= 2.0.0"
34
35
  s.add_development_dependency "minitest", "~> 5.0", ">= 5.0"
35
36
  s.add_development_dependency "simplecov"
37
+ s.add_development_dependency "timecop"
36
38
  end
data/bin/autobuild CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  begin
4
4
  require 'daemons'
5
- rescue LoadError # rubocop:disable Lint/HandleExceptions
5
+ rescue LoadError # rubocop:disable Lint/SuppressedException
6
6
  end
7
7
 
8
8
  require 'autobuild'
@@ -6,8 +6,7 @@ module Autobuild
6
6
  class BuildLogfile
7
7
  Entry = Struct.new :package, :phase, :start_time, :duration
8
8
 
9
- attr_reader :by_package
10
- attr_reader :by_phase
9
+ attr_reader :by_package, :by_phase
11
10
 
12
11
  def initialize(entries = Array.new)
13
12
  @entries = entries.dup
@@ -198,7 +198,7 @@ module Autobuild
198
198
  opts.separator ""
199
199
  opts.separator "General behaviour"
200
200
  opts.on('--nice NICE', Integer,
201
- 'nice the subprocesses to the given value') do |v|
201
+ 'nice the subprocesses to the given value') do |v|
202
202
  Autobuild.nice = v
203
203
  end
204
204
  opts.on("-h", "--help", "Show this message") do
@@ -253,7 +253,7 @@ module Autobuild
253
253
  opts.separator ""
254
254
  opts.separator "Mail reports"
255
255
  opts.on("--mail-from EMAIL", String,
256
- "From: field of the sent mails") do |from_email|
256
+ "From: field of the sent mails") do |from_email|
257
257
  mail[:from] = from_email
258
258
  end
259
259
  opts.on("--mail-to EMAILS", String, "comma-separated list of emails "\
@@ -262,7 +262,7 @@ module Autobuild
262
262
  mail[:to] += emails.split(',')
263
263
  end
264
264
  opts.on("--mail-subject SUBJECT", String,
265
- "Subject: field of the sent mails") do |subject_email|
265
+ "Subject: field of the sent mails") do |subject_email|
266
266
  mail[:subject] = subject_email
267
267
  end
268
268
  opts.on("--mail-smtp HOSTNAME", String, "address of the mail server "\
@@ -301,7 +301,7 @@ module Autobuild
301
301
 
302
302
  def self.apply(packages, buildname = "autobuild", phases = [], options = Hash.new)
303
303
  options = Kernel.validate_options options,
304
- parallel: Autobuild.parallel_build_level
304
+ parallel: Autobuild.parallel_build_level
305
305
 
306
306
  if Autobuild.mail[:to]
307
307
  if !Autobuild::HAS_RMAIL
@@ -352,7 +352,20 @@ module Autobuild
352
352
  invoker = Autobuild::RakeTaskParallelism.new(options[:parallel])
353
353
  Autobuild.parallel_task_manager = invoker
354
354
  phases.each do |phase|
355
- invoker.invoke_parallel([Rake::Task["#{buildname}-#{phase}"]])
355
+ package_tasks = packages.each_with_object({}) do |pkg_name, h|
356
+ h["#{pkg_name}-#{phase}"] = true
357
+ end
358
+ callback =
359
+ if block_given?
360
+ proc do |task|
361
+ yield(task.package, phase) if package_tasks[task.name]
362
+ end
363
+ else
364
+ proc {}
365
+ end
366
+
367
+ invoker.invoke_parallel([Rake::Task["#{buildname}-#{phase}"]],
368
+ completion_callback: callback)
356
369
  end
357
370
  ensure
358
371
  Autobuild.parallel_task_manager = nil
@@ -109,6 +109,7 @@ module Autobuild
109
109
 
110
110
  stamps = dependencies.map { |pkg| Autobuild::Package[pkg].installstamp }
111
111
  file configurestamp => stamps do
112
+ @install_invoked = true
112
113
  isolate_errors do
113
114
  ensure_dependencies_installed
114
115
  configure
@@ -118,6 +119,7 @@ module Autobuild
118
119
  task "#{name}-prepare" => configurestamp
119
120
 
120
121
  file buildstamp => [srcdir, configurestamp] do
122
+ @install_invoked = true
121
123
  isolate_errors do
122
124
  ensure_dependencies_installed
123
125
  build
@@ -132,7 +134,7 @@ module Autobuild
132
134
  def configure
133
135
  if File.exist?(builddir) && !File.directory?(builddir)
134
136
  raise ConfigException.new(self, 'configure'),
135
- "#{builddir} already exists but is not a directory"
137
+ "#{builddir} already exists but is not a directory"
136
138
  end
137
139
 
138
140
  FileUtils.mkdir_p builddir unless File.directory?(builddir)
@@ -89,10 +89,7 @@ module Autobuild
89
89
  # path separator (File::PATH_SEPARATOR)
90
90
  attr_reader :environment
91
91
 
92
- attr_reader :inherited_variables
93
-
94
- attr_reader :system_env
95
- attr_reader :original_env
92
+ attr_reader :inherited_variables, :system_env, :original_env, :target_arch
96
93
 
97
94
  # The set of environment variables that are known to hold paths on the
98
95
  # filesystem
@@ -162,7 +159,8 @@ module Autobuild
162
159
  inherited_environment.delete(name)
163
160
  init_from_env(name)
164
161
  else
165
- environment.keys.each do |env_key|
162
+ keys = environment.keys # get keys first to avoid delete-while-iterating
163
+ keys.each do |env_key|
166
164
  reset(env_key)
167
165
  end
168
166
  end
@@ -180,7 +178,8 @@ module Autobuild
180
178
  environment[name] = nil
181
179
  inherited_environment[name] = nil
182
180
  else
183
- environment.keys.each do |env_key|
181
+ keys = environment.keys # get keys first to avoid delete-while-iterating
182
+ keys.each do |env_key|
184
183
  clear(env_key)
185
184
  end
186
185
  end
@@ -228,7 +227,9 @@ module Autobuild
228
227
  # @see inherit? inherit
229
228
  def inherit=(value)
230
229
  @inherit = value
231
- inherited_environment.keys.each do |env_name|
230
+ # get keys first to avoid modify-while-iterating
231
+ keys = inherited_environment.keys
232
+ keys.each do |env_name|
232
233
  init_from_env(env_name)
233
234
  end
234
235
  end
@@ -328,7 +329,7 @@ module Autobuild
328
329
  end
329
330
  end
330
331
  options = Kernel.validate_options options,
331
- inheritance_mode: :expand
332
+ inheritance_mode: :expand
332
333
  inheritance_mode = options[:inheritance_mode]
333
334
 
334
335
  if !include?(name)
@@ -511,8 +512,8 @@ module Autobuild
511
512
  end
512
513
  export.update.each do |name, (with_inheritance, without_inheritance)|
513
514
  io.puts format(SHELL_CONDITIONAL_SET_COMMAND, name,
514
- with_inheritance.join(File::PATH_SEPARATOR),
515
- without_inheritance.join(File::PATH_SEPARATOR))
515
+ with_inheritance.join(File::PATH_SEPARATOR),
516
+ without_inheritance.join(File::PATH_SEPARATOR))
516
517
  io.puts format(SHELL_EXPORT_COMMAND, name)
517
518
  end
518
519
  source_after(shell: shell).each do |path|
@@ -555,9 +556,8 @@ module Autobuild
555
556
  # DEPRECATED: use add_path instead
556
557
  def self.pathvar(path, varname)
557
558
  if File.directory?(path)
558
- if block_given?
559
- return unless yield(path)
560
- end
559
+ return if block_given? && !yield(path)
560
+
561
561
  add_path(varname, path)
562
562
  end
563
563
  end
@@ -614,8 +614,6 @@ module Autobuild
614
614
  @arch_size, @arch_names = nil
615
615
  end
616
616
 
617
- attr_reader :target_arch
618
-
619
617
  def arch_names
620
618
  return @arch_names if @arch_names
621
619
 
@@ -635,38 +633,24 @@ module Autobuild
635
633
  add_prefix(newprefix, includes)
636
634
  end
637
635
 
638
- # rubocop:disable Metrics/LineLength
639
- PKGCONFIG_INFO = [
640
- %r{Scanning directory (?:#\d+ )?'(.*/)((?:lib|lib64|share)/.*)'$},
641
- %r{Cannot open directory (?:#\d+ )?'.*/((?:lib|lib64|share)/.*)' in package search path:.*}
642
- ].freeze
643
- # rubocop:enable Metrics/LineLength
636
+ PKGCONFIG_PATH_RX = %r{.*/((?:lib|lib64|share)/.*)}.freeze
644
637
 
645
638
  # Returns the system-wide search path that is embedded in pkg-config
646
639
  def default_pkgconfig_search_suffixes
647
- found_path_rx = PKGCONFIG_INFO[0]
648
- nonexistent_path_rx = PKGCONFIG_INFO[1]
649
-
650
- unless @default_pkgconfig_search_suffixes
651
- pkg_config = Autobuild.tool("pkg-config")
652
- output = `LANG=C PKG_CONFIG_PATH= #{pkg_config} --debug 2>&1`.split("\n")
653
- found_paths = output.grep(found_path_rx).
654
- map { |l| l.gsub(found_path_rx, '\2') }.
655
- to_set
656
- not_found = output.grep(nonexistent_path_rx).
657
- map { |l| l.gsub(nonexistent_path_rx, '\1') }.
658
- to_set
659
- @default_pkgconfig_search_suffixes = found_paths | not_found
660
- end
661
- @default_pkgconfig_search_suffixes
640
+ @default_pkgconfig_search_suffixes ||=
641
+ `LANG=C #{Autobuild.tool("pkg-config")} --variable pc_path pkg-config`
642
+ .strip
643
+ .split(":")
644
+ .grep(PKGCONFIG_PATH_RX)
645
+ .map { |l| l.gsub(PKGCONFIG_PATH_RX, '\1') }
646
+ .to_set
662
647
  end
663
648
 
664
649
  # Updates the environment when a new prefix has been added
665
650
  def add_prefix(newprefix, includes = nil)
666
- if !includes || includes.include?('PATH')
667
- if File.directory?("#{newprefix}/bin")
668
- add_path('PATH', "#{newprefix}/bin")
669
- end
651
+ if (!includes || includes.include?('PATH')) &&
652
+ File.directory?("#{newprefix}/bin")
653
+ add_path('PATH', "#{newprefix}/bin")
670
654
  end
671
655
 
672
656
  if !includes || includes.include?('PKG_CONFIG_PATH')
@@ -717,7 +701,7 @@ module Autobuild
717
701
  begin
718
702
  stat = File.stat(full)
719
703
  return full if stat.file? && stat.executable?
720
- rescue ::Exception # rubocop:disable Lint/HandleExceptions
704
+ rescue ::Exception # rubocop:disable Lint/SuppressedException
721
705
  end
722
706
  end
723
707
  nil
@@ -743,7 +727,7 @@ module Autobuild
743
727
  def prepare
744
728
  # Set up some important autobuild parameters
745
729
  inherit 'PATH', 'PKG_CONFIG_PATH', 'RUBYLIB', \
746
- LIBRARY_PATH, 'CMAKE_PREFIX_PATH', 'PYTHONPATH'
730
+ LIBRARY_PATH, 'CMAKE_PREFIX_PATH', 'PYTHONPATH'
747
731
  end
748
732
 
749
733
  # Method called to filter the environment variables before they are set,
@@ -868,9 +852,8 @@ module Autobuild
868
852
  # @deprecated use {Env#add_path} on {.env} instead
869
853
  def self.pathvar(path, varname)
870
854
  if File.directory?(path)
871
- if block_given?
872
- return unless yield(path)
873
- end
855
+ return if block_given? && !yield(path)
856
+
874
857
  env.add_path(varname, path)
875
858
  end
876
859
  end
@@ -24,6 +24,7 @@ module Autobuild
24
24
  @target = target
25
25
  @phase = phase
26
26
  @retry = options[:retry]
27
+ super()
27
28
  end
28
29
 
29
30
  alias exception_message to_s
@@ -52,10 +53,11 @@ module Autobuild
52
53
  class ConfigException < PhaseException
53
54
  def initialize(target = nil, phase = nil, options = Hash.new)
54
55
  options, other_options = Kernel.filter_options options,
55
- retry: false
56
+ retry: false
56
57
  super(target, phase, options.merge(other_options))
57
58
  end
58
59
  end
60
+
59
61
  ## An error occured in a package
60
62
  class PackageException < PhaseException
61
63
  def mail?
@@ -64,7 +66,7 @@ module Autobuild
64
66
 
65
67
  def initialize(target = nil, phase = nil, options = Hash.new)
66
68
  options, other_options = Kernel.filter_options options,
67
- retry: false
69
+ retry: false
68
70
  super(target, phase, options.merge(other_options))
69
71
  end
70
72
  end
@@ -76,6 +78,7 @@ module Autobuild
76
78
 
77
79
  # The subcommand is not found
78
80
  class CommandNotFound < PhaseException; end
81
+
79
82
  # An error occured while running a subcommand
80
83
  class SubcommandFailed < PhaseException
81
84
  def mail?
@@ -84,8 +87,10 @@ module Autobuild
84
87
 
85
88
  attr_writer :retry
86
89
  attr_reader :command, :logfile, :status, :output
90
+
87
91
  def initialize(*args)
88
- if args.size == 1
92
+ case args.size
93
+ when 1
89
94
  sc = args[0]
90
95
  target = sc.target
91
96
  command = sc.command
@@ -93,7 +98,7 @@ module Autobuild
93
98
  status = sc.status
94
99
  output = sc.output
95
100
  @orig_message = sc.exception_message
96
- elsif args.size == 4 || args.size == 5
101
+ when 4, 5
97
102
  target, command, logfile, status, output = *args
98
103
  else
99
104
  raise ArgumentError, "wrong number of arguments, should be 1 or 4..5"
@@ -140,13 +145,14 @@ module Autobuild
140
145
 
141
146
  # The exception type that is used to report multiple errors that occured
142
147
  # when ignore_errors is set
143
- class CompositeException < Autobuild::Exception
148
+ class CompositeException < PhaseException
144
149
  # The array of exception objects representing all the errors that
145
150
  # occured during the build
146
151
  attr_reader :original_errors
147
152
 
148
153
  def initialize(original_errors)
149
154
  @original_errors = original_errors
155
+ super()
150
156
  end
151
157
 
152
158
  def mail?