autobuild 1.20.0 → 1.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) 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 +7 -6
  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 +126 -58
  10. data/lib/autobuild/exceptions.rb +13 -6
  11. data/lib/autobuild/import/archive.rb +33 -23
  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 +155 -73
  16. data/lib/autobuild/import/hg.rb +7 -7
  17. data/lib/autobuild/import/svn.rb +17 -10
  18. data/lib/autobuild/importer.rb +37 -39
  19. data/lib/autobuild/mail_reporter.rb +5 -2
  20. data/lib/autobuild/package.rb +28 -15
  21. data/lib/autobuild/packages/autotools.rb +6 -10
  22. data/lib/autobuild/packages/cmake.rb +13 -9
  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 +19 -8
  28. data/lib/autobuild/packages/ruby.rb +5 -5
  29. data/lib/autobuild/parallel.rb +9 -17
  30. data/lib/autobuild/pkgconfig.rb +1 -0
  31. data/lib/autobuild/progress_display.rb +67 -43
  32. data/lib/autobuild/rake_task_extension.rb +6 -0
  33. data/lib/autobuild/reporting.rb +15 -9
  34. data/lib/autobuild/subcommand.rb +30 -26
  35. data/lib/autobuild/test_utility.rb +6 -3
  36. data/lib/autobuild/timestamps.rb +3 -3
  37. data/lib/autobuild/utility.rb +22 -4
  38. data/lib/autobuild/version.rb +1 -1
  39. data/lib/autobuild.rb +0 -3
  40. metadata +28 -26
  41. data/.travis.yml +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b347c81cc5ac09e4f967df3dd5f53bca82fb3ba2a1a4a2e76b1b2d20ba19869
4
- data.tar.gz: 6eaa54db5306f069ce5e9809b708df1bb4c5def84dc1553c953a3e38319cbf26
3
+ metadata.gz: 6431400922a5accc7c11c921745648a3a7fa65e92023bc700b26e6d975bd2d6a
4
+ data.tar.gz: bd29297ec7e7902e067a08ecb9ea4837a051be82b7db7c6ca40c207657d587bc
5
5
  SHA512:
6
- metadata.gz: ccefa69f82809031debaeee77adde985c2de4d88c738e9b439cf7e839bc511f2f4c757486625f88a91541d97c16566217a544831c35924ea76cae98920d9f59d
7
- data.tar.gz: 9f4b9b5c38e9072104dc052c630ca7a49a915331526cdbc624d2ef725eef44987b97b97667ebcafead9afb145fcbb3cee5a921f699aed101ec99efd611c28352
6
+ metadata.gz: 726b002c5f1e6a51efe77397546762ce1aa50e546bddecaec4a379a69943646e414e6c0d7ae8a470d29be982a2a50541be800ae40d30a6206723185d1937e30a
7
+ data.tar.gz: 95088358f807bb6edfd52746e8c30ed85b52b05f2318c09be17fe05b45484f554205d48d280094dc378e322b26ae468a2b5ad72468c34b9b369e4d0aa085a5fa
@@ -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,11 +23,12 @@ 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"
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
@@ -361,7 +361,7 @@ module Autobuild
361
361
  yield(task.package, phase) if package_tasks[task.name]
362
362
  end
363
363
  else
364
- proc { }
364
+ proc {}
365
365
  end
366
366
 
367
367
  invoker.invoke_parallel([Rake::Task["#{buildname}-#{phase}"]],
@@ -29,37 +29,44 @@ module Autobuild
29
29
 
30
30
  SHELL_VAR_EXPANSION =
31
31
  if windows? then "%%%s%%".freeze
32
- else "$%s".freeze
32
+ else
33
+ "$%s".freeze
33
34
  end
34
35
  SHELL_SET_COMMAND =
35
36
  if windows? then "set %s=%s".freeze
36
- else "%s=\"%s\"".freeze
37
+ else
38
+ "%s=\"%s\"".freeze
37
39
  end
38
40
  SHELL_CONDITIONAL_SET_COMMAND =
39
41
  if windows? then "set %s=%s".freeze
40
- else "if test -z \"$%1$s\"; then\n %1$s=\"%3$s\"\n"\
42
+ else
43
+ "if test -z \"$%1$s\"; then\n %1$s=\"%3$s\"\n"\
41
44
  "else\n %1$s=\"%2$s\"\nfi".freeze
42
45
  end
43
46
  SHELL_UNSET_COMMAND = "unset %s".freeze
44
47
  SHELL_EXPORT_COMMAND =
45
48
  if windows? then "set %s".freeze
46
- else "export %s".freeze
49
+ else
50
+ "export %s".freeze
47
51
  end
48
52
  SHELL_SOURCE_SCRIPT =
49
53
  if windows? then "%s".freeze
50
- else '. "%s"'.freeze
54
+ else
55
+ '. "%s"'.freeze
51
56
  end
52
57
 
53
58
  LIBRARY_PATH =
54
59
  if macos? then 'DYLD_LIBRARY_PATH'.freeze
55
60
  elsif windows? then 'PATH'.freeze
56
- else 'LD_LIBRARY_PATH'.freeze
61
+ else
62
+ 'LD_LIBRARY_PATH'.freeze
57
63
  end
58
64
 
59
65
  LIBRARY_SUFFIX =
60
66
  if macos? then 'dylib'
61
67
  elsif windows? then 'dll'
62
- else 'so'
68
+ else
69
+ 'so'
63
70
  end
64
71
 
65
72
  ORIGINAL_ENV = Hash.new
@@ -89,10 +96,7 @@ module Autobuild
89
96
  # path separator (File::PATH_SEPARATOR)
90
97
  attr_reader :environment
91
98
 
92
- attr_reader :inherited_variables
93
-
94
- attr_reader :system_env
95
- attr_reader :original_env
99
+ attr_reader :inherited_variables, :system_env, :original_env, :target_arch
96
100
 
97
101
  # The set of environment variables that are known to hold paths on the
98
102
  # filesystem
@@ -162,7 +166,8 @@ module Autobuild
162
166
  inherited_environment.delete(name)
163
167
  init_from_env(name)
164
168
  else
165
- environment.keys.each do |env_key|
169
+ keys = environment.keys # get keys first to avoid delete-while-iterating
170
+ keys.each do |env_key|
166
171
  reset(env_key)
167
172
  end
168
173
  end
@@ -180,7 +185,8 @@ module Autobuild
180
185
  environment[name] = nil
181
186
  inherited_environment[name] = nil
182
187
  else
183
- environment.keys.each do |env_key|
188
+ keys = environment.keys # get keys first to avoid delete-while-iterating
189
+ keys.each do |env_key|
184
190
  clear(env_key)
185
191
  end
186
192
  end
@@ -212,7 +218,8 @@ module Autobuild
212
218
  if @inherit
213
219
  if name
214
220
  @inherited_variables.include?(name)
215
- else true
221
+ else
222
+ true
216
223
  end
217
224
  end
218
225
  end
@@ -228,7 +235,9 @@ module Autobuild
228
235
  # @see inherit? inherit
229
236
  def inherit=(value)
230
237
  @inherit = value
231
- inherited_environment.keys.each do |env_name|
238
+ # get keys first to avoid modify-while-iterating
239
+ keys = inherited_environment.keys
240
+ keys.each do |env_name|
232
241
  init_from_env(env_name)
233
242
  end
234
243
  end
@@ -244,7 +253,8 @@ module Autobuild
244
253
  flag =
245
254
  if !names.last.respond_to?(:to_str)
246
255
  names.pop
247
- else true
256
+ else
257
+ true
248
258
  end
249
259
 
250
260
  if flag
@@ -328,7 +338,7 @@ module Autobuild
328
338
  end
329
339
  end
330
340
  options = Kernel.validate_options options,
331
- inheritance_mode: :expand
341
+ inheritance_mode: :expand
332
342
  inheritance_mode = options[:inheritance_mode]
333
343
 
334
344
  if !include?(name)
@@ -341,7 +351,8 @@ module Autobuild
341
351
  inherited_environment[name] || []
342
352
  elsif inheritance_mode == :keep && inherit?(name)
343
353
  ["$#{name}"]
344
- else []
354
+ else
355
+ []
345
356
  end
346
357
 
347
358
  value = []
@@ -438,7 +449,8 @@ module Autobuild
438
449
  if file
439
450
  @source_before << { file: file, shell: shell }
440
451
  source_before(shell: shell) # for backwards compatibility
441
- else @source_before.select { |pair| pair[:shell] == shell }
452
+ else
453
+ @source_before.select { |pair| pair[:shell] == shell }
442
454
  .map { |item| item[:file] }
443
455
  end
444
456
  end
@@ -456,7 +468,8 @@ module Autobuild
456
468
  if file
457
469
  @source_after << { file: file, shell: shell }
458
470
  source_after(shell: shell) # for backwards compatibility
459
- else @source_after.select { |pair| pair[:shell] == shell }
471
+ else
472
+ @source_after.select { |pair| pair[:shell] == shell }
460
473
  .map { |item| item[:file] }
461
474
  end
462
475
  end
@@ -511,8 +524,8 @@ module Autobuild
511
524
  end
512
525
  export.update.each do |name, (with_inheritance, without_inheritance)|
513
526
  io.puts format(SHELL_CONDITIONAL_SET_COMMAND, name,
514
- with_inheritance.join(File::PATH_SEPARATOR),
515
- without_inheritance.join(File::PATH_SEPARATOR))
527
+ with_inheritance.join(File::PATH_SEPARATOR),
528
+ without_inheritance.join(File::PATH_SEPARATOR))
516
529
  io.puts format(SHELL_EXPORT_COMMAND, name)
517
530
  end
518
531
  source_after(shell: shell).each do |path|
@@ -541,7 +554,8 @@ module Autobuild
541
554
  with_inheritance = with_inheritance.map do |value|
542
555
  if value == variable_expansion
543
556
  base_env[name]
544
- else value
557
+ else
558
+ value
545
559
  end
546
560
  end
547
561
  result[name] = with_inheritance.join(File::PATH_SEPARATOR)
@@ -555,9 +569,8 @@ module Autobuild
555
569
  # DEPRECATED: use add_path instead
556
570
  def self.pathvar(path, varname)
557
571
  if File.directory?(path)
558
- if block_given?
559
- return unless yield(path)
560
- end
572
+ return if block_given? && !yield(path)
573
+
561
574
  add_path(varname, path)
562
575
  end
563
576
  end
@@ -604,7 +617,8 @@ module Autobuild
604
617
  @arch_size ||=
605
618
  if RbConfig::CONFIG['host_cpu'] =~ /64/
606
619
  64
607
- else 32
620
+ else
621
+ 32
608
622
  end
609
623
  @arch_size
610
624
  end
@@ -614,8 +628,6 @@ module Autobuild
614
628
  @arch_size, @arch_names = nil
615
629
  end
616
630
 
617
- attr_reader :target_arch
618
-
619
631
  def arch_names
620
632
  return @arch_names if @arch_names
621
633
 
@@ -635,38 +647,85 @@ module Autobuild
635
647
  add_prefix(newprefix, includes)
636
648
  end
637
649
 
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
650
+ def default_cmake_search_globs(prefix, *file_globs)
651
+ lib_globs = %w[lib]
652
+
653
+ case arch_size
654
+ when 32
655
+ lib_globs << "lib32"
656
+ lib_globs << "libx32"
657
+ when 64
658
+ lib_globs << "lib64"
659
+ end
660
+
661
+ unless arch_names.empty?
662
+ arch_names.each do |arch_name|
663
+ lib_globs << File.join("lib", arch_name)
664
+ end
665
+ end
666
+
667
+ lib_share_glob = "{#{lib_globs.join(',')},share}"
668
+ file_glob = "{#{file_globs.join(',')}}"
669
+
670
+ # Reference: https://cmake.org/cmake/help/latest/command/find_package.html
671
+ #
672
+ # <prefix>/ (W)
673
+ # <prefix>/(cmake|CMake)/ (W)
674
+ # <prefix>/<name>*/ (W)
675
+ # <prefix>/<name>*/(cmake|CMake)/ (W)
676
+ # <prefix>/(lib/<arch>|lib*|share)/cmake/<name>*/ (U)
677
+ # <prefix>/(lib/<arch>|lib*|share)/<name>*/ (U)
678
+ # <prefix>/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/ (U)
679
+ # <prefix>/<name>*/(lib/<arch>|lib*|share)/cmake/<name>*/ (W/U)
680
+ # <prefix>/<name>*/(lib/<arch>|lib*|share)/<name>*/ (W/U)
681
+ # <prefix>/<name>*/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/ (W/U)
682
+ [
683
+ File.join(prefix, file_glob),
684
+ File.join(prefix, "{cmake,CMake}", file_glob),
685
+ File.join(prefix, "*", file_glob),
686
+ File.join(prefix, "*", "{cmake/CMake}", file_glob),
687
+ File.join(prefix, lib_share_glob, "cmake", "*", file_glob),
688
+ File.join(prefix, lib_share_glob, "*", file_glob),
689
+ File.join(prefix, lib_share_glob, "*", "{cmake,CMake}", file_glob),
690
+ File.join(prefix, "*", lib_share_glob, "cmake", "*", file_glob),
691
+ File.join(prefix, "*", lib_share_glob, "*", file_glob),
692
+ File.join(prefix, "*", lib_share_glob, "*", "{cmake,CMake}", file_glob)
693
+ ]
694
+ end
695
+
696
+ def has_cmake_files?(prefix, *file_globs)
697
+ default_cmake_search_globs(prefix, *file_globs).each do |glob_path|
698
+ return true unless Dir[glob_path].empty?
699
+ end
700
+ false
701
+ end
702
+
703
+ PKGCONFIG_PATH_RX = %r{.*/((?:lib|lib64|share)/.*)}.freeze
704
+
705
+ def pkgconfig_tool_path
706
+ @pkgconfig_tool_path ||= Autobuild.tool_in_path("pkg-config", env: self)
707
+ rescue ArgumentError
708
+ nil
709
+ end
644
710
 
645
711
  # Returns the system-wide search path that is embedded in pkg-config
646
712
  def default_pkgconfig_search_suffixes
647
- found_path_rx = PKGCONFIG_INFO[0]
648
- nonexistent_path_rx = PKGCONFIG_INFO[1]
713
+ return [] unless pkgconfig_tool_path
649
714
 
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
715
+ @default_pkgconfig_search_suffixes ||=
716
+ `LANG=C #{pkgconfig_tool_path} --variable pc_path pkg-config`
717
+ .strip
718
+ .split(":")
719
+ .grep(PKGCONFIG_PATH_RX)
720
+ .map { |l| l.gsub(PKGCONFIG_PATH_RX, '\1') }
721
+ .to_set
662
722
  end
663
723
 
664
724
  # Updates the environment when a new prefix has been added
665
725
  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
726
+ if (!includes || includes.include?('PATH')) &&
727
+ File.directory?("#{newprefix}/bin")
728
+ add_path('PATH', "#{newprefix}/bin")
670
729
  end
671
730
 
672
731
  if !includes || includes.include?('PKG_CONFIG_PATH')
@@ -686,6 +745,16 @@ module Autobuild
686
745
  end
687
746
  end
688
747
 
748
+ cmake_pairs = []
749
+ cmake_pairs << ["CMAKE_PREFIX_PATH", ["*-config.cmake", "*Config.cmake"]]
750
+ cmake_pairs << ["CMAKE_MODULE_PATH", ["Find*.cmake"]]
751
+ cmake_pairs.each do |cmake_var, cmake_file_globs|
752
+ if !includes || includes.include?(cmake_var)
753
+ has_cmake = has_cmake_files?(newprefix, *cmake_file_globs)
754
+ add_path(cmake_var, newprefix) if has_cmake
755
+ end
756
+ end
757
+
689
758
  # Validate the new rubylib path
690
759
  if !includes || includes.include?('RUBYLIB')
691
760
  new_rubylib = "#{newprefix}/lib"
@@ -717,7 +786,7 @@ module Autobuild
717
786
  begin
718
787
  stat = File.stat(full)
719
788
  return full if stat.file? && stat.executable?
720
- rescue ::Exception # rubocop:disable Lint/HandleExceptions
789
+ rescue ::Exception # rubocop:disable Lint/SuppressedException
721
790
  end
722
791
  end
723
792
  nil
@@ -743,7 +812,7 @@ module Autobuild
743
812
  def prepare
744
813
  # Set up some important autobuild parameters
745
814
  inherit 'PATH', 'PKG_CONFIG_PATH', 'RUBYLIB', \
746
- LIBRARY_PATH, 'CMAKE_PREFIX_PATH', 'PYTHONPATH'
815
+ LIBRARY_PATH, 'CMAKE_PREFIX_PATH', 'PYTHONPATH'
747
816
  end
748
817
 
749
818
  # Method called to filter the environment variables before they are set,
@@ -868,9 +937,8 @@ module Autobuild
868
937
  # @deprecated use {Env#add_path} on {.env} instead
869
938
  def self.pathvar(path, varname)
870
939
  if File.directory?(path)
871
- if block_given?
872
- return unless yield(path)
873
- end
940
+ return if block_given? && !yield(path)
941
+
874
942
  env.add_path(varname, path)
875
943
  end
876
944
  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
@@ -32,7 +33,8 @@ module Autobuild
32
33
  target_name =
33
34
  if target.respond_to?(:name)
34
35
  target.name
35
- else target.to_str
36
+ else
37
+ target.to_str
36
38
  end
37
39
 
38
40
  if target && phase
@@ -52,10 +54,11 @@ module Autobuild
52
54
  class ConfigException < PhaseException
53
55
  def initialize(target = nil, phase = nil, options = Hash.new)
54
56
  options, other_options = Kernel.filter_options options,
55
- retry: false
57
+ retry: false
56
58
  super(target, phase, options.merge(other_options))
57
59
  end
58
60
  end
61
+
59
62
  ## An error occured in a package
60
63
  class PackageException < PhaseException
61
64
  def mail?
@@ -64,7 +67,7 @@ module Autobuild
64
67
 
65
68
  def initialize(target = nil, phase = nil, options = Hash.new)
66
69
  options, other_options = Kernel.filter_options options,
67
- retry: false
70
+ retry: false
68
71
  super(target, phase, options.merge(other_options))
69
72
  end
70
73
  end
@@ -76,6 +79,7 @@ module Autobuild
76
79
 
77
80
  # The subcommand is not found
78
81
  class CommandNotFound < PhaseException; end
82
+
79
83
  # An error occured while running a subcommand
80
84
  class SubcommandFailed < PhaseException
81
85
  def mail?
@@ -84,8 +88,10 @@ module Autobuild
84
88
 
85
89
  attr_writer :retry
86
90
  attr_reader :command, :logfile, :status, :output
91
+
87
92
  def initialize(*args)
88
- if args.size == 1
93
+ case args.size
94
+ when 1
89
95
  sc = args[0]
90
96
  target = sc.target
91
97
  command = sc.command
@@ -93,7 +99,7 @@ module Autobuild
93
99
  status = sc.status
94
100
  output = sc.output
95
101
  @orig_message = sc.exception_message
96
- elsif args.size == 4 || args.size == 5
102
+ when 4, 5
97
103
  target, command, logfile, status, output = *args
98
104
  else
99
105
  raise ArgumentError, "wrong number of arguments, should be 1 or 4..5"
@@ -140,13 +146,14 @@ module Autobuild
140
146
 
141
147
  # The exception type that is used to report multiple errors that occured
142
148
  # when ignore_errors is set
143
- class CompositeException < Autobuild::Exception
149
+ class CompositeException < PhaseException
144
150
  # The array of exception objects representing all the errors that
145
151
  # occured during the build
146
152
  attr_reader :original_errors
147
153
 
148
154
  def initialize(original_errors)
149
155
  @original_errors = original_errors
156
+ super()
150
157
  end
151
158
 
152
159
  def mail?