autobuild 1.22.1 → 1.24.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: 48e8645a039ab9b7fa950f3264bc9e15a53901a82c34fef9a32e008f123b275e
4
- data.tar.gz: e6cfbaba2cf060c25c8bced04d8577c20275d2aabbdc0aac123ed1b43a9df4a7
3
+ metadata.gz: 56a551f16208e61f38188d81b0b944ef6ba663fbc3155ae7e55b009f2adda2e6
4
+ data.tar.gz: 60e5b9d1b8ffe8ff4e35d006960a251ef82467ee5d17adcb9d9d21e2e7f47b15
5
5
  SHA512:
6
- metadata.gz: 490828e178d20f24bc84d819cf9ac6fb3e6880cf5b9eb938fef540e18e8023008cd467d26fac61b46f531bb7abeadaa1822fd257437a7eb36d8c23ec8dc10906
7
- data.tar.gz: e7eb1e3bc9bfb1f59852766113cfdb981331c595a78c9ef2f7bc530a9cf3594a64f8775b498c27f9ac534296e12393011e172c79129d7abbca69cae7581f6525
6
+ metadata.gz: 30af86ba246a653daac4299675fe4b248b36b2d30750feefd567dc32c6768b9f4b60f877021253699336c5d01c54b69f1d7db6808a6d49ea12ff612f425ca01c
7
+ data.tar.gz: 16e7849423378e7e5e89f0e40e7cc77173e87290954734aa86195cf15547388bce6a7b234aaf8857593e2d513b9daf4634759026706a6f2e54eb2044b7ee8b96
@@ -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
@@ -211,7 +218,8 @@ module Autobuild
211
218
  if @inherit
212
219
  if name
213
220
  @inherited_variables.include?(name)
214
- else true
221
+ else
222
+ true
215
223
  end
216
224
  end
217
225
  end
@@ -245,7 +253,8 @@ module Autobuild
245
253
  flag =
246
254
  if !names.last.respond_to?(:to_str)
247
255
  names.pop
248
- else true
256
+ else
257
+ true
249
258
  end
250
259
 
251
260
  if flag
@@ -342,7 +351,8 @@ module Autobuild
342
351
  inherited_environment[name] || []
343
352
  elsif inheritance_mode == :keep && inherit?(name)
344
353
  ["$#{name}"]
345
- else []
354
+ else
355
+ []
346
356
  end
347
357
 
348
358
  value = []
@@ -439,7 +449,8 @@ module Autobuild
439
449
  if file
440
450
  @source_before << { file: file, shell: shell }
441
451
  source_before(shell: shell) # for backwards compatibility
442
- else @source_before.select { |pair| pair[:shell] == shell }
452
+ else
453
+ @source_before.select { |pair| pair[:shell] == shell }
443
454
  .map { |item| item[:file] }
444
455
  end
445
456
  end
@@ -457,7 +468,8 @@ module Autobuild
457
468
  if file
458
469
  @source_after << { file: file, shell: shell }
459
470
  source_after(shell: shell) # for backwards compatibility
460
- else @source_after.select { |pair| pair[:shell] == shell }
471
+ else
472
+ @source_after.select { |pair| pair[:shell] == shell }
461
473
  .map { |item| item[:file] }
462
474
  end
463
475
  end
@@ -542,7 +554,8 @@ module Autobuild
542
554
  with_inheritance = with_inheritance.map do |value|
543
555
  if value == variable_expansion
544
556
  base_env[name]
545
- else value
557
+ else
558
+ value
546
559
  end
547
560
  end
548
561
  result[name] = with_inheritance.join(File::PATH_SEPARATOR)
@@ -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
@@ -633,17 +647,83 @@ module Autobuild
633
647
  add_prefix(newprefix, includes)
634
648
  end
635
649
 
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
+
636
703
  PKGCONFIG_PATH_RX = %r{.*/((?:lib|lib64|share)/.*)}.freeze
637
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
710
+
638
711
  # Returns the system-wide search path that is embedded in pkg-config
639
712
  def default_pkgconfig_search_suffixes
713
+ return [] unless pkgconfig_tool_path
714
+
640
715
  @default_pkgconfig_search_suffixes ||=
641
- `LANG=C #{Autobuild.tool("pkg-config")} --variable pc_path pkg-config`
716
+ `LANG=C #{pkgconfig_tool_path} --variable pc_path pkg-config`
642
717
  .strip
643
718
  .split(":")
644
719
  .grep(PKGCONFIG_PATH_RX)
645
720
  .map { |l| l.gsub(PKGCONFIG_PATH_RX, '\1') }
646
721
  .to_set
722
+ .add("/lib/pkgconfig")
723
+ # /lib/pkgconfig is added for packages that always install their
724
+ # libraries in /lib/ instead of the system mandated directory
725
+ # (/lib/x86_64-linux-gnu/ for 64bit x86 ubuntu multiarch,
726
+ # /lib64/ for some other 64bit systems)
647
727
  end
648
728
 
649
729
  # Updates the environment when a new prefix has been added
@@ -670,6 +750,16 @@ module Autobuild
670
750
  end
671
751
  end
672
752
 
753
+ cmake_pairs = []
754
+ cmake_pairs << ["CMAKE_PREFIX_PATH", ["*-config.cmake", "*Config.cmake"]]
755
+ cmake_pairs << ["CMAKE_MODULE_PATH", ["Find*.cmake"]]
756
+ cmake_pairs.each do |cmake_var, cmake_file_globs|
757
+ if !includes || includes.include?(cmake_var)
758
+ has_cmake = has_cmake_files?(newprefix, *cmake_file_globs)
759
+ add_path(cmake_var, newprefix) if has_cmake
760
+ end
761
+ end
762
+
673
763
  # Validate the new rubylib path
674
764
  if !includes || includes.include?('RUBYLIB')
675
765
  new_rubylib = "#{newprefix}/lib"
@@ -33,7 +33,8 @@ module Autobuild
33
33
  target_name =
34
34
  if target.respond_to?(:name)
35
35
  target.name
36
- else target.to_str
36
+ else
37
+ target.to_str
37
38
  end
38
39
 
39
40
  if target && phase
@@ -529,7 +529,8 @@ module Autobuild
529
529
 
530
530
  if mode == Zip
531
531
  main_dir = if @options[:no_subdirectory] then package.srcdir
532
- else base_dir
532
+ else
533
+ base_dir
533
534
  end
534
535
 
535
536
  FileUtils.mkdir_p base_dir
@@ -10,7 +10,26 @@ module Autobuild
10
10
  # Exception raised when a network access is needed while only_local is true
11
11
  class NetworkAccessNeeded < RuntimeError; end
12
12
 
13
+ @default_fingerprint_mode = "commit"
14
+
13
15
  class << self
16
+ # Sets the single_branch option globally for all Git importers
17
+ # This can can be overriden in the oporter options
18
+ attr_writer :single_branch
19
+
20
+ # Whether single_branch is enabled globally
21
+ def single_branch?
22
+ !!@single_branch
23
+ end
24
+
25
+ # Sets shallow clones globally (applies to submodules as well)
26
+ attr_writer :shallow
27
+
28
+ # Whether shallow clones is enabled globally
29
+ def shallow?
30
+ !!@shallow
31
+ end
32
+
14
33
  # Sets the default alternates path used by all Git importers
15
34
  #
16
35
  # Setting it explicitly overrides any value we get from the
@@ -40,9 +59,22 @@ module Autobuild
40
59
  @default_alternates = cache_dirs.map do |path|
41
60
  File.join(File.expand_path(path), '%s')
42
61
  end
43
- else Array.new
62
+ else
63
+ Array.new
44
64
  end
45
65
  end
66
+
67
+ # What git repository fingerprinting uses as reference
68
+ #
69
+ # Can either be
70
+ # - "commit" (the default). Use the commit hash of HEAD
71
+ # - "tree". Use the tree hash. This will return the same fingerprint
72
+ # for new commits that do not change the source code. However, it
73
+ # will fail to detect changes to the working copy that are due
74
+ # to git checkout filters.
75
+ #
76
+ # @return [String]
77
+ attr_accessor :default_fingerprint_mode
46
78
  end
47
79
 
48
80
  def self.default_config
@@ -141,17 +173,22 @@ module Autobuild
141
173
  Autobuild.warn " branch: 'master'"
142
174
  end
143
175
 
144
- gitopts, common = Kernel.filter_options options,
145
- push_to: nil,
146
- branch: nil,
147
- local_branch: nil,
148
- remote_branch: nil,
149
- tag: nil,
150
- commit: nil,
151
- repository_id: nil,
152
- source_id: nil,
153
- with_submodules: false,
154
- single_branch: false
176
+ gitopts, common = Kernel.filter_options(
177
+ options,
178
+ push_to: nil,
179
+ branch: nil,
180
+ local_branch: nil,
181
+ remote_branch: nil,
182
+ tag: nil,
183
+ commit: nil,
184
+ repository_id: nil,
185
+ source_id: nil,
186
+ with_submodules: false,
187
+ fingerprint_mode: Git.default_fingerprint_mode,
188
+ single_branch: Git.single_branch?,
189
+ shallow: Git.shallow?
190
+ )
191
+
155
192
  if gitopts[:branch] && branch
156
193
  raise ConfigException, "git branch specified with both the option hash "\
157
194
  "and the explicit parameter"
@@ -161,6 +198,7 @@ module Autobuild
161
198
  super(common)
162
199
 
163
200
  @single_branch = gitopts[:single_branch]
201
+ @shallow = gitopts[:shallow]
164
202
  @with_submodules = gitopts.delete(:with_submodules)
165
203
  @alternates =
166
204
  if @with_submodules
@@ -171,12 +209,13 @@ module Autobuild
171
209
 
172
210
  @remote_name = 'autobuild'
173
211
  @push_to = nil
212
+ @fingerprint_mode = gitopts[:fingerprint_mode]
174
213
  relocate(repository, gitopts)
175
214
  @additional_remotes = Array.new
176
215
  end
177
216
 
178
217
  def vcs_fingerprint(package)
179
- rev_parse(package, 'HEAD')
218
+ rev_parse(package, "HEAD", @fingerprint_mode)
180
219
  end
181
220
 
182
221
  # The name of the remote that should be set up by the importer
@@ -285,9 +324,17 @@ module Autobuild
285
324
  @single_branch
286
325
  end
287
326
 
327
+ # Whether clones should be shallow
328
+ def shallow?
329
+ @shallow
330
+ end
331
+
288
332
  # Set the {#single_branch?} predicate
289
333
  attr_writer :single_branch
290
334
 
335
+ # Set the {#shallow?} predicate
336
+ attr_writer :shallow
337
+
291
338
  # @api private
292
339
  #
293
340
  # Verifies that the package's {Package#importdir} points to a git
@@ -764,7 +811,8 @@ module Autobuild
764
811
  rescue SubcommandFailed => e
765
812
  if e.status == 1
766
813
  false
767
- else raise
814
+ else
815
+ raise
768
816
  end
769
817
  end
770
818
 
@@ -775,7 +823,8 @@ module Autobuild
775
823
  rescue SubcommandFailed => e
776
824
  if e.status == 1
777
825
  false
778
- else raise
826
+ else
827
+ raise
779
828
  end
780
829
  end
781
830
 
@@ -1020,7 +1069,8 @@ module Autobuild
1020
1069
  File.readlines(alternates_path)
1021
1070
  .map(&:strip)
1022
1071
  .find_all { |l| !l.empty? }
1023
- else Array.new
1072
+ else
1073
+ Array.new
1024
1074
  end
1025
1075
 
1026
1076
  alternates = each_alternate_path(package).map do |path|
@@ -1251,19 +1301,60 @@ module Autobuild
1251
1301
  @lfs_installed = status.success?
1252
1302
  end
1253
1303
 
1304
+ def validate_shallow(package)
1305
+ return false unless shallow?
1306
+
1307
+ if commit
1308
+ Autoproj.warn "#{package.name}: "\
1309
+ "Cannot pin a commit while doing a shallow clone"
1310
+ return false
1311
+ end
1312
+ if tag && !single_branch?
1313
+ Autoproj.warn "#{package.name}: "\
1314
+ "Cannot pin a tag while doing a shallow clone"
1315
+ return false
1316
+ end
1317
+ if @remote_branch
1318
+ Autoproj.warn "#{package.name}: "\
1319
+ "Cannot use remote_branch while doing a shallow clone"
1320
+ return false
1321
+ end
1322
+ true
1323
+ end
1324
+
1254
1325
  def checkout(package, _options = Hash.new)
1326
+ shallow_clone = validate_shallow(package)
1327
+
1255
1328
  base_dir = File.expand_path('..', package.importdir)
1256
1329
  FileUtils.mkdir_p(base_dir) unless File.directory?(base_dir)
1257
1330
 
1258
1331
  clone_options = Array.new
1259
- clone_options << '--recurse-submodules' if with_submodules?
1332
+ if with_submodules?
1333
+ clone_options << '--recurse-submodules'
1334
+ clone_options << '--shallow-submodules' if shallow_clone
1335
+ end
1336
+
1337
+ clone_options << '--depth' << '1' if shallow_clone
1338
+
1260
1339
  if single_branch?
1261
- if remote_branch.start_with?("refs/")
1262
- raise ArgumentError, "you cannot provide a full ref for"\
1263
- " the remote branch while cloning a single branch"
1340
+ if tag
1341
+ if tag.start_with?("refs/")
1342
+ raise ArgumentError, "you cannot provide a full ref for"\
1343
+ " the tag while cloning a single branch"
1344
+ end
1345
+ clone_options << "--branch=#{tag}"
1346
+ elsif remote_branch
1347
+ if remote_branch.start_with?("refs/")
1348
+ raise ArgumentError, "you cannot provide a full ref for"\
1349
+ " the remote branch while cloning a single branch"
1350
+ end
1351
+ clone_options << "--branch=#{remote_branch}"
1264
1352
  end
1265
- clone_options << "--branch=#{remote_branch}" << "--single-branch"
1353
+ clone_options << "--single-branch"
1354
+ elsif shallow_clone
1355
+ clone_options << "--no-single-branch"
1266
1356
  end
1357
+
1267
1358
  each_alternate_path(package) do |path|
1268
1359
  clone_options << '--reference' << path
1269
1360
  end
@@ -1274,7 +1365,7 @@ module Autobuild
1274
1365
  Autobuild.tool('git'), 'clone', '-o', remote_name, *clone_options,
1275
1366
  repository, package.importdir, retry: true)
1276
1367
 
1277
- update_remotes_configuration(package)
1368
+ update_remotes_configuration(package, only_local: false)
1278
1369
  update(package, only_local: !remote_branch.start_with?("refs/"),
1279
1370
  reset: :force)
1280
1371
  if with_submodules?
@@ -202,7 +202,8 @@ module Autobuild
202
202
  # Try svn upgrade and info again
203
203
  run_svn(package, 'upgrade', retry: false)
204
204
  svninfo = run_svn(package, 'info')
205
- else raise
205
+ else
206
+ raise
206
207
  end
207
208
  end
208
209
 
@@ -357,7 +357,8 @@ module Autobuild
357
357
  message = Autobuild.color('interrupted', :red)
358
358
  if last_error
359
359
  raise last_error
360
- else raise
360
+ else
361
+ raise
361
362
  end
362
363
  rescue ::Exception => e
363
364
  message = Autobuild.color('update failed', :red)
@@ -410,7 +411,8 @@ module Autobuild
410
411
  execute_post_hooks(package)
411
412
  rescue Interrupt
412
413
  if last_error then raise last_error
413
- else raise
414
+ else
415
+ raise
414
416
  end
415
417
  rescue ::Exception => e
416
418
  last_error = e
@@ -119,7 +119,8 @@ module Autobuild
119
119
  def update?
120
120
  if @update.nil?
121
121
  Autobuild.do_update
122
- else @update
122
+ else
123
+ @update
123
124
  end
124
125
  end
125
126
 
@@ -287,6 +288,11 @@ module Autobuild
287
288
  add_env_op EnvOp.new(:add_prefix, prefix, [includes])
288
289
  end
289
290
 
291
+ # Add a file to be sourced at the end of the generated env file
292
+ def env_source_after(file, shell: "sh")
293
+ add_env_op EnvOp.new(:source_after, file, shell: shell)
294
+ end
295
+
290
296
  # Hook called by autoproj to set up the default environment for this
291
297
  # package
292
298
  #
@@ -327,7 +333,11 @@ module Autobuild
327
333
  set[env_op.name] = [self, env_op.values]
328
334
  end
329
335
  end
330
- env.send(env_op.type, env_op.name, *env_op.values)
336
+ if env_op.type == :source_after
337
+ env.send(env_op.type, env_op.name, **env_op.values)
338
+ else
339
+ env.send(env_op.type, env_op.name, *env_op.values)
340
+ end
331
341
  ops << env_op
332
342
  end
333
343
  ops
@@ -492,7 +502,8 @@ module Autobuild
492
502
  suffix << token.gsub(/%s/, name)
493
503
  elsif suffix.empty?
494
504
  prefix << token
495
- else suffix << token
505
+ else
506
+ suffix << token
496
507
  end
497
508
  end
498
509
  if suffix.empty?
@@ -206,7 +206,8 @@ module Autobuild
206
206
  varname, = o.split("=").first
207
207
  if (current_flag = testflags.find { |fl| fl =~ /^#{varname}=/ })
208
208
  current_flag != o
209
- else false
209
+ else
210
+ false
210
211
  end
211
212
  end
212
213
  end
@@ -269,7 +269,14 @@ module Autobuild
269
269
  run('doc', Autobuild.tool(:doxygen), doxyfile)
270
270
  end
271
271
 
272
- def common_utility_handling(utility, target, *args, start_msg, done_msg)
272
+ def common_utility_handling( # rubocop:disable Metrics/ParameterLists
273
+ utility,
274
+ target,
275
+ *args,
276
+ start_msg,
277
+ done_msg,
278
+ post_process: nil
279
+ )
273
280
  utility.source_ref_dir = builddir
274
281
  utility.task do
275
282
  progress_start start_msg, :done_message => done_msg do
@@ -284,6 +291,24 @@ module Autobuild
284
291
  end
285
292
  yield if block_given?
286
293
  end
294
+
295
+ post_process&.call
296
+ end
297
+ end
298
+
299
+ def with_coverage(&block)
300
+ @with_coverage ||= block
301
+ end
302
+
303
+ def coverage_block
304
+ proc do
305
+ next unless test_utility.coverage_enabled?
306
+ next unless @with_coverage
307
+
308
+ progress_start "generating coverage report for %s",
309
+ done_message: "generated coverage report for %s" do
310
+ @with_coverage.call
311
+ end
287
312
  end
288
313
  end
289
314
 
@@ -299,7 +324,8 @@ module Autobuild
299
324
  common_utility_handling(
300
325
  test_utility, target, "ARGS=-V",
301
326
  "running tests for %s",
302
- "successfully ran tests for %s", &block)
327
+ "successfully ran tests for %s",
328
+ post_process: coverage_block, &block)
303
329
  end
304
330
 
305
331
  CMAKE_EQVS = {
@@ -440,7 +466,8 @@ module Autobuild
440
466
  def show_make_messages?
441
467
  if !@show_make_messages.nil?
442
468
  @show_make_messages
443
- else CMake.show_make_messages?
469
+ else
470
+ CMake.show_make_messages?
444
471
  end
445
472
  end
446
473
 
@@ -27,12 +27,14 @@ module Autobuild
27
27
 
28
28
  def prepare_for_forced_build
29
29
  super
30
- FileUtils.rm_f configurestamp
31
30
  @forced = true
32
31
  end
33
32
 
34
33
  def generate_build_command
35
- command = ['python', 'setup.py', 'build']
34
+ command = %w[python setup.py]
35
+ command << "egg_info"
36
+ command << "--egg-base=#{builddir}"
37
+ command << "build"
36
38
  command << "--build-base=#{builddir}"
37
39
  command += buildflags.flatten
38
40
  command
@@ -42,25 +44,35 @@ module Autobuild
42
44
  command = generate_build_command
43
45
  command << 'install'
44
46
  command << "--prefix=#{prefix}"
47
+ command << "--record=#{builddir}/install.log"
48
+ command << "--single-version-externally-managed"
45
49
  command += installflags.flatten
46
50
  command
47
51
  end
48
52
 
49
- def python_path
53
+ def self.user_site(prefix)
54
+ return File.join(prefix, @user_site) if @user_site
55
+
50
56
  begin
51
- _, output, _, ret = Open3.popen3({ 'PYTHONUSERBASE' => prefix },
52
- 'python -m site --user-site')
57
+ env = Autobuild.env.resolved_env.merge({ 'PYTHONUSERBASE' => "/" })
58
+ _, output, _, ret = Open3.popen3(env, 'python -m site --user-site')
53
59
  rescue Exception => e
54
60
  raise "Unable to set PYTHONPATH: #{e.message}"
55
61
  end
56
62
 
57
63
  if ret.value.success?
58
- output.read.chomp
64
+ @user_site = Pathname.new(output.read.chomp)
65
+ .relative_path_from(Pathname.new("/"))
66
+ File.join(prefix, @user_site)
59
67
  else
60
68
  raise 'Unable to set PYTHONPATH: user site directory disabled?'
61
69
  end
62
70
  end
63
71
 
72
+ def python_path
73
+ self.class.user_site(prefix)
74
+ end
75
+
64
76
  # Do the build in builddir
65
77
  def build
66
78
  return unless install_mode?
@@ -88,7 +88,8 @@ module Autobuild
88
88
  if task.respond_to?(:package)
89
89
  started_packages[task.package] ||= -started_packages.size
90
90
  queue[task] = started_packages[task.package]
91
- else queue[task] = base_priority
91
+ else
92
+ queue[task] = base_priority
92
93
  end
93
94
  end
94
95
 
@@ -246,7 +246,8 @@ module Autobuild
246
246
  groups.last[1] = (current_group.first..group_end_index)
247
247
  groups << [prefix, [idx, other_idx]]
248
248
  grouping = true
249
- else break
249
+ else
250
+ break
250
251
  end
251
252
  end
252
253
  end
@@ -130,7 +130,8 @@ module Autobuild
130
130
  # :exit if debug is false, or :raise if it is true
131
131
  def self.default_report_on_package_failures
132
132
  if Autobuild.debug then :raise
133
- else :exit
133
+ else
134
+ :exit
134
135
  end
135
136
  end
136
137
 
@@ -163,7 +164,8 @@ module Autobuild
163
164
  raise interrupted_by if interrupted_by
164
165
 
165
166
  e = if errors.size == 1 then errors.first
166
- else CompositeException.new(errors)
167
+ else
168
+ CompositeException.new(errors)
167
169
  end
168
170
  raise e
169
171
  elsif %i[report_silent report].include?(on_package_failures)
@@ -251,7 +251,8 @@ module Autobuild::Subprocess # rubocop:disable Style/ClassAndModuleChildren
251
251
  end
252
252
  logdir = if target.respond_to?(:logdir)
253
253
  target.logdir
254
- else Autobuild.logdir
254
+ else
255
+ Autobuild.logdir
255
256
  end
256
257
 
257
258
  if target.respond_to?(:working_directory)
@@ -271,7 +272,8 @@ module Autobuild::Subprocess # rubocop:disable Style/ClassAndModuleChildren
271
272
 
272
273
  open_flag = if Autobuild.keep_oldlogs then 'a'
273
274
  elsif Autobuild.registered_logfile?(logname) then 'a'
274
- else 'w'
275
+ else
276
+ 'w'
275
277
  end
276
278
  open_flag << ":BINARY"
277
279
 
@@ -461,7 +463,8 @@ module Autobuild::Subprocess # rubocop:disable Style/ClassAndModuleChildren
461
463
  error = Autobuild::SubcommandFailed.new(target, command.join(" "),
462
464
  logname, e.status, subcommand_output)
463
465
  error.retry = if e.retry?.nil? then options[:retry]
464
- else e.retry?
466
+ else
467
+ e.retry?
465
468
  end
466
469
  error.phase = phase
467
470
  raise error, e.message
@@ -24,7 +24,8 @@ module Autobuild
24
24
  def coverage_enabled?
25
25
  if @coverage_enabled.nil?
26
26
  TestUtility.coverage_enabled?
27
- else @coverage_enabled
27
+ else
28
+ @coverage_enabled
28
29
  end
29
30
  end
30
31
 
@@ -53,7 +54,8 @@ module Autobuild
53
54
  if @coverage_source_dir
54
55
  relative = if package.respond_to?(:builddir)
55
56
  package.builddir
56
- else package.srcdir
57
+ else
58
+ package.srcdir
57
59
  end
58
60
  File.expand_path(@coverage_source_dir, relative)
59
61
  end
@@ -1,3 +1,3 @@
1
1
  module Autobuild
2
- VERSION = "1.22.1".freeze unless defined? Autobuild::VERSION
2
+ VERSION = "1.24.0".freeze unless defined? Autobuild::VERSION
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.1
4
+ version: 1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -277,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
277
  - !ruby/object:Gem::Version
278
278
  version: '0'
279
279
  requirements: []
280
- rubygems_version: 3.1.2
280
+ rubygems_version: 3.1.6
281
281
  signing_key:
282
282
  specification_version: 4
283
283
  summary: Library to handle build systems and import mechanisms