autoproj 2.13.0 → 2.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) 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 +79 -91
  5. data/.rubocop_todo.yml +1473 -0
  6. data/Gemfile +9 -9
  7. data/Rakefile +24 -24
  8. data/autoproj.gemspec +24 -22
  9. data/bin/alocate +4 -4
  10. data/bin/alog +5 -7
  11. data/bin/amake +4 -4
  12. data/bin/aup +4 -4
  13. data/bin/autoproj +3 -3
  14. data/bin/autoproj_bootstrap +224 -199
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +223 -198
  17. data/bin/autoproj_install.in +6 -7
  18. data/lib/autoproj/aruba_minitest.rb +6 -11
  19. data/lib/autoproj/autobuild.rb +9 -6
  20. data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
  21. data/lib/autoproj/autobuild_extensions/dsl.rb +64 -34
  22. data/lib/autoproj/autobuild_extensions/git.rb +27 -26
  23. data/lib/autoproj/autobuild_extensions/package.rb +23 -22
  24. data/lib/autoproj/autobuild_extensions/python.rb +18 -0
  25. data/lib/autoproj/autobuild_extensions/svn.rb +1 -2
  26. data/lib/autoproj/base.rb +1 -1
  27. data/lib/autoproj/bash_completion.rb +5 -6
  28. data/lib/autoproj/build_option.rb +22 -24
  29. data/lib/autoproj/cli/base.rb +26 -26
  30. data/lib/autoproj/cli/bootstrap.rb +14 -16
  31. data/lib/autoproj/cli/build.rb +10 -7
  32. data/lib/autoproj/cli/cache.rb +11 -11
  33. data/lib/autoproj/cli/clean.rb +10 -10
  34. data/lib/autoproj/cli/commit.rb +7 -8
  35. data/lib/autoproj/cli/doc.rb +2 -2
  36. data/lib/autoproj/cli/envsh.rb +1 -2
  37. data/lib/autoproj/cli/exec.rb +60 -20
  38. data/lib/autoproj/cli/inspection_tool.rb +13 -7
  39. data/lib/autoproj/cli/locate.rb +30 -41
  40. data/lib/autoproj/cli/log.rb +7 -7
  41. data/lib/autoproj/cli/main.rb +213 -204
  42. data/lib/autoproj/cli/main_doc.rb +22 -21
  43. data/lib/autoproj/cli/main_global.rb +44 -19
  44. data/lib/autoproj/cli/main_plugin.rb +18 -18
  45. data/lib/autoproj/cli/main_test.rb +28 -27
  46. data/lib/autoproj/cli/manifest.rb +7 -7
  47. data/lib/autoproj/cli/osdeps.rb +12 -11
  48. data/lib/autoproj/cli/patcher.rb +2 -3
  49. data/lib/autoproj/cli/query.rb +17 -18
  50. data/lib/autoproj/cli/reconfigure.rb +1 -2
  51. data/lib/autoproj/cli/reset.rb +9 -12
  52. data/lib/autoproj/cli/show.rb +38 -39
  53. data/lib/autoproj/cli/status.rb +45 -39
  54. data/lib/autoproj/cli/switch_config.rb +5 -6
  55. data/lib/autoproj/cli/tag.rb +12 -11
  56. data/lib/autoproj/cli/test.rb +7 -7
  57. data/lib/autoproj/cli/update.rb +35 -37
  58. data/lib/autoproj/cli/utility.rb +11 -10
  59. data/lib/autoproj/cli/version.rb +42 -40
  60. data/lib/autoproj/cli/versions.rb +14 -15
  61. data/lib/autoproj/cli/watch.rb +33 -37
  62. data/lib/autoproj/cli/which.rb +16 -20
  63. data/lib/autoproj/cli.rb +4 -2
  64. data/lib/autoproj/configuration.rb +77 -85
  65. data/lib/autoproj/default.osdeps +18 -3
  66. data/lib/autoproj/environment.rb +42 -23
  67. data/lib/autoproj/exceptions.rb +9 -3
  68. data/lib/autoproj/find_workspace.rb +20 -25
  69. data/lib/autoproj/git_server_configuration.rb +40 -44
  70. data/lib/autoproj/gitorious.rb +1 -1
  71. data/lib/autoproj/installation_manifest.rb +64 -29
  72. data/lib/autoproj/local_package_set.rb +13 -11
  73. data/lib/autoproj/manifest.rb +137 -130
  74. data/lib/autoproj/metapackage.rb +2 -6
  75. data/lib/autoproj/ops/atomic_write.rb +7 -6
  76. data/lib/autoproj/ops/build.rb +4 -6
  77. data/lib/autoproj/ops/cache.rb +41 -43
  78. data/lib/autoproj/ops/cached_env.rb +5 -4
  79. data/lib/autoproj/ops/configuration.rb +525 -507
  80. data/lib/autoproj/ops/import.rb +76 -64
  81. data/lib/autoproj/ops/install.rb +217 -191
  82. data/lib/autoproj/ops/loader.rb +77 -76
  83. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  84. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  85. data/lib/autoproj/ops/snapshot.rb +250 -247
  86. data/lib/autoproj/ops/tools.rb +76 -78
  87. data/lib/autoproj/ops/watch.rb +6 -6
  88. data/lib/autoproj/ops/which.rb +17 -14
  89. data/lib/autoproj/options.rb +13 -2
  90. data/lib/autoproj/os_package_installer.rb +102 -92
  91. data/lib/autoproj/os_package_query.rb +7 -13
  92. data/lib/autoproj/os_package_resolver.rb +189 -140
  93. data/lib/autoproj/os_repository_installer.rb +4 -4
  94. data/lib/autoproj/os_repository_resolver.rb +8 -6
  95. data/lib/autoproj/package_definition.rb +12 -13
  96. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +19 -11
  97. data/lib/autoproj/package_managers/bundler_manager.rb +186 -129
  98. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  99. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  100. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  101. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  102. data/lib/autoproj/package_managers/manager.rb +8 -3
  103. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  104. data/lib/autoproj/package_managers/pip_manager.rb +30 -28
  105. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  106. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  107. data/lib/autoproj/package_managers/shell_script_manager.rb +47 -25
  108. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  109. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  110. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  111. data/lib/autoproj/package_manifest.rb +28 -74
  112. data/lib/autoproj/package_selection.rb +187 -187
  113. data/lib/autoproj/package_set.rb +144 -113
  114. data/lib/autoproj/python.rb +297 -0
  115. data/lib/autoproj/query_base.rb +20 -14
  116. data/lib/autoproj/reporter.rb +19 -19
  117. data/lib/autoproj/repository_managers/apt.rb +102 -68
  118. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  119. data/lib/autoproj/ros_condition_parser.rb +84 -0
  120. data/lib/autoproj/ros_package_manifest.rb +125 -0
  121. data/lib/autoproj/shell_completion.rb +16 -13
  122. data/lib/autoproj/source_package_query.rb +29 -36
  123. data/lib/autoproj/system.rb +32 -21
  124. data/lib/autoproj/test.rb +127 -104
  125. data/lib/autoproj/variable_expansion.rb +7 -9
  126. data/lib/autoproj/vcs_definition.rb +35 -32
  127. data/lib/autoproj/version.rb +1 -1
  128. data/lib/autoproj/workspace.rb +142 -108
  129. data/lib/autoproj/zsh_completion.rb +8 -9
  130. data/lib/autoproj.rb +55 -55
  131. data/samples/autoproj/init.rb +1 -2
  132. metadata +80 -46
  133. data/.travis.yml +0 -24
@@ -1,8 +1,8 @@
1
- require 'backports/2.4.0/float/dup'
2
- require 'backports/2.4.0/fixnum/dup'
3
- require 'backports/2.4.0/nil_class/dup'
4
- require 'backports/2.4.0/false_class/dup'
5
- require 'backports/2.4.0/true_class/dup'
1
+ require "backports/2.4.0/float/dup"
2
+ require "backports/2.4.0/fixnum/dup"
3
+ require "backports/2.4.0/nil_class/dup"
4
+ require "backports/2.4.0/false_class/dup"
5
+ require "backports/2.4.0/true_class/dup"
6
6
 
7
7
  module Autoproj
8
8
  # Class that does the handling of configuration options as well as
@@ -89,14 +89,13 @@ module Autoproj
89
89
  overrides[option_name] = value
90
90
  end
91
91
 
92
- # Remove a specific override
93
- def reset_overrides(name)
94
- @overrides.delete(name)
95
- end
96
-
97
92
  # Remove all overrides
98
- def reset_overrides
99
- @overrides.clear
93
+ def reset_overrides(*names)
94
+ if names.empty?
95
+ @overrides.clear
96
+ else
97
+ names.each { |n| @overrides.delete(n) }
98
+ end
100
99
  end
101
100
 
102
101
  # Tests whether a value is set for the given option name
@@ -108,32 +107,26 @@ module Autoproj
108
107
 
109
108
  # Get the value for a given option
110
109
  def get(key, *default_value)
111
- if overrides.has_key?(key)
112
- return overrides[key].dup
113
- end
110
+ return overrides[key].dup if overrides.has_key?(key)
114
111
 
115
112
  has_value = config.has_key?(key)
116
113
  value, validated = config[key]
117
114
 
118
115
  if !declared?(key)
119
116
  if has_value
120
- return value.dup
117
+ value.dup
121
118
  elsif default_value.empty?
122
119
  raise ConfigError, "undeclared option '#{key}'"
123
120
  else
124
121
  default_value.first.dup
125
122
  end
123
+ elsif validated
124
+ doc = declared_options[key].short_doc
125
+ doc = "#{doc}:" if doc[-1, 1] != "?"
126
+ displayed_options[key] = value
127
+ value.dup
126
128
  else
127
- if validated
128
- doc = declared_options[key].short_doc
129
- if doc[-1, 1] != "?"
130
- doc = "#{doc}:"
131
- end
132
- displayed_options[key] = value
133
- value.dup
134
- else
135
- configure(key).dup
136
- end
129
+ configure(key).dup
137
130
  end
138
131
  end
139
132
 
@@ -184,8 +177,8 @@ module Autoproj
184
177
  # @return [Object] the new option value
185
178
  # @raise ConfigError if the option is not declared
186
179
  def configure(option_name)
187
- if opt = declared_options[option_name]
188
- if current_value = config[option_name]
180
+ if (opt = declared_options[option_name])
181
+ if (current_value = config[option_name])
189
182
  current_value = current_value.first
190
183
  end
191
184
  is_default = false
@@ -210,15 +203,13 @@ module Autoproj
210
203
 
211
204
  def load(path: self.path, reconfigure: false)
212
205
  current_keys = @config.keys
213
- if h = YAML.load(File.read(path))
214
- h.each do |key, value|
215
- current_keys.delete(key)
216
- set(key, value, !reconfigure)
217
- end
218
- if current_keys.empty?
219
- @modified = false
220
- end
206
+ return unless (h = YAML.load(File.read(path)))
207
+
208
+ h.each do |key, value|
209
+ current_keys.delete(key)
210
+ set(key, value, !reconfigure)
221
211
  end
212
+ @modified = false if current_keys.empty?
222
213
  end
223
214
 
224
215
  def reconfigure!
@@ -245,46 +236,46 @@ module Autoproj
245
236
  end
246
237
 
247
238
  def each_reused_autoproj_installation(&block)
248
- if has_value_for?('reused_autoproj_installations')
249
- get('reused_autoproj_installations').each(&block)
250
- else [].each(&block)
239
+ if has_value_for?("reused_autoproj_installations")
240
+ get("reused_autoproj_installations").each(&block)
241
+ else
242
+ [].each(&block)
251
243
  end
252
244
  end
253
245
 
254
246
  def import_log_enabled?
255
- get('import_log_enabled', true)
247
+ get("import_log_enabled", true)
256
248
  end
257
249
 
258
250
  def import_log_enabled=(value)
259
- set('import_log_enabled', !!value)
251
+ set("import_log_enabled", !!value)
260
252
  end
261
253
 
262
254
  def parallel_build_level
263
- get('parallel_build_level', nil) || Autobuild.parallel_build_level
255
+ get("parallel_build_level", nil) || Autobuild.parallel_build_level
264
256
  end
265
257
 
266
258
  def parallel_build_level=(level)
267
- set('parallel_build_level', level)
259
+ set("parallel_build_level", level)
268
260
  Autobuild.parallel_build_level = level
269
261
  end
270
262
 
271
263
  def parallel_import_level
272
- get('parallel_import_level', 10)
264
+ get("parallel_import_level", 10)
273
265
  end
274
266
 
275
267
  def parallel_import_level=(level)
276
- set('parallel_import_level', level)
268
+ set("parallel_import_level", level)
277
269
  end
278
270
 
279
271
  # The user-wide place where RubyGems installs gems
280
272
  def self.dot_gem_dir
281
- File.join(Gem.user_home, ".gem")
273
+ Ops::Install.dot_gem_dir
282
274
  end
283
275
 
284
276
  # The Ruby platform and version-specific subdirectory used by bundler and rubygem
285
277
  def self.gems_path_suffix
286
- @gems_path_suffix ||= Pathname.new(Gem.user_dir).
287
- relative_path_from(Pathname.new(dot_gem_dir)).to_s
278
+ Ops::Install.gems_path_suffix
288
279
  end
289
280
 
290
281
  # The gem install root into which the workspace gems are installed
@@ -300,7 +291,7 @@ module Autoproj
300
291
  # @param [Workspace] ws the workspace whose gems are being considered
301
292
  # @return [String]
302
293
  def gems_install_path
303
- get('gems_install_path')
294
+ get("gems_install_path")
304
295
  end
305
296
 
306
297
  # The GEM_HOME into which the workspace gems are installed
@@ -313,55 +304,54 @@ module Autoproj
313
304
 
314
305
  # The full path to the expected ruby executable
315
306
  def ruby_executable
316
- if path = get('ruby_executable', nil)
317
- path
318
- else
307
+ unless (path = get("ruby_executable", nil))
319
308
  path = OSPackageResolver.autodetect_ruby_program
320
- set('ruby_executable', path, true)
321
- path
309
+ set("ruby_executable", path, true)
322
310
  end
311
+
312
+ path
323
313
  end
324
314
 
325
315
  # Verify that the Ruby executable that is being used to run autoproj
326
316
  # matches the one expected in the configuration
327
317
  def validate_ruby_executable
328
- actual = OSPackageResolver.autodetect_ruby_program
329
- if has_value_for?('ruby_executable')
330
- expected = get('ruby_executable')
318
+ actual = OSPackageResolver.autodetect_ruby_program
319
+ if has_value_for?("ruby_executable")
320
+ expected = get("ruby_executable")
331
321
  if expected != actual
332
322
  raise ConfigError.new, "this autoproj installation was bootstrapped using #{expected}, but you are currently running under #{actual}. Changing the Ruby executable for in an existing autoproj workspace is unsupported"
333
323
  end
334
324
  else
335
- set('ruby_executable', actual, true)
325
+ set("ruby_executable", actual, true)
336
326
  end
337
327
  end
338
328
 
339
329
  def use_prerelease?
340
330
  use_prerelease =
341
- if env_flag = ENV['AUTOPROJ_USE_PRERELEASE']
342
- env_flag == '1'
343
- elsif has_value_for?('autoproj_use_prerelease')
344
- get('autoproj_use_prerelease')
331
+ if (env_flag = ENV["AUTOPROJ_USE_PRERELEASE"])
332
+ env_flag == "1"
333
+ elsif has_value_for?("autoproj_use_prerelease")
334
+ get("autoproj_use_prerelease")
345
335
  end
346
336
  set "autoproj_use_prerelease", (use_prerelease ? true : false), true
347
337
  use_prerelease
348
338
  end
349
339
 
350
340
  def shell_helpers?
351
- get 'shell_helpers', true
341
+ get "shell_helpers", true
352
342
  end
353
343
 
354
344
  def shell_helpers=(flag)
355
- set 'shell_helpers', flag, true
345
+ set "shell_helpers", flag, true
356
346
  end
357
347
 
358
348
  def bundler_version
359
- get 'bundler_version', nil
349
+ get "bundler_version", nil
360
350
  end
361
351
 
362
352
  def apply_autobuild_configuration
363
- if has_value_for?('autobuild')
364
- params = get('autobuild')
353
+ if has_value_for?("autobuild")
354
+ params = get("autobuild")
365
355
  if params.kind_of?(Hash)
366
356
  params.each do |k, v|
367
357
  Autobuild.send("#{k}=", v)
@@ -372,17 +362,17 @@ module Autoproj
372
362
 
373
363
  # A cache directory for autobuild's importers
374
364
  def importer_cache_dir
375
- get('importer_cache_dir', nil)
365
+ get("importer_cache_dir", nil)
376
366
  end
377
367
 
378
368
  # Set import and gem cache directory
379
369
  def importer_cache_dir=(path)
380
- set('importer_cache_dir', path, true)
370
+ set("importer_cache_dir", path, true)
381
371
  end
382
372
 
383
373
  # Sets the directory in which packages will be installed
384
374
  def prefix_dir=(path)
385
- set('prefix', path, true)
375
+ set("prefix", path, true)
386
376
  end
387
377
 
388
378
  # The directory in which packages will be installed.
@@ -394,19 +384,19 @@ module Autoproj
394
384
  #
395
385
  # @return [String]
396
386
  def prefix_dir
397
- get('prefix', 'install')
387
+ get("prefix", "install")
398
388
  end
399
389
 
400
390
  # Sets the shells used in this workspace.
401
391
  def user_shells=(shells)
402
- set('user_shells', shells, true)
392
+ set("user_shells", shells, true)
403
393
  end
404
394
 
405
395
  # The shells used in this workspace.
406
396
  #
407
397
  # @return [Array<String>]
408
398
  def user_shells
409
- get('user_shells', [])
399
+ get("user_shells", [])
410
400
  end
411
401
 
412
402
  # Defines the temporary area in which packages should put their build
@@ -420,7 +410,7 @@ module Autoproj
420
410
  #
421
411
  # @return [String]
422
412
  def build_dir
423
- get('build', 'build')
413
+ get("build", "build")
424
414
  end
425
415
 
426
416
  # Defines a folder to which source packages will be layed out relative to
@@ -432,7 +422,7 @@ module Autoproj
432
422
  #
433
423
  # @return [String,nil]
434
424
  def source_dir
435
- get('source', nil)
425
+ get("source", nil)
436
426
  end
437
427
 
438
428
  # Returns true if there should be one prefix per package
@@ -441,14 +431,14 @@ module Autoproj
441
431
  #
442
432
  # @return [Boolean]
443
433
  def separate_prefixes?
444
- get('separate_prefixes', false)
434
+ get("separate_prefixes", false)
445
435
  end
446
436
 
447
437
  # Controls whether there should be one prefix per package
448
438
  #
449
439
  # @see separate_prefixes?
450
440
  def separate_prefixes=(flag)
451
- set('separate_prefixes', flag, true)
441
+ set("separate_prefixes", flag, true)
452
442
  end
453
443
 
454
444
  # Returns true if packages and prefixes should be auto-generated, based
@@ -459,7 +449,7 @@ module Autoproj
459
449
  #
460
450
  # @return [Boolean]
461
451
  def randomize_layout?
462
- get('randomize_layout', false)
452
+ get("randomize_layout", false)
463
453
  end
464
454
 
465
455
  # Sets whether the layout should be randomized
@@ -467,7 +457,7 @@ module Autoproj
467
457
  # @return [Boolean]
468
458
  # @see randomize_layout?
469
459
  def randomize_layout=(value)
470
- set('randomize_layout', value, true)
460
+ set("randomize_layout", value, true)
471
461
  end
472
462
 
473
463
  # Returns true if the configuration should be performed interactively
@@ -477,17 +467,18 @@ module Autoproj
477
467
  def interactive?
478
468
  if !interactive.nil?
479
469
  return interactive
480
- elsif ENV['AUTOPROJ_NONINTERACTIVE'] == '1'
470
+ elsif ENV["AUTOPROJ_NONINTERACTIVE"] == "1"
481
471
  return false
482
472
  elsif has_value_for?("interactive")
483
- return get('interactive')
473
+ return get("interactive")
484
474
  end
475
+
485
476
  true
486
477
  end
487
478
 
488
479
  DEFAULT_UTILITY_SETUP = Hash[
489
- 'doc' => true,
490
- 'test' => false]
480
+ "doc" => true,
481
+ "test" => false]
491
482
 
492
483
  # The configuration key that should be used to store the utility
493
484
  # enable/disable information
@@ -513,7 +504,8 @@ module Autoproj
513
504
  utility_config = get(utility_key(utility), Hash.new)
514
505
  if utility_config.has_key?(package)
515
506
  utility_config[package]
516
- else get("#{utility_key(utility)}_default", DEFAULT_UTILITY_SETUP[utility])
507
+ else
508
+ get("#{utility_key(utility)}_default", DEFAULT_UTILITY_SETUP[utility])
517
509
  end
518
510
  end
519
511
 
@@ -596,7 +588,7 @@ module Autoproj
596
588
  #
597
589
  # This is false by default
598
590
  def prefer_indep_over_os_packages?
599
- get('prefer_indep_over_os_packages', false)
591
+ get("prefer_indep_over_os_packages", false)
600
592
  end
601
593
 
602
594
  # The configuration as a key => value map
@@ -166,7 +166,12 @@ cvs:
166
166
  default: cvs
167
167
 
168
168
  pip:
169
- debian,ubuntu: python-pip
169
+ debian:
170
+ '8,jessie,9,stretch': python-pip
171
+ default: python3-pip
172
+ ubuntu:
173
+ '16.04,18.04': python-pip
174
+ default: python3-pip
170
175
  arch: python2-pip
171
176
  opensuse: python-pip
172
177
  fedora: python-pip
@@ -175,7 +180,12 @@ pip:
175
180
 
176
181
  python:
177
182
  arch: python2
178
- debian,ubuntu: python-dev
183
+ debian:
184
+ '8,jessie,9,stretch': python-dev
185
+ default: python3-dev
186
+ ubuntu:
187
+ '16.04,18.04': python-dev
188
+ default: python3-dev
179
189
  fedora: python-devel
180
190
  freebsd: python-devel
181
191
  gentoo: dev-lang/python
@@ -184,7 +194,12 @@ python:
184
194
 
185
195
  python-setuptools:
186
196
  arch: python2-distribute
187
- debian,ubuntu: python-setuptools
197
+ debian:
198
+ '8,jessie,9,stretch': python-setuptools
199
+ default: python3-setuptools
200
+ ubuntu:
201
+ '16.04,18.04': python-setuptools
202
+ default: python3-setuptools
188
203
  fedora: python-setuptools
189
204
  gentoo: dev-python/setuptools
190
205
  default: ignore # will be installed manually by the user
@@ -1,7 +1,8 @@
1
1
  module Autoproj
2
2
  ENV_FILENAME =
3
3
  if Autobuild.windows? then "env.bat"
4
- else "env.sh"
4
+ else
5
+ "env.sh"
5
6
  end
6
7
 
7
8
  class Environment < Autobuild::Environment
@@ -9,7 +10,7 @@ module Autoproj
9
10
 
10
11
  def prepare(root_dir)
11
12
  @root_dir = root_dir
12
- set 'AUTOPROJ_CURRENT_ROOT', root_dir
13
+ set "AUTOPROJ_CURRENT_ROOT", root_dir
13
14
  super()
14
15
  end
15
16
 
@@ -17,36 +18,43 @@ module Autoproj
17
18
  Autoproj.filter_out_paths_in_workspace(env)
18
19
  end
19
20
 
21
+ def env_filename(shell, *subdir)
22
+ env_filename = if shell == "sh"
23
+ ENV_FILENAME
24
+ else
25
+ (Pathname(ENV_FILENAME).sub_ext "").to_s.concat(".#{shell}")
26
+ end
27
+
28
+ File.join(root_dir, *subdir, env_filename)
29
+ end
30
+
31
+ def each_env_filename(*subdir)
32
+ (["sh"] + Autoproj.workspace.config.user_shells).to_set.each do |shell|
33
+ yield shell, env_filename(shell, *subdir)
34
+ end
35
+ end
36
+
20
37
  def export_env_sh(subdir = nil, options = Hash.new)
21
38
  if subdir.kind_of?(Hash)
22
- subdir, options = nil, subdir
39
+ options = subdir
40
+ subdir = nil
23
41
  end
24
42
  options = validate_options options,
25
- shell_helpers: true
43
+ shell_helpers: true
26
44
 
27
45
  shell_dir = File.expand_path(File.join("..", "..", "shell"), File.dirname(__FILE__))
28
- completion_dir = File.join(shell_dir, 'completion')
46
+ completion_dir = File.join(shell_dir, "completion")
29
47
  env_updated = false
30
48
 
31
- (['sh'] + Autoproj.workspace.config.user_shells).to_set.each do |shell|
32
- env_filename = if shell == 'sh'
33
- ENV_FILENAME
34
- else
35
- (Pathname(ENV_FILENAME).sub_ext '').to_s.concat(".#{shell}")
36
- end
37
-
38
- filename = if subdir
39
- File.join(root_dir, subdir, env_filename)
40
- else
41
- File.join(root_dir, env_filename)
42
- end
43
-
49
+ each_env_filename(*[subdir].compact) do |shell, filename|
44
50
  helper = File.join(shell_dir, "autoproj_#{shell}")
45
51
  if options[:shell_helpers]
46
52
  source_after(helper, shell: shell) if File.file?(helper)
47
53
  %w[alocate alog amake aup autoproj].each do |tool|
48
54
  completion_file = File.join(completion_dir, "#{tool}_#{shell}")
49
- source_after(completion_file, shell: shell) if File.file?(completion_file)
55
+ if File.file?(completion_file)
56
+ source_after(completion_file, shell: shell)
57
+ end
50
58
  end
51
59
  end
52
60
 
@@ -55,7 +63,7 @@ module Autoproj
55
63
  rescue SystemCallError
56
64
  end
57
65
 
58
- StringIO.open(new_content = String.new, 'w') do |io|
66
+ StringIO.open(new_content = String.new, "w") do |io|
59
67
  if inherit?
60
68
  io.write <<-EOF
61
69
  if test -n "$AUTOPROJ_CURRENT_ROOT" && test "$AUTOPROJ_CURRENT_ROOT" != "#{root_dir}"; then
@@ -80,46 +88,57 @@ module Autoproj
80
88
  def self.env_set(name, *value)
81
89
  env.set(name, *value)
82
90
  end
91
+
83
92
  # @deprecated call Autoproj.env.add instead
84
93
  def self.env_add(name, *value)
85
94
  env.add(name, *value)
86
95
  end
96
+
87
97
  # @deprecated call Autoproj.env.set_path instead
88
98
  def self.env_set_path(name, *value)
89
99
  env.set_path(name, *value)
90
100
  end
101
+
91
102
  # @deprecated call Autoproj.env.add_path instead
92
103
  def self.env_add_path(name, *value)
93
104
  env.add_path(name, *value)
94
105
  end
106
+
95
107
  # @deprecated call Autoproj.env.source_after instead
96
- def self.env_source_file(file, shell: 'sh')
108
+ def self.env_source_file(file, shell: "sh")
97
109
  env.source_after(file, shell: shell)
98
110
  end
111
+
99
112
  # @deprecated call Autoproj.env.source_after instead
100
- def self.env_source_after(file, shell: 'sh')
113
+ def self.env_source_after(file, shell: "sh")
101
114
  env.source_after(file, shell: shell)
102
115
  end
116
+
103
117
  # @deprecated call Autoproj.env.source_before instead
104
- def self.env_source_before(file, shell: 'sh')
118
+ def self.env_source_before(file, shell: "sh")
105
119
  env.source_before(file, shell: shell)
106
120
  end
121
+
107
122
  # @deprecated call Autoproj.env.inherit instead
108
123
  def self.env_inherit(*names)
109
124
  env.inherit(*names)
110
125
  end
126
+
111
127
  # @deprecated use Autoproj.env.isolate instead
112
128
  def self.set_initial_env
113
129
  isolate_environment
114
130
  end
131
+
115
132
  # @deprecated use Autoproj.env.isolate instead
116
133
  def self.isolate_environment
117
134
  env.isolate
118
135
  end
136
+
119
137
  # @deprecated call Autoproj.env.prepare directly
120
138
  def self.prepare_environment(env = Autoproj.env, manifest = Autoproj.manifest)
121
139
  env.prepare(manifest)
122
140
  end
141
+
123
142
  # @deprecated use Autoproj.env.export_env_sh instead
124
143
  def self.export_env_sh(subdir = nil)
125
144
  env.export_env_sh(subdir)
@@ -1,13 +1,15 @@
1
- require 'autobuild/exceptions'
1
+ require "autobuild/exceptions"
2
2
 
3
3
  module Autoproj
4
4
  class ConfigError < RuntimeError
5
5
  attr_accessor :file
6
+
6
7
  def initialize(file = nil)
7
8
  super
8
9
  @file = file
9
10
  end
10
11
  end
12
+
11
13
  class InternalError < RuntimeError; end
12
14
 
13
15
  class ImportFailed < Autobuild::CompositeException
@@ -48,8 +50,11 @@ module Autoproj
48
50
  # Exception raised when a caller requires to use an excluded package
49
51
  class ExcludedPackage < ConfigError
50
52
  attr_reader :name
53
+
51
54
  def initialize(name)
52
55
  @name = name
56
+
57
+ super()
53
58
  end
54
59
  end
55
60
 
@@ -65,8 +70,11 @@ module Autoproj
65
70
  # selection is completely excluded
66
71
  class ExcludedSelection < ConfigError
67
72
  attr_reader :selection
73
+
68
74
  def initialize(selection)
69
75
  @selection = selection
76
+
77
+ super()
70
78
  end
71
79
  end
72
80
 
@@ -90,5 +98,3 @@ module Autoproj
90
98
  # Raised by 'which' when an executable cannot be found
91
99
  class ExecutableNotFound < ArgumentError; end
92
100
  end
93
-
94
-