autoproj 1.13.7 → 2.0.0.b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gemtest +0 -0
  3. data/Manifest.txt +27 -21
  4. data/Rakefile +4 -6
  5. data/bin/alocate +5 -1
  6. data/bin/amake +3 -53
  7. data/bin/aup +3 -50
  8. data/bin/autoproj +3 -264
  9. data/bin/autoproj_bootstrap +294 -349
  10. data/bin/autoproj_bootstrap.in +27 -3
  11. data/lib/autoproj.rb +23 -1
  12. data/lib/autoproj/autobuild.rb +51 -89
  13. data/lib/autoproj/base.rb +0 -9
  14. data/lib/autoproj/build_option.rb +1 -3
  15. data/lib/autoproj/cli.rb +1 -0
  16. data/lib/autoproj/cli/base.rb +155 -0
  17. data/lib/autoproj/cli/bootstrap.rb +119 -0
  18. data/lib/autoproj/cli/build.rb +72 -0
  19. data/lib/autoproj/cli/cache.rb +31 -0
  20. data/lib/autoproj/cli/clean.rb +37 -0
  21. data/lib/autoproj/cli/commit.rb +41 -0
  22. data/lib/autoproj/cli/doc.rb +22 -0
  23. data/lib/autoproj/cli/envsh.rb +22 -0
  24. data/lib/autoproj/cli/inspection_tool.rb +73 -0
  25. data/lib/autoproj/cli/locate.rb +96 -0
  26. data/lib/autoproj/cli/log.rb +26 -0
  27. data/lib/autoproj/cli/main.rb +249 -0
  28. data/lib/autoproj/cli/main_test.rb +57 -0
  29. data/lib/autoproj/cli/osdeps.rb +30 -0
  30. data/lib/autoproj/cli/query.rb +43 -0
  31. data/lib/autoproj/cli/reconfigure.rb +19 -0
  32. data/lib/autoproj/cli/reset.rb +7 -32
  33. data/lib/autoproj/cli/show.rb +219 -0
  34. data/lib/autoproj/cli/snapshot.rb +1 -1
  35. data/lib/autoproj/cli/status.rb +149 -0
  36. data/lib/autoproj/cli/switch_config.rb +28 -0
  37. data/lib/autoproj/cli/tag.rb +9 -35
  38. data/lib/autoproj/cli/test.rb +34 -55
  39. data/lib/autoproj/cli/update.rb +158 -0
  40. data/lib/autoproj/cli/versions.rb +32 -69
  41. data/lib/autoproj/configuration.rb +95 -34
  42. data/lib/autoproj/default.osdeps +25 -35
  43. data/lib/autoproj/environment.rb +85 -63
  44. data/lib/autoproj/exceptions.rb +50 -0
  45. data/lib/autoproj/gitorious.rb +11 -9
  46. data/lib/autoproj/manifest.rb +199 -231
  47. data/lib/autoproj/metapackage.rb +0 -8
  48. data/lib/autoproj/ops/build.rb +1 -17
  49. data/lib/autoproj/ops/configuration.rb +92 -90
  50. data/lib/autoproj/ops/import.rb +222 -0
  51. data/lib/autoproj/ops/loader.rb +18 -8
  52. data/lib/autoproj/ops/main_config_switcher.rb +45 -73
  53. data/lib/autoproj/ops/snapshot.rb +5 -10
  54. data/lib/autoproj/ops/tools.rb +10 -44
  55. data/lib/autoproj/options.rb +35 -6
  56. data/lib/autoproj/osdeps.rb +97 -68
  57. data/lib/autoproj/package_selection.rb +39 -20
  58. data/lib/autoproj/package_set.rb +26 -24
  59. data/lib/autoproj/reporter.rb +91 -0
  60. data/lib/autoproj/system.rb +50 -149
  61. data/lib/autoproj/variable_expansion.rb +32 -6
  62. data/lib/autoproj/vcs_definition.rb +57 -17
  63. data/lib/autoproj/version.rb +1 -1
  64. data/lib/autoproj/workspace.rb +550 -0
  65. data/test/ops/test_snapshot.rb +26 -0
  66. data/test/test_package.rb +30 -0
  67. data/test/test_vcs_definition.rb +46 -0
  68. metadata +55 -50
  69. data/bin/autolocate +0 -3
  70. data/bin/autoproj-bootstrap +0 -68
  71. data/bin/autoproj-cache +0 -18
  72. data/bin/autoproj-clean +0 -13
  73. data/bin/autoproj-commit +0 -10
  74. data/bin/autoproj-create-set +0 -118
  75. data/bin/autoproj-doc +0 -28
  76. data/bin/autoproj-envsh +0 -14
  77. data/bin/autoproj-list +0 -69
  78. data/bin/autoproj-locate +0 -85
  79. data/bin/autoproj-log +0 -5
  80. data/bin/autoproj-query +0 -82
  81. data/bin/autoproj-reset +0 -13
  82. data/bin/autoproj-show +0 -192
  83. data/bin/autoproj-snapshot +0 -27
  84. data/bin/autoproj-switch-config +0 -24
  85. data/bin/autoproj-tag +0 -13
  86. data/bin/autoproj-test +0 -31
  87. data/bin/autoproj-versions +0 -20
  88. data/bin/autoproj_stress_test +0 -40
  89. data/lib/autoproj/cmdline.rb +0 -1649
@@ -74,7 +74,14 @@ module Autobuild
74
74
 
75
75
  module Subprocess
76
76
  def self.run(name, phase, *cmd)
77
- output = `'#{cmd.join("' '")}'`
77
+ if cmd.last.kind_of?(Hash)
78
+ options = cmd.pop
79
+ (options[:env] || Hash.new).each do |k, v|
80
+ ENV[k] = v
81
+ end
82
+ end
83
+
84
+ output = `#{cmd.join(" ")}`
78
85
  if $?.exitstatus != 0
79
86
  STDERR.puts "ERROR: failed to run #{cmd.join(" ")}"
80
87
  STDERR.puts "ERROR: command output is: #{output}"
@@ -94,7 +101,6 @@ end
94
101
 
95
102
  OSDEPS_CODE
96
103
  TOOLS_CODE
97
- OPTIONS_CODE
98
104
  SYSTEM_CODE
99
105
 
100
106
  DEFS = <<EODEFS
@@ -148,6 +154,24 @@ if !curdir_entries.empty? && ENV['AUTOPROJ_BOOTSTRAP_IGNORE_NONEMPTY_DIR'] != '1
148
154
  end
149
155
  end
150
156
 
157
+ # While in here, we don't have utilrb
158
+ module Kernel
159
+ def filter_options(options, defaults)
160
+ options = options.dup
161
+ filtered = Hash.new
162
+ defaults.each do |k, v|
163
+ filtered[k] =
164
+ if options.has_key?(k) then options.delete(k)
165
+ else v
166
+ end
167
+ end
168
+ return filtered, options
169
+ end
170
+ def validate_options(options, defaults)
171
+ defaults.merge(options)
172
+ end
173
+ end
174
+
151
175
  # Environment is clean, so just mark it as so unconditionally
152
176
  ENV['AUTOPROJ_BOOTSTRAP_IGNORE_NONEMPTY_DIR'] = '1'
153
177
 
@@ -159,7 +183,6 @@ ENV['GEM_HOME'] = gem_home
159
183
  ENV['GEM_PATH'] = gem_path
160
184
  ENV['PATH'] = "#{ENV['GEM_HOME']}/bin:#{ENV['PATH']}"
161
185
 
162
-
163
186
  Autoproj::OSDependencies.define_osdeps_mode_option
164
187
  osdeps_mode = Autoproj::OSDependencies.osdeps_mode.join(",")
165
188
  ENV['AUTOPROJ_OSDEPS_MODE'] = osdeps_mode
@@ -178,6 +201,7 @@ osdeps_management =
178
201
  Autoproj::OSDependencies.new(YAML.load(DEFS))
179
202
  end
180
203
  osdeps_management.silent = false
204
+ Autoproj::PackageManagers::GemManager.gem_home = gem_home
181
205
  Autoproj::PackageManagers::GemManager.use_cache_dir
182
206
 
183
207
  begin
@@ -1,7 +1,10 @@
1
1
  require "enumerator"
2
+ require 'utilrb/module/attr_predicate'
2
3
  require 'autobuild'
3
4
  require 'autoproj/base'
5
+ require 'autoproj/exceptions'
4
6
  require 'autoproj/version'
7
+ require 'autoproj/reporter'
5
8
  require 'autoproj/environment'
6
9
  require 'autoproj/variable_expansion'
7
10
  require 'autoproj/vcs_definition'
@@ -17,15 +20,18 @@ require 'autoproj/system'
17
20
  require 'autoproj/build_option'
18
21
  require 'autoproj/configuration'
19
22
  require 'autoproj/options'
23
+ # Required by Workspace
24
+ require 'autoproj/ops/import'
20
25
  # Required for auto-saving in import_packages
21
26
  require 'autoproj/ops/snapshot'
22
- require 'autoproj/cmdline'
23
27
  require 'autoproj/query'
24
28
 
25
29
  require 'autoproj/ops/tools'
26
30
  require 'autoproj/ops/loader'
27
31
  require 'autoproj/ops/configuration'
28
32
 
33
+ require 'autoproj/workspace'
34
+
29
35
  require 'logger'
30
36
  require 'utilrb/logger'
31
37
 
@@ -37,5 +43,21 @@ module Autoproj
37
43
  logger.level = Logger::WARN
38
44
  logger.formatter = lambda { |severity, time, progname, msg| "#{severity}: #{msg}\n" }
39
45
  extend Logger::Forward
46
+
47
+ def self.warn_deprecated_level
48
+ @warn_deprecated_level
49
+ end
50
+
51
+ def self.warn_deprecated_level=(level)
52
+ @warn_deprecated_level = level
53
+ end
54
+ @warn_deprecated_level = 0
55
+
56
+ def self.warn_deprecated(method, msg, level = 0)
57
+ if level >= @warn_deprecated_level
58
+ Autoproj.warn "#{method} is deprecated, #{msg}"
59
+ caller.each { |l| Autoproj.warn " #{l}" }
60
+ end
61
+ end
40
62
  end
41
63
 
@@ -3,9 +3,17 @@ require 'fileutils'
3
3
  require 'autobuild'
4
4
  require 'set'
5
5
 
6
- def explicit_osdeps_selection(name)
7
- if !Autoproj.declared_option?("osdeps_#{name}")
8
- if Autoproj.has_config_key?("osdeps_#{name}")
6
+ module Autoproj
7
+ module CmdLine
8
+ def self.ruby_executable
9
+ Autoproj.workspace.config.ruby_executable
10
+ end
11
+ end
12
+ end
13
+
14
+ def explicit_osdeps_selection(name, config = Autoproj.config)
15
+ if !config.declared?("osdeps_#{name}")
16
+ if config.has_value_for?("osdeps_#{name}")
9
17
  doc_string = "install #{name} from source ?"
10
18
  else
11
19
  # Declare the option
@@ -18,12 +26,12 @@ Do you want me to build #{name} from source ? If you say 'no', you will have to
18
26
  EOT
19
27
  end
20
28
 
21
- Autoproj.configuration_option(
29
+ config.declare(
22
30
  "osdeps_#{name}", "boolean",
23
31
  :default => "yes",
24
32
  :doc => doc_string)
25
33
  end
26
- !Autoproj.user_config("osdeps_#{name}")
34
+ !config.get("osdeps_#{name}")
27
35
  end
28
36
 
29
37
  module Autobuild
@@ -100,18 +108,12 @@ module Autobuild
100
108
  name = name.name
101
109
  end
102
110
 
103
- if Autoproj::CmdLine.ignore_dependencies?
104
- return
105
- end
106
-
107
111
  @os_packages ||= Set.new
108
112
  pkg_autobuild, pkg_os = partition_package(name)
109
113
  pkg_autobuild.each do |pkg|
110
114
  __depends_on__(pkg)
111
115
  end
112
116
  @os_packages |= pkg_os.to_set
113
- rescue Autoproj::OSDependencies::MissingOSDep
114
- Autoproj.manifest.add_exclusion(self.name, "it depends on #{name}, which is neither the name of a source package, nor an osdep that is available on this operating system")
115
117
  end
116
118
 
117
119
  def depends_on_os_package(name)
@@ -125,16 +127,12 @@ module Autobuild
125
127
  end
126
128
 
127
129
  def optional_dependency(name)
128
- if Autoproj::CmdLine.ignore_dependencies?
129
- return
130
- end
131
-
132
130
  optional_dependencies << name
133
131
  end
134
132
 
135
133
  def partition_package(pkg_name)
136
134
  pkg_autobuild, pkg_osdeps = [], []
137
- Autoproj.manifest.resolve_package_name(pkg_name).each do |type, dep_name|
135
+ Autoproj.workspace.manifest.resolve_package_name(pkg_name).each do |type, dep_name|
138
136
  if type == :osdeps
139
137
  pkg_osdeps << dep_name
140
138
  elsif type == :package
@@ -146,34 +144,23 @@ module Autobuild
146
144
  end
147
145
 
148
146
  def partition_optional_dependencies
149
- packages, osdeps, disabled = [], [], []
147
+ packages, osdeps = [], []
150
148
  optional_dependencies.each do |name|
151
- if !Autoproj.manifest.package_enabled?(name, false)
152
- disabled << name
153
- next
154
- end
155
-
156
- pkg_autobuild, pkg_osdeps = partition_package(name)
157
- valid = pkg_autobuild.all? { |pkg| Autoproj.manifest.package_enabled?(pkg) } &&
158
- pkg_osdeps.all? { |pkg| Autoproj.manifest.package_enabled?(pkg) }
159
-
160
- if valid
149
+ begin
150
+ pkg_autobuild, pkg_osdeps = partition_package(name)
161
151
  packages.concat(pkg_autobuild)
162
152
  osdeps.concat(pkg_osdeps)
163
- else
164
- disabled << name
153
+ rescue Autoproj::PackageNotFound
154
+ # Simply ignore non-existent optional dependencies
165
155
  end
166
156
  end
167
- return packages, osdeps, disabled
157
+ return packages, osdeps
168
158
  end
169
159
 
170
160
  def resolve_optional_dependencies
171
- if !Autoproj::CmdLine.ignore_dependencies?
172
- packages, osdeps, disabled = partition_optional_dependencies
173
- packages.each { |pkg| depends_on(pkg) }
174
- @os_packages ||= Set.new
175
- @os_packages |= osdeps.to_set
176
- end
161
+ packages, osdeps = partition_optional_dependencies
162
+ packages.each { |pkg| __depends_on__(pkg) }
163
+ os_packages.merge(osdeps.to_set)
177
164
  end
178
165
 
179
166
  def optional_dependencies
@@ -223,25 +210,6 @@ module Autobuild
223
210
  end
224
211
 
225
212
  module Autoproj
226
- # Subclass of Autobuild::Reporter, used to display a message when the build
227
- # finishes/fails.
228
- class Reporter < Autobuild::Reporter
229
- def error(error)
230
- error_lines = error.to_s.split("\n")
231
- Autoproj.message("Command failed", :bold, :red, STDERR)
232
- Autoproj.message("#{error_lines.shift}", :bold, :red, STDERR)
233
- error_lines.each do |line|
234
- Autoproj.message line, STDERR
235
- end
236
- end
237
- def success
238
- Autoproj.message("Command finished successfully at #{Time.now}", :bold, :green)
239
- if Autobuild.post_success_message
240
- Autoproj.message Autobuild.post_success_message
241
- end
242
- end
243
- end
244
-
245
213
  @file_stack = Array.new
246
214
 
247
215
  def self.package_name_from_options(spec)
@@ -252,40 +220,34 @@ module Autoproj
252
220
  end
253
221
  end
254
222
 
255
- # @deprecated use Ops.loader.in_package_set or add a proper Loader object to your
223
+ # @deprecated use Autoproj.workspace.in_package_set or add a proper Loader object to your
256
224
  # class
257
225
  def self.in_package_set(package_set, path, &block)
258
- Ops.loader.in_package_set(package_set, path, &block)
226
+ Autoproj.workspace.in_package_set(package_set, path, &block)
259
227
  end
260
-
261
- # @deprecated use Ops.loader.current_file or add a proper Loader object to your
228
+ # @deprecated use Autoproj.workspace.current_file or add a proper Loader object to your
262
229
  # class
263
230
  def self.current_file
264
- Ops.loader.current_file
231
+ Autoproj.workspace.current_file
265
232
  end
266
-
267
- # @deprecated use Ops.loader.current_package_set or add a proper Loader object to your
233
+ # @deprecated use Autoproj.workspace.current_package_set or add a proper Loader object to your
268
234
  # class
269
235
  def self.current_package_set
270
- Ops.loader.current_package_set
236
+ Autoproj.workspace.current_package_set
271
237
  end
272
238
 
273
239
  def self.define(package_type, spec, &block)
274
240
  package = Autobuild.send(package_type, spec)
275
- Autoproj.manifest.register_package(package, block, *current_file)
241
+ Autoproj.workspace.manifest.register_package(package, block, *current_file)
276
242
  package
277
243
  end
278
244
 
279
- @loaded_autobuild_files = Set.new
280
-
281
- class << self
282
- attr_reader :loaded_autobuild_files
245
+ def self.loaded_autobuild_files
246
+ Autoproj.workspace.loaded_autobuild_files
283
247
  end
284
248
 
285
249
  def self.import_autobuild_file(package_set, path)
286
- return if @loaded_autobuild_files.include?(path)
287
- Autoproj.load(package_set, path)
288
- @loaded_autobuild_files << path
250
+ Autoproj.workspace.import_autobuild_file(package_set, path)
289
251
  end
290
252
 
291
253
  def self.find_topmost_directory_containing(dir, glob_pattern = nil)
@@ -344,7 +306,7 @@ def setup_package(package_name, &block)
344
306
  raise ConfigError.new, "you must give a block to #setup_package"
345
307
  end
346
308
 
347
- package_definition = Autoproj.manifest.package(package_name)
309
+ package_definition = Autoproj.workspace.manifest.package(package_name)
348
310
  if !package_definition
349
311
  raise ConfigError.new, "#{package_name} is not a known package"
350
312
  elsif package_definition.autobuild.kind_of?(Autobuild::DummyPackage)
@@ -360,7 +322,7 @@ def package_common(package_type, spec, &block)
360
322
 
361
323
  if Autobuild::Package[package_name]
362
324
  current_file = Autoproj.current_file[1]
363
- old_file = Autoproj.manifest.definition_file(package_name)
325
+ old_file = Autoproj.workspace.manifest.definition_file(package_name)
364
326
  Autoproj.warn "#{package_name} from #{current_file} is overridden by the definition in #{old_file}"
365
327
 
366
328
  return Autobuild::Package[package_name]
@@ -434,10 +396,10 @@ def autotools_package(options, &block)
434
396
  end
435
397
 
436
398
  def env_set(name, value)
437
- Autoproj.env_set(name, value)
399
+ Autoproj.env.set(name, value)
438
400
  end
439
401
  def env_add(name, value)
440
- Autoproj.env_add(name, value)
402
+ Autoproj.env.add(name, value)
441
403
  end
442
404
 
443
405
 
@@ -548,7 +510,7 @@ def not_on(*architectures)
548
510
  current_packages
549
511
 
550
512
  new_packages.each do |pkg_name|
551
- Autoproj.manifest.add_exclusion(pkg_name, "#{pkg_name} is disabled on this operating system")
513
+ Autoproj.workspace.manifest.add_exclusion(pkg_name, "#{pkg_name} is disabled on this operating system")
552
514
  end
553
515
  end
554
516
 
@@ -563,16 +525,16 @@ end
563
525
 
564
526
  # Define a configuration option
565
527
  #
566
- # See Autoproj.configuration_option
528
+ # @see Autoproj::Configuration#declare
567
529
  def configuration_option(*opts, &block)
568
- Autoproj.configuration_option(*opts, &block)
530
+ Autoproj.config.declare(*opts, &block)
569
531
  end
570
532
 
571
533
  # Retrieves the configuration value for the given option
572
534
  #
573
535
  # See Autoproj.user_config
574
536
  def user_config(key)
575
- Autoproj.user_config(key)
537
+ Autoproj.config.get(key)
576
538
  end
577
539
 
578
540
  class Autobuild::Git
@@ -625,42 +587,42 @@ class Autobuild::ArchiveImporter
625
587
  end
626
588
 
627
589
  def package(name)
628
- Autobuild::Package[name]
590
+ Autoproj.workspace.manifest.find_autobuild_package(name)
629
591
  end
630
592
 
631
593
  # Returns true if +name+ is a valid package and is neither excluded nor ignored
632
594
  # from the build
633
595
  def package_selected?(name)
634
- Autoproj.manifest.package_selected?(name, false)
596
+ Autoproj.workspace.manifest.package_selected?(name, false)
635
597
  end
636
598
 
637
599
  # Returns true if +name+ is a valid package and is included in the build
638
600
  def package_enabled?(name)
639
- Autoproj.manifest.package_enabled?(name, false)
601
+ Autoproj.workspace.manifest.package_enabled?(name, false)
640
602
  end
641
603
 
642
604
  # If used in init.rb, allows to disable automatic imports from specific package
643
605
  # sets
644
606
  def disable_imports_from(name)
645
- Autoproj.manifest.disable_imports_from(name)
607
+ Autoproj.workspace.manifest.disable_imports_from(name)
646
608
  end
647
609
 
648
610
  # Moves the given package to a new subdirectory
649
611
  def move_package(name, new_dir)
650
- Autoproj.manifest.move_package(name, new_dir)
612
+ Autoproj.workspace.manifest.move_package(name, new_dir)
651
613
  end
652
614
 
653
615
  # Removes all the packages currently added from the given metapackage
654
616
  #
655
617
  # Calling this function will make sure that the given metapackage is now empty.
656
618
  def clear_metapackage(name)
657
- meta = Autoproj.manifest.metapackage(name)
619
+ meta = Autoproj.workspace.manifest.metapackage(name)
658
620
  meta.packages.clear
659
621
  end
660
622
 
661
623
  # Declares a new metapackage, or adds packages to an existing one
662
624
  def metapackage(name, *packages)
663
- Autoproj.manifest.metapackage(name, *packages)
625
+ Autoproj.workspace.manifest.metapackage(name, *packages)
664
626
  end
665
627
 
666
628
  # This can be used only during the load of a package set
@@ -682,15 +644,15 @@ end
682
644
  # their dependencies) are.
683
645
  def remove_from_default(*names)
684
646
  pkg_set = Autoproj.current_package_set
685
- Autoproj.manifest.metapackage(pkg_set.name).packages.delete_if do |pkg|
647
+ Autoproj.workspace.manifest.metapackage(pkg_set.name).packages.delete_if do |pkg|
686
648
  names.include?(pkg.name)
687
649
  end
688
650
  end
689
651
 
690
652
  def renamed_package(current_name, old_name, options)
691
- if options[:obsolete] && !Autoproj.manifest.explicitely_selected_in_layout?(old_name)
653
+ if options[:obsolete] && !Autoproj.workspace.manifest.explicitely_selected_in_layout?(old_name)
692
654
  import_package old_name
693
- Autoproj.manifest.add_exclusion old_name, "#{old_name} has been renamed to #{current_name}, you still have the option of using the old name by adding '- #{old_name}' explicitely in the layout in autoproj/manifest, but be warned that the name will stop being usable at all in the near future"
655
+ Autoproj.workspace.manifest.add_exclusion old_name, "#{old_name} has been renamed to #{current_name}, you still have the option of using the old name by adding '- #{old_name}' explicitely in the layout in autoproj/manifest, but be warned that the name will stop being usable at all in the near future"
694
656
  else
695
657
  metapackage old_name, current_name
696
658
  end
@@ -7,15 +7,6 @@ module Autoproj
7
7
  ArgumentError
8
8
  end
9
9
 
10
- class ConfigError < RuntimeError
11
- attr_accessor :file
12
- def initialize(file = nil)
13
- super
14
- @file = file
15
- end
16
- end
17
- class InternalError < RuntimeError; end
18
-
19
10
  # Yields, and if the given block raises a ConfigError with no file assigned,
20
11
  # add that file to both the object and the exception message
21
12
  def self.in_file(file, exception_t = ConfigError)
@@ -1,8 +1,6 @@
1
1
  module Autoproj
2
- class InputError < RuntimeError; end
3
-
4
2
  # Definition of an autoproj option as defined by
5
- # {Configuration#configuration_option}
3
+ # {Configuration#declare}
6
4
  class BuildOption
7
5
  attr_reader :name
8
6
  attr_reader :type