autoproj 2.14.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) 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 +22 -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 +185 -182
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +184 -181
  17. data/bin/autoproj_install.in +6 -7
  18. data/lib/autoproj/aruba_minitest.rb +6 -11
  19. data/lib/autoproj/autobuild.rb +5 -6
  20. data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
  21. data/lib/autoproj/autobuild_extensions/dsl.rb +38 -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/svn.rb +1 -2
  25. data/lib/autoproj/base.rb +1 -1
  26. data/lib/autoproj/bash_completion.rb +5 -6
  27. data/lib/autoproj/build_option.rb +22 -24
  28. data/lib/autoproj/cli/base.rb +26 -26
  29. data/lib/autoproj/cli/bootstrap.rb +14 -16
  30. data/lib/autoproj/cli/build.rb +10 -7
  31. data/lib/autoproj/cli/cache.rb +11 -11
  32. data/lib/autoproj/cli/clean.rb +10 -10
  33. data/lib/autoproj/cli/commit.rb +7 -8
  34. data/lib/autoproj/cli/doc.rb +2 -2
  35. data/lib/autoproj/cli/envsh.rb +1 -2
  36. data/lib/autoproj/cli/exec.rb +60 -20
  37. data/lib/autoproj/cli/inspection_tool.rb +13 -7
  38. data/lib/autoproj/cli/locate.rb +30 -41
  39. data/lib/autoproj/cli/log.rb +7 -7
  40. data/lib/autoproj/cli/main.rb +213 -204
  41. data/lib/autoproj/cli/main_doc.rb +22 -21
  42. data/lib/autoproj/cli/main_global.rb +44 -19
  43. data/lib/autoproj/cli/main_plugin.rb +18 -18
  44. data/lib/autoproj/cli/main_test.rb +28 -27
  45. data/lib/autoproj/cli/manifest.rb +7 -7
  46. data/lib/autoproj/cli/osdeps.rb +12 -11
  47. data/lib/autoproj/cli/patcher.rb +2 -3
  48. data/lib/autoproj/cli/query.rb +17 -18
  49. data/lib/autoproj/cli/reconfigure.rb +1 -2
  50. data/lib/autoproj/cli/reset.rb +9 -12
  51. data/lib/autoproj/cli/show.rb +38 -39
  52. data/lib/autoproj/cli/status.rb +45 -39
  53. data/lib/autoproj/cli/switch_config.rb +5 -6
  54. data/lib/autoproj/cli/tag.rb +12 -11
  55. data/lib/autoproj/cli/test.rb +7 -7
  56. data/lib/autoproj/cli/update.rb +35 -37
  57. data/lib/autoproj/cli/utility.rb +11 -10
  58. data/lib/autoproj/cli/version.rb +42 -40
  59. data/lib/autoproj/cli/versions.rb +14 -15
  60. data/lib/autoproj/cli/watch.rb +33 -37
  61. data/lib/autoproj/cli/which.rb +16 -20
  62. data/lib/autoproj/cli.rb +4 -2
  63. data/lib/autoproj/configuration.rb +77 -84
  64. data/lib/autoproj/environment.rb +28 -13
  65. data/lib/autoproj/exceptions.rb +9 -3
  66. data/lib/autoproj/find_workspace.rb +20 -25
  67. data/lib/autoproj/git_server_configuration.rb +40 -44
  68. data/lib/autoproj/gitorious.rb +1 -1
  69. data/lib/autoproj/installation_manifest.rb +64 -29
  70. data/lib/autoproj/local_package_set.rb +13 -11
  71. data/lib/autoproj/manifest.rb +132 -130
  72. data/lib/autoproj/metapackage.rb +2 -6
  73. data/lib/autoproj/ops/atomic_write.rb +7 -6
  74. data/lib/autoproj/ops/build.rb +4 -6
  75. data/lib/autoproj/ops/cache.rb +41 -43
  76. data/lib/autoproj/ops/cached_env.rb +5 -4
  77. data/lib/autoproj/ops/configuration.rb +511 -506
  78. data/lib/autoproj/ops/import.rb +73 -63
  79. data/lib/autoproj/ops/install.rb +178 -174
  80. data/lib/autoproj/ops/loader.rb +77 -76
  81. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  82. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  83. data/lib/autoproj/ops/snapshot.rb +250 -247
  84. data/lib/autoproj/ops/tools.rb +76 -78
  85. data/lib/autoproj/ops/watch.rb +6 -6
  86. data/lib/autoproj/ops/which.rb +17 -14
  87. data/lib/autoproj/options.rb +13 -2
  88. data/lib/autoproj/os_package_installer.rb +102 -92
  89. data/lib/autoproj/os_package_query.rb +7 -13
  90. data/lib/autoproj/os_package_resolver.rb +189 -140
  91. data/lib/autoproj/os_repository_installer.rb +4 -4
  92. data/lib/autoproj/os_repository_resolver.rb +8 -6
  93. data/lib/autoproj/package_definition.rb +12 -13
  94. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +10 -10
  95. data/lib/autoproj/package_managers/bundler_manager.rb +147 -111
  96. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  97. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  98. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  99. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  100. data/lib/autoproj/package_managers/manager.rb +8 -3
  101. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  102. data/lib/autoproj/package_managers/pip_manager.rb +20 -22
  103. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  104. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  105. data/lib/autoproj/package_managers/shell_script_manager.rb +32 -22
  106. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  107. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  108. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  109. data/lib/autoproj/package_manifest.rb +27 -26
  110. data/lib/autoproj/package_selection.rb +187 -187
  111. data/lib/autoproj/package_set.rb +127 -113
  112. data/lib/autoproj/python.rb +55 -55
  113. data/lib/autoproj/query_base.rb +20 -14
  114. data/lib/autoproj/reporter.rb +19 -19
  115. data/lib/autoproj/repository_managers/apt.rb +101 -67
  116. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  117. data/lib/autoproj/shell_completion.rb +16 -13
  118. data/lib/autoproj/source_package_query.rb +29 -36
  119. data/lib/autoproj/system.rb +32 -21
  120. data/lib/autoproj/test.rb +127 -104
  121. data/lib/autoproj/variable_expansion.rb +7 -9
  122. data/lib/autoproj/vcs_definition.rb +35 -32
  123. data/lib/autoproj/version.rb +1 -1
  124. data/lib/autoproj/workspace.rb +123 -107
  125. data/lib/autoproj/zsh_completion.rb +8 -9
  126. data/lib/autoproj.rb +53 -55
  127. data/samples/autoproj/init.rb +1 -2
  128. metadata +53 -51
  129. 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,35 +236,36 @@ 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
@@ -283,8 +275,8 @@ module Autoproj
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
+ @gems_path_suffix ||= Pathname.new(Gem.user_dir)
279
+ .relative_path_from(Pathname.new(dot_gem_dir)).to_s
288
280
  end
289
281
 
290
282
  # The gem install root into which the workspace gems are installed
@@ -300,7 +292,7 @@ module Autoproj
300
292
  # @param [Workspace] ws the workspace whose gems are being considered
301
293
  # @return [String]
302
294
  def gems_install_path
303
- get('gems_install_path')
295
+ get("gems_install_path")
304
296
  end
305
297
 
306
298
  # The GEM_HOME into which the workspace gems are installed
@@ -313,55 +305,54 @@ module Autoproj
313
305
 
314
306
  # The full path to the expected ruby executable
315
307
  def ruby_executable
316
- if path = get('ruby_executable', nil)
317
- path
318
- else
308
+ unless (path = get("ruby_executable", nil))
319
309
  path = OSPackageResolver.autodetect_ruby_program
320
- set('ruby_executable', path, true)
321
- path
310
+ set("ruby_executable", path, true)
322
311
  end
312
+
313
+ path
323
314
  end
324
315
 
325
316
  # Verify that the Ruby executable that is being used to run autoproj
326
317
  # matches the one expected in the configuration
327
318
  def validate_ruby_executable
328
- actual = OSPackageResolver.autodetect_ruby_program
329
- if has_value_for?('ruby_executable')
330
- expected = get('ruby_executable')
319
+ actual = OSPackageResolver.autodetect_ruby_program
320
+ if has_value_for?("ruby_executable")
321
+ expected = get("ruby_executable")
331
322
  if expected != actual
332
323
  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
324
  end
334
325
  else
335
- set('ruby_executable', actual, true)
326
+ set("ruby_executable", actual, true)
336
327
  end
337
328
  end
338
329
 
339
330
  def use_prerelease?
340
331
  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')
332
+ if (env_flag = ENV["AUTOPROJ_USE_PRERELEASE"])
333
+ env_flag == "1"
334
+ elsif has_value_for?("autoproj_use_prerelease")
335
+ get("autoproj_use_prerelease")
345
336
  end
346
337
  set "autoproj_use_prerelease", (use_prerelease ? true : false), true
347
338
  use_prerelease
348
339
  end
349
340
 
350
341
  def shell_helpers?
351
- get 'shell_helpers', true
342
+ get "shell_helpers", true
352
343
  end
353
344
 
354
345
  def shell_helpers=(flag)
355
- set 'shell_helpers', flag, true
346
+ set "shell_helpers", flag, true
356
347
  end
357
348
 
358
349
  def bundler_version
359
- get 'bundler_version', nil
350
+ get "bundler_version", nil
360
351
  end
361
352
 
362
353
  def apply_autobuild_configuration
363
- if has_value_for?('autobuild')
364
- params = get('autobuild')
354
+ if has_value_for?("autobuild")
355
+ params = get("autobuild")
365
356
  if params.kind_of?(Hash)
366
357
  params.each do |k, v|
367
358
  Autobuild.send("#{k}=", v)
@@ -372,17 +363,17 @@ module Autoproj
372
363
 
373
364
  # A cache directory for autobuild's importers
374
365
  def importer_cache_dir
375
- get('importer_cache_dir', nil)
366
+ get("importer_cache_dir", nil)
376
367
  end
377
368
 
378
369
  # Set import and gem cache directory
379
370
  def importer_cache_dir=(path)
380
- set('importer_cache_dir', path, true)
371
+ set("importer_cache_dir", path, true)
381
372
  end
382
373
 
383
374
  # Sets the directory in which packages will be installed
384
375
  def prefix_dir=(path)
385
- set('prefix', path, true)
376
+ set("prefix", path, true)
386
377
  end
387
378
 
388
379
  # The directory in which packages will be installed.
@@ -394,19 +385,19 @@ module Autoproj
394
385
  #
395
386
  # @return [String]
396
387
  def prefix_dir
397
- get('prefix', 'install')
388
+ get("prefix", "install")
398
389
  end
399
390
 
400
391
  # Sets the shells used in this workspace.
401
392
  def user_shells=(shells)
402
- set('user_shells', shells, true)
393
+ set("user_shells", shells, true)
403
394
  end
404
395
 
405
396
  # The shells used in this workspace.
406
397
  #
407
398
  # @return [Array<String>]
408
399
  def user_shells
409
- get('user_shells', [])
400
+ get("user_shells", [])
410
401
  end
411
402
 
412
403
  # Defines the temporary area in which packages should put their build
@@ -420,7 +411,7 @@ module Autoproj
420
411
  #
421
412
  # @return [String]
422
413
  def build_dir
423
- get('build', 'build')
414
+ get("build", "build")
424
415
  end
425
416
 
426
417
  # Defines a folder to which source packages will be layed out relative to
@@ -432,7 +423,7 @@ module Autoproj
432
423
  #
433
424
  # @return [String,nil]
434
425
  def source_dir
435
- get('source', nil)
426
+ get("source", nil)
436
427
  end
437
428
 
438
429
  # Returns true if there should be one prefix per package
@@ -441,14 +432,14 @@ module Autoproj
441
432
  #
442
433
  # @return [Boolean]
443
434
  def separate_prefixes?
444
- get('separate_prefixes', false)
435
+ get("separate_prefixes", false)
445
436
  end
446
437
 
447
438
  # Controls whether there should be one prefix per package
448
439
  #
449
440
  # @see separate_prefixes?
450
441
  def separate_prefixes=(flag)
451
- set('separate_prefixes', flag, true)
442
+ set("separate_prefixes", flag, true)
452
443
  end
453
444
 
454
445
  # Returns true if packages and prefixes should be auto-generated, based
@@ -459,7 +450,7 @@ module Autoproj
459
450
  #
460
451
  # @return [Boolean]
461
452
  def randomize_layout?
462
- get('randomize_layout', false)
453
+ get("randomize_layout", false)
463
454
  end
464
455
 
465
456
  # Sets whether the layout should be randomized
@@ -467,7 +458,7 @@ module Autoproj
467
458
  # @return [Boolean]
468
459
  # @see randomize_layout?
469
460
  def randomize_layout=(value)
470
- set('randomize_layout', value, true)
461
+ set("randomize_layout", value, true)
471
462
  end
472
463
 
473
464
  # Returns true if the configuration should be performed interactively
@@ -477,17 +468,18 @@ module Autoproj
477
468
  def interactive?
478
469
  if !interactive.nil?
479
470
  return interactive
480
- elsif ENV['AUTOPROJ_NONINTERACTIVE'] == '1'
471
+ elsif ENV["AUTOPROJ_NONINTERACTIVE"] == "1"
481
472
  return false
482
473
  elsif has_value_for?("interactive")
483
- return get('interactive')
474
+ return get("interactive")
484
475
  end
476
+
485
477
  true
486
478
  end
487
479
 
488
480
  DEFAULT_UTILITY_SETUP = Hash[
489
- 'doc' => true,
490
- 'test' => false]
481
+ "doc" => true,
482
+ "test" => false]
491
483
 
492
484
  # The configuration key that should be used to store the utility
493
485
  # enable/disable information
@@ -513,7 +505,8 @@ module Autoproj
513
505
  utility_config = get(utility_key(utility), Hash.new)
514
506
  if utility_config.has_key?(package)
515
507
  utility_config[package]
516
- else get("#{utility_key(utility)}_default", DEFAULT_UTILITY_SETUP[utility])
508
+ else
509
+ get("#{utility_key(utility)}_default", DEFAULT_UTILITY_SETUP[utility])
517
510
  end
518
511
  end
519
512
 
@@ -596,7 +589,7 @@ module Autoproj
596
589
  #
597
590
  # This is false by default
598
591
  def prefer_indep_over_os_packages?
599
- get('prefer_indep_over_os_packages', false)
592
+ get("prefer_indep_over_os_packages", false)
600
593
  end
601
594
 
602
595
  # The configuration as a key => value map
@@ -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
 
@@ -18,30 +19,31 @@ module Autoproj
18
19
  end
19
20
 
20
21
  def env_filename(shell, *subdir)
21
- env_filename = if shell == 'sh'
22
+ env_filename = if shell == "sh"
22
23
  ENV_FILENAME
23
24
  else
24
- (Pathname(ENV_FILENAME).sub_ext '').to_s.concat(".#{shell}")
25
+ (Pathname(ENV_FILENAME).sub_ext "").to_s.concat(".#{shell}")
25
26
  end
26
27
 
27
28
  File.join(root_dir, *subdir, env_filename)
28
29
  end
29
30
 
30
31
  def each_env_filename(*subdir)
31
- (['sh'] + Autoproj.workspace.config.user_shells).to_set.each do |shell|
32
+ (["sh"] + Autoproj.workspace.config.user_shells).to_set.each do |shell|
32
33
  yield shell, env_filename(shell, *subdir)
33
34
  end
34
35
  end
35
36
 
36
37
  def export_env_sh(subdir = nil, options = Hash.new)
37
38
  if subdir.kind_of?(Hash)
38
- subdir, options = nil, subdir
39
+ options = subdir
40
+ subdir = nil
39
41
  end
40
42
  options = validate_options options,
41
- shell_helpers: true
43
+ shell_helpers: true
42
44
 
43
45
  shell_dir = File.expand_path(File.join("..", "..", "shell"), File.dirname(__FILE__))
44
- completion_dir = File.join(shell_dir, 'completion')
46
+ completion_dir = File.join(shell_dir, "completion")
45
47
  env_updated = false
46
48
 
47
49
  each_env_filename(*[subdir].compact) do |shell, filename|
@@ -50,7 +52,9 @@ module Autoproj
50
52
  source_after(helper, shell: shell) if File.file?(helper)
51
53
  %w[alocate alog amake aup autoproj].each do |tool|
52
54
  completion_file = File.join(completion_dir, "#{tool}_#{shell}")
53
- 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
54
58
  end
55
59
  end
56
60
 
@@ -59,7 +63,7 @@ module Autoproj
59
63
  rescue SystemCallError
60
64
  end
61
65
 
62
- StringIO.open(new_content = String.new, 'w') do |io|
66
+ StringIO.open(new_content = String.new, "w") do |io|
63
67
  if inherit?
64
68
  io.write <<-EOF
65
69
  if test -n "$AUTOPROJ_CURRENT_ROOT" && test "$AUTOPROJ_CURRENT_ROOT" != "#{root_dir}"; then
@@ -84,46 +88,57 @@ module Autoproj
84
88
  def self.env_set(name, *value)
85
89
  env.set(name, *value)
86
90
  end
91
+
87
92
  # @deprecated call Autoproj.env.add instead
88
93
  def self.env_add(name, *value)
89
94
  env.add(name, *value)
90
95
  end
96
+
91
97
  # @deprecated call Autoproj.env.set_path instead
92
98
  def self.env_set_path(name, *value)
93
99
  env.set_path(name, *value)
94
100
  end
101
+
95
102
  # @deprecated call Autoproj.env.add_path instead
96
103
  def self.env_add_path(name, *value)
97
104
  env.add_path(name, *value)
98
105
  end
106
+
99
107
  # @deprecated call Autoproj.env.source_after instead
100
- def self.env_source_file(file, shell: 'sh')
108
+ def self.env_source_file(file, shell: "sh")
101
109
  env.source_after(file, shell: shell)
102
110
  end
111
+
103
112
  # @deprecated call Autoproj.env.source_after instead
104
- def self.env_source_after(file, shell: 'sh')
113
+ def self.env_source_after(file, shell: "sh")
105
114
  env.source_after(file, shell: shell)
106
115
  end
116
+
107
117
  # @deprecated call Autoproj.env.source_before instead
108
- def self.env_source_before(file, shell: 'sh')
118
+ def self.env_source_before(file, shell: "sh")
109
119
  env.source_before(file, shell: shell)
110
120
  end
121
+
111
122
  # @deprecated call Autoproj.env.inherit instead
112
123
  def self.env_inherit(*names)
113
124
  env.inherit(*names)
114
125
  end
126
+
115
127
  # @deprecated use Autoproj.env.isolate instead
116
128
  def self.set_initial_env
117
129
  isolate_environment
118
130
  end
131
+
119
132
  # @deprecated use Autoproj.env.isolate instead
120
133
  def self.isolate_environment
121
134
  env.isolate
122
135
  end
136
+
123
137
  # @deprecated call Autoproj.env.prepare directly
124
138
  def self.prepare_environment(env = Autoproj.env, manifest = Autoproj.manifest)
125
139
  env.prepare(manifest)
126
140
  end
141
+
127
142
  # @deprecated use Autoproj.env.export_env_sh instead
128
143
  def self.export_env_sh(subdir = nil)
129
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
-
@@ -1,10 +1,10 @@
1
- require 'pathname'
2
- require 'yaml'
1
+ require "pathname"
2
+ require "yaml"
3
3
 
4
4
  module Autoproj
5
5
  # The base path from which we search for workspaces
6
6
  def self.default_find_base_dir
7
- ENV['AUTOPROJ_CURRENT_ROOT'] || Dir.pwd
7
+ ENV["AUTOPROJ_CURRENT_ROOT"] || Dir.pwd
8
8
  end
9
9
 
10
10
  # Looks for the autoproj workspace that is related to a given directory
@@ -29,19 +29,16 @@ module Autoproj
29
29
  # if base_dir is not part of a workspace
30
30
  def self.find_v2_workspace_config(base_dir)
31
31
  path = Pathname.new(base_dir).expand_path
32
- while !path.root?
33
- if (path + ".autoproj" + "config.yml").exist?
34
- break
35
- end
32
+ until path.root?
33
+ break if path.join(".autoproj", "config.yml").exist?
34
+
36
35
  path = path.parent
37
36
  end
38
37
 
39
- if path.root?
40
- return
41
- end
38
+ return if path.root?
42
39
 
43
- config_path = path + ".autoproj" + "config.yml"
44
- return path.to_s, (YAML.load(config_path.read) || Hash.new)
40
+ config_path = path.join(".autoproj", "config.yml")
41
+ [path.to_s, (YAML.load(config_path.read) || Hash.new)]
45
42
  end
46
43
 
47
44
  # @private
@@ -58,17 +55,18 @@ module Autoproj
58
55
  # there's none
59
56
  def self.find_v2_root_dir(base_dir, config_field_name)
60
57
  path, config = find_v2_workspace_config(base_dir)
61
- return if !path
58
+ return unless path
59
+
62
60
  result = config[config_field_name] || path.to_s
63
61
  result = File.expand_path(result, path.to_s)
64
- if result == path.to_s
65
- return result
66
- end
62
+ return result if result == path.to_s
63
+
67
64
  resolved = find_v2_root_dir(result, config_field_name)
68
65
 
69
66
  if !resolved || (resolved != result)
70
67
  raise ArgumentError, "found #{path} as possible workspace root for #{base_dir}, but it contains a configuration file that points to #{result} and #{result} is not an autoproj workspace root"
71
68
  end
69
+
72
70
  resolved
73
71
  end
74
72
 
@@ -84,7 +82,7 @@ module Autoproj
84
82
  ws_path, ws_config = find_v2_workspace_config(p)
85
83
  if ws_path
86
84
  known_workspace_dirs << "#{ws_path}/"
87
- if ws_dir = ws_config['workspace']
85
+ if (ws_dir = ws_config["workspace"])
88
86
  known_workspace_dirs << "#{ws_dir}/"
89
87
  end
90
88
  false
@@ -97,12 +95,12 @@ module Autoproj
97
95
 
98
96
  # {#find_workspace_dir} for v2 workspaces
99
97
  def self.find_v2_workspace_dir(base_dir = default_find_base_dir)
100
- find_v2_root_dir(base_dir, 'workspace')
98
+ find_v2_root_dir(base_dir, "workspace")
101
99
  end
102
100
 
103
101
  # {#find_prefix_dir} for v2 workspaces
104
102
  def self.find_v2_prefix_dir(base_dir = default_find_base_dir)
105
- find_v2_root_dir(base_dir, 'prefix')
103
+ find_v2_root_dir(base_dir, "prefix")
106
104
  end
107
105
 
108
106
  # {#find_workspace_dir} for v1 workspaces
@@ -110,15 +108,12 @@ module Autoproj
110
108
  # Note that for v1 workspaces {#find_prefix_dir} cannot be implemented
111
109
  def self.find_v1_workspace_dir(base_dir = default_find_base_dir)
112
110
  path = Pathname.new(base_dir)
113
- while !path.root?
114
- if (path + "autoproj").exist?
115
- if !(path + ".autoproj").exist?
116
- return path.to_s
117
- end
111
+ until path.root?
112
+ if path.join("autoproj").exist?
113
+ return path.to_s unless path.join(".autoproj").exist?
118
114
  end
119
115
  path = path.parent
120
116
  end
121
117
  nil
122
118
  end
123
119
  end
124
-