autoproj 1.10.2 → 1.11.0.b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +9 -0
  3. data/Rakefile +4 -0
  4. data/bin/aup +5 -1
  5. data/bin/autolocate +1 -82
  6. data/bin/autoproj +6 -56
  7. data/bin/autoproj-bootstrap +31 -3
  8. data/bin/autoproj-cache +3 -60
  9. data/bin/autoproj-clean +1 -1
  10. data/bin/autoproj-create-set +0 -0
  11. data/bin/autoproj-doc +1 -1
  12. data/bin/autoproj-envsh +0 -0
  13. data/bin/autoproj-list +1 -1
  14. data/bin/autoproj-locate +17 -16
  15. data/bin/autoproj-query +0 -0
  16. data/bin/autoproj-show +0 -0
  17. data/bin/autoproj-switch-config +23 -0
  18. data/bin/autoproj-test +2 -2
  19. data/bin/autoproj_bootstrap +354 -210
  20. data/bin/autoproj_bootstrap.in +8 -0
  21. data/bin/autoproj_stress_test +1 -1
  22. data/lib/autoproj.rb +7 -0
  23. data/lib/autoproj/autobuild.rb +14 -35
  24. data/lib/autoproj/build_option.rb +104 -0
  25. data/lib/autoproj/cmdline.rb +62 -355
  26. data/lib/autoproj/configuration.rb +161 -0
  27. data/lib/autoproj/gitorious.rb +31 -20
  28. data/lib/autoproj/installation_manifest.rb +7 -1
  29. data/lib/autoproj/manifest.rb +124 -342
  30. data/lib/autoproj/ops/build.rb +107 -0
  31. data/lib/autoproj/ops/cache.rb +82 -0
  32. data/lib/autoproj/ops/configuration.rb +302 -0
  33. data/lib/autoproj/ops/loader.rb +97 -0
  34. data/lib/autoproj/ops/main_config_switcher.rb +271 -0
  35. data/lib/autoproj/ops/tools.rb +54 -0
  36. data/lib/autoproj/options.rb +26 -178
  37. data/lib/autoproj/osdeps.rb +49 -9
  38. data/lib/autoproj/package_set.rb +168 -87
  39. data/lib/autoproj/system.rb +6 -23
  40. data/lib/autoproj/variable_expansion.rb +0 -1
  41. data/lib/autoproj/vcs_definition.rb +23 -0
  42. data/lib/autoproj/version.rb +1 -1
  43. metadata +17 -7
File without changes
File without changes
@@ -0,0 +1,23 @@
1
+ #! /usr/bin/env ruby
2
+ require 'autoproj'
3
+ require 'autoproj/ops/main_config_switcher'
4
+
5
+ Autoproj::CmdLine.report do
6
+ Autoproj::CmdLine.initialize
7
+
8
+ if Dir.pwd.start_with?(Autoproj.remotes_dir) || Dir.pwd.start_with?(Autoproj.config_dir)
9
+ raise ConfigError, "you cannot run autoproj switch-config from autoproj's configuration directory or one of its subdirectories"
10
+ end
11
+
12
+ # We must switch to the root dir first, as it is required by the
13
+ # configuration switch code. This is acceptable as long as we
14
+ # quit just after the switch
15
+ Dir.chdir(Autoproj.root_dir)
16
+ switcher = Autoproj::Ops::MainConfigSwitcher.new(Autoproj.root_dir)
17
+ if switcher.switch_config(*ARGV)
18
+ manifest = Autoproj::Manifest.load(File.join(Autoproj.config_dir, 'manifest'))
19
+ update = Autoproj::Ops::Configuration.new(manifest, Autoproj::Ops.loader)
20
+ update.update_configuration
21
+ end
22
+ end
23
+
@@ -22,7 +22,7 @@ Autoproj::CmdLine.report do
22
22
  resolved_selection = Autoproj::CmdLine.
23
23
  resolve_user_selection(user_selection, :filter => false)
24
24
  # Remove non-existing packages
25
- Autoproj.manifest.each_package do |pkg|
25
+ Autoproj.manifest.each_autobuild_package do |pkg|
26
26
  if !File.directory?(pkg.srcdir)
27
27
  Autoproj.manifest.add_exclusion(pkg, "#{pkg.name} is not checked out")
28
28
  end
@@ -31,6 +31,6 @@ Autoproj::CmdLine.report do
31
31
  # This calls #prepare, which is required to run build_packages
32
32
  packages = Autoproj::CmdLine.import_packages(resolved_selection)
33
33
  packages.each { |pkg| Autobuild::Package[pkg].disable_phases('import', 'prepare', 'install') }
34
- Autoproj::CmdLine.build_packages(resolved_selection, packages, ['test'])
34
+ Autobuild.apply(packages, "autoproj-test", ['test'])
35
35
  end
36
36
 
@@ -125,6 +125,279 @@ module Autobuild
125
125
  end
126
126
  end
127
127
 
128
+ module Autoproj
129
+ class InputError < RuntimeError; end
130
+
131
+ # Definition of an autoproj option as defined by
132
+ # {Configuration#configuration_option}
133
+ class BuildOption
134
+ attr_reader :name
135
+ attr_reader :type
136
+ attr_reader :options
137
+
138
+ attr_reader :validator
139
+
140
+ TRUE_STRINGS = %w{on yes y true}
141
+ FALSE_STRINGS = %w{off no n false}
142
+ def initialize(name, type, options, validator)
143
+ @name, @type, @options = name.to_str, type.to_str, options.to_hash
144
+ @validator = validator.to_proc if validator
145
+ if !BuildOption.respond_to?("validate_#{type}")
146
+ raise ConfigError.new, "invalid option type #{type}"
147
+ end
148
+ end
149
+
150
+ def short_doc
151
+ if short_doc = options[:short_doc]
152
+ short_doc
153
+ elsif doc = options[:doc]
154
+ if doc.respond_to?(:to_ary) then doc.first
155
+ else doc
156
+ end
157
+ else "#{name} (no documentation for this option)"
158
+ end
159
+ end
160
+
161
+ def doc
162
+ doc = (options[:doc] || "#{name} (no documentation for this option)")
163
+ if doc.respond_to?(:to_ary) # multi-line
164
+ first_line = doc[0]
165
+ remaining = doc[1..-1]
166
+ if remaining.empty?
167
+ first_line
168
+ else
169
+ remaining = remaining.join("\n").split("\n").join("\n ")
170
+ Autoproj.color(first_line, :bold) + "\n " + remaining
171
+ end
172
+ else
173
+ doc
174
+ end
175
+ end
176
+
177
+ def ask(current_value, doc = nil)
178
+ default_value =
179
+ if !current_value.nil? then current_value.to_s
180
+ elsif options[:default] then options[:default].to_str
181
+ else ''
182
+ end
183
+
184
+ STDOUT.print " #{doc || self.doc} [#{default_value}] "
185
+ STDOUT.flush
186
+ answer = STDIN.readline.chomp
187
+ if answer == ''
188
+ answer = default_value
189
+ end
190
+ validate(answer)
191
+
192
+ rescue InputError => e
193
+ Autoproj.message("invalid value: #{e.message}", :red)
194
+ retry
195
+ end
196
+
197
+ def validate(value)
198
+ value = BuildOption.send("validate_#{type}", value, options)
199
+ if validator
200
+ value = validator[value]
201
+ end
202
+ value
203
+ end
204
+
205
+ def self.validate_boolean(value, options)
206
+ if TRUE_STRINGS.include?(value.downcase)
207
+ true
208
+ elsif FALSE_STRINGS.include?(value.downcase)
209
+ false
210
+ else
211
+ raise InputError, "invalid boolean value '#{value}', accepted values are '#{TRUE_STRINGS.join(", ")}' for true, and '#{FALSE_STRINGS.join(", ")} for false"
212
+ end
213
+ end
214
+
215
+ def self.validate_string(value, options)
216
+ if possible_values = options[:possible_values]
217
+ if options[:lowercase]
218
+ value = value.downcase
219
+ elsif options[:uppercase]
220
+ value = value.upcase
221
+ end
222
+
223
+ if !possible_values.include?(value)
224
+ raise InputError, "invalid value '#{value}', accepted values are '#{possible_values.join("', '")}' (without the quotes)"
225
+ end
226
+ end
227
+ value
228
+ end
229
+ end
230
+ end
231
+
232
+
233
+ module Autoproj
234
+ # Class that does the handling of configuration options as well as
235
+ # loading/saving on disk
236
+ class Configuration
237
+ # Set of currently known options
238
+ #
239
+ # These are the values that are going to be saved on disk. Use
240
+ # {override} to change a value without changing the saved configuration
241
+ # file.
242
+ attr_reader :config
243
+ # Set of overriden option values that won't get written to file
244
+ attr_reader :overrides
245
+ # Set of options that have been declared with {declare}
246
+ attr_reader :declared_options
247
+ # The options that have already been shown to the user
248
+ attr_reader :displayed_options
249
+
250
+ def initialize
251
+ @config = Hash.new
252
+ @overrides = Hash.new
253
+ @declared_options = Hash.new
254
+ @displayed_options = Hash.new
255
+ end
256
+
257
+ # Deletes the current value for an option
258
+ #
259
+ # The user will be asked for a new value next time the option is needed
260
+ #
261
+ # @param [String] the option name
262
+ # @return the deleted value
263
+ def reset(name)
264
+ config.delete(name)
265
+ end
266
+
267
+ # Sets a configuration option
268
+ #
269
+ # @param [String] key the option name
270
+ # @param [Object] value the option value
271
+ # @param [Boolean] user_validated if true, autoproj will not ask the
272
+ # user about this value next time it is needed. Otherwise, it will be
273
+ # asked about it, the new value being used as default
274
+ def set(key, value, user_validated = false)
275
+ config[key] = [value, user_validated]
276
+ end
277
+
278
+ # Override a known option value
279
+ #
280
+ # The new value will not be saved to disk, unlike with {set}
281
+ def override(option_name, value)
282
+ overrides[option_name] = value
283
+ end
284
+
285
+ # Tests whether a value is set for the given option name
286
+ #
287
+ # @return [Boolean]
288
+ def has_value_for?(name)
289
+ config.has_key?(name) || overrides.has_key?(name)
290
+ end
291
+
292
+ # Get the value for a given option
293
+ def get(key)
294
+ if overrides.has_key?(key)
295
+ return overrides[key]
296
+ end
297
+
298
+ value, validated = config[key]
299
+ if value.nil? || (declared?(key) && !validated)
300
+ value = configure(key)
301
+ else
302
+ if declared?(key) && (displayed_options[key] != value)
303
+ doc = declared_options[key].short_doc
304
+ if doc[-1, 1] != "?"
305
+ doc = "#{doc}:"
306
+ end
307
+ Autoproj.message " #{doc} #{value}"
308
+ displayed_options[key] = value
309
+ end
310
+ value
311
+ end
312
+ end
313
+
314
+ # Returns the option's name-value pairs for the options that do not
315
+ # require user input
316
+ def validated_values
317
+ config.inject(Hash.new) do |h, (k, v)|
318
+ h[k] =
319
+ if overrides.has_key?(k) then overrides[k]
320
+ elsif v.last || !declared?(k) then v.first
321
+ end
322
+ h
323
+ end
324
+ end
325
+
326
+ # Declare an option
327
+ #
328
+ # This declares a given option, thus allowing to ask the user about it
329
+ #
330
+ # @param [String] name the option name
331
+ # @param [String] type the option type (can be 'boolean' or 'string')
332
+ # @option options [String] :short_doc the one-line documentation string
333
+ # that is displayed when the user does not have to be queried. It
334
+ # defaults to the first line of :doc if not given
335
+ # @option options [String] :doc the full option documentation. It is
336
+ # displayed to the user when he is explicitly asked about the option's
337
+ # value
338
+ # @option options [Object] :default the default value this option should
339
+ # take
340
+ # @option options [Array] :possible_values list of possible values (only
341
+ # if the option type is 'string')
342
+ # @option options [Boolean] :lowercase (false) whether the user's input
343
+ # should be converted to lowercase before it gets validated / saved.
344
+ # @option options [Boolean] :uppercase (false) whether the user's input
345
+ # should be converted to uppercase before it gets validated / saved.
346
+ def declare(name, type, options, &validator)
347
+ declared_options[name] = BuildOption.new(name, type, options, validator)
348
+ end
349
+
350
+ # Checks if an option exists
351
+ # @return [Boolean]
352
+ def declared?(name)
353
+ declared_options.has_key?(name)
354
+ end
355
+
356
+ # Configures a given option by asking the user about its desired value
357
+ #
358
+ # @return [Object] the new option value
359
+ # @raise ConfigError if the option is not declared
360
+ def configure(option_name)
361
+ if opt = declared_options[option_name]
362
+ if current_value = config[option_name]
363
+ current_value = current_value.first
364
+ end
365
+ value = opt.ask(current_value)
366
+ config[option_name] = [value, true]
367
+ displayed_options[option_name] = value
368
+ value
369
+ else
370
+ raise ConfigError.new, "undeclared option '#{option_name}'"
371
+ end
372
+ end
373
+
374
+ def load(path, reconfigure = false)
375
+ if h = YAML.load(File.read(path))
376
+ h.each do |key, value|
377
+ set(key, value, !reconfigure)
378
+ end
379
+ end
380
+ end
381
+
382
+ def save(path)
383
+ File.open(path, "w") do |io|
384
+ h = Hash.new
385
+ config.each do |key, value|
386
+ h[key] = value.first
387
+ end
388
+
389
+ io.write YAML.dump(h)
390
+ end
391
+ end
392
+ end
393
+ end
394
+
395
+ module Autoproj
396
+ def self.config
397
+ @config ||= Configuration.new
398
+ end
399
+ end
400
+
128
401
  require 'tempfile'
129
402
  require 'json'
130
403
  module Autoproj
@@ -547,6 +820,25 @@ fi
547
820
  end
548
821
  new_packages
549
822
  end
823
+
824
+ def install(packages)
825
+ patterns, packages = packages.partition { |pkg| pkg =~ /^@/ }
826
+ patterns = patterns.map { |str| str[1..-1] }
827
+ result = false
828
+ if !patterns.empty?
829
+ result |= super(patterns,
830
+ :auto_install_cmd => "yum groupinstall -y '%s'",
831
+ :user_install_cmd => "yum groupinstall '%s'")
832
+ end
833
+ if !packages.empty?
834
+ result |= super(packages)
835
+ end
836
+ if result
837
+ # Invalidate caching of installed packages, as we just
838
+ # installed new packages !
839
+ @installed_packages = nil
840
+ end
841
+ end
550
842
  end
551
843
 
552
844
  # Package manager interface for systems that use APT and dpkg for
@@ -701,6 +993,7 @@ fi
701
993
  end
702
994
 
703
995
  def reinstall
996
+ Autoproj.message "reinstalling all RubyGems"
704
997
  base_cmdline = [Autobuild.tool_in_path('ruby'), '-S', Autobuild.tool('gem')]
705
998
  Autobuild::Subprocess.run 'autoproj', 'osdeps', 'reinstall', *base_cmdline,
706
999
  'clean'
@@ -738,7 +1031,7 @@ fi
738
1031
  gems.each do |name, v|
739
1032
  installed_gems << name
740
1033
  end
741
- did_something = true
1034
+ true
742
1035
  end
743
1036
  end
744
1037
 
@@ -1125,7 +1418,20 @@ fi
1125
1418
  root_dir ||= "#{Autoproj.root_dir}/"
1126
1419
  old = source_of(h).gsub(root_dir, '')
1127
1420
  new = info.source_of(h).gsub(root_dir, '')
1128
- Autoproj.warn("osdeps definition for #{h}, previously defined in #{old} overridden by #{new}")
1421
+
1422
+ # Warn if the new osdep definition resolves to a different
1423
+ # set of packages than the old one
1424
+ old_resolved = resolve_package(h).inject(Hash.new) do |osdep_h, (handler, status, list)|
1425
+ osdep_h[handler.name] = [status, list]
1426
+ h
1427
+ end
1428
+ new_resolved = info.resolve_package(h).inject(Hash.new) do |osdep_h, (handler, status, list)|
1429
+ osdep_h[handler.name] = [status, list]
1430
+ h
1431
+ end
1432
+ if old_resolved != new_resolved
1433
+ Autoproj.warn("osdeps definition for #{h}, previously defined in #{old} overridden by #{new}")
1434
+ end
1129
1435
  end
1130
1436
  v2
1131
1437
  end
@@ -1281,11 +1587,7 @@ fi
1281
1587
  options.dup
1282
1588
  end
1283
1589
 
1284
- if options[:force]
1285
- @operating_system = nil
1286
- elsif !@operating_system.nil? # @operating_system can be set to false to simulate an unknown OS
1287
- return @operating_system
1288
- elsif user_os = ENV['AUTOPROJ_OS']
1590
+ if user_os = ENV['AUTOPROJ_OS']
1289
1591
  @operating_system =
1290
1592
  if user_os.empty? then false
1291
1593
  else
@@ -1293,6 +1595,13 @@ fi
1293
1595
  normalize_os_representation(names.split(','), versions.split(','))
1294
1596
  end
1295
1597
  return @operating_system
1598
+ end
1599
+
1600
+
1601
+ if options[:force]
1602
+ @operating_system = nil
1603
+ elsif !@operating_system.nil? # @operating_system can be set to false to simulate an unknown OS
1604
+ return @operating_system
1296
1605
  elsif Autoproj.has_config_key?('operating_system')
1297
1606
  os = Autoproj.user_config('operating_system')
1298
1607
  if os.respond_to?(:to_ary)
@@ -1588,8 +1897,12 @@ fi
1588
1897
  # Resolves the given OS dependencies into the actual packages that need
1589
1898
  # to be installed on this particular OS.
1590
1899
  #
1591
- # Raises ConfigError if some packages can't be found or if the
1592
- # nonexistent keyword was found for some of them
1900
+ # @param [Array<String>] dependencies the list of osdep names that should be resolved
1901
+ # @return [Array<#install,Array<String>>] the set of packages, grouped
1902
+ # by the package handlers that should be used to install them
1903
+ #
1904
+ # @raise MissingOSDep if some packages can't be found or if the
1905
+ # nonexistent keyword was found for some of them
1593
1906
  def resolve_os_dependencies(dependencies)
1594
1907
  all_packages = []
1595
1908
  dependencies.each do |name|
@@ -2019,205 +2332,53 @@ end
2019
2332
 
2020
2333
 
2021
2334
  module Autoproj
2022
- class InputError < RuntimeError; end
2023
-
2024
- class << self
2025
- # Programatically overriden autoproj options
2026
- #
2027
- # @see override_option
2028
- attr_reader :option_overrides
2029
- end
2030
- @option_overrides = Hash.new
2031
-
2032
- # Programatically override a user-selected option without changing the
2033
- # configuration file
2335
+ # @deprecated use config.override instead
2034
2336
  def self.override_option(option_name, value)
2035
- @option_overrides[option_name] = value
2036
- end
2037
-
2038
- class BuildOption
2039
- attr_reader :name
2040
- attr_reader :type
2041
- attr_reader :options
2042
-
2043
- attr_reader :validator
2044
-
2045
- TRUE_STRINGS = %w{on yes y true}
2046
- FALSE_STRINGS = %w{off no n false}
2047
- def initialize(name, type, options, validator)
2048
- @name, @type, @options = name.to_str, type.to_str, options.to_hash
2049
- @validator = validator.to_proc if validator
2050
- if !BuildOption.respond_to?("validate_#{type}")
2051
- raise ConfigError.new, "invalid option type #{type}"
2052
- end
2053
- end
2054
-
2055
- def short_doc
2056
- if short_doc = options[:short_doc]
2057
- short_doc
2058
- elsif doc = options[:doc]
2059
- if doc.respond_to?(:to_ary) then doc.first
2060
- else doc
2061
- end
2062
- else "#{name} (no documentation for this option)"
2063
- end
2064
- end
2065
-
2066
- def doc
2067
- doc = (options[:doc] || "#{name} (no documentation for this option)")
2068
- if doc.respond_to?(:to_ary) # multi-line
2069
- first_line = doc[0]
2070
- remaining = doc[1..-1]
2071
- if remaining.empty?
2072
- first_line
2073
- else
2074
- remaining = remaining.join("\n").split("\n").join("\n ")
2075
- Autoproj.color(first_line, :bold) + "\n " + remaining
2076
- end
2077
- else
2078
- doc
2079
- end
2080
- end
2081
-
2082
- def ask(current_value, doc = nil)
2083
- default_value =
2084
- if !current_value.nil? then current_value.to_s
2085
- elsif options[:default] then options[:default].to_str
2086
- else ''
2087
- end
2088
-
2089
- STDOUT.print " #{doc || self.doc} [#{default_value}] "
2090
- STDOUT.flush
2091
- answer = STDIN.readline.chomp
2092
- if answer == ''
2093
- answer = default_value
2094
- end
2095
- validate(answer)
2096
-
2097
- rescue InputError => e
2098
- Autoproj.message("invalid value: #{e.message}", :red)
2099
- retry
2100
- end
2101
-
2102
- def validate(value)
2103
- value = BuildOption.send("validate_#{type}", value, options)
2104
- if validator
2105
- value = validator[value]
2106
- end
2107
- value
2108
- end
2109
-
2110
- def self.validate_boolean(value, options)
2111
- if TRUE_STRINGS.include?(value.downcase)
2112
- true
2113
- elsif FALSE_STRINGS.include?(value.downcase)
2114
- false
2115
- else
2116
- raise InputError, "invalid boolean value '#{value}', accepted values are '#{TRUE_STRINGS.join(", ")}' for true, and '#{FALSE_STRINGS.join(", ")} for false"
2117
- end
2118
- end
2119
-
2120
- def self.validate_string(value, options)
2121
- if possible_values = options[:possible_values]
2122
- if options[:lowercase]
2123
- value = value.downcase
2124
- elsif options[:uppercase]
2125
- value = value.upcase
2126
- end
2127
-
2128
- if !possible_values.include?(value)
2129
- raise InputError, "invalid value '#{value}', accepted values are '#{possible_values.join("', '")}' (without the quotes)"
2130
- end
2131
- end
2132
- value
2133
- end
2134
- end
2135
-
2136
- @user_config = Hash.new
2137
-
2138
- def self.option_set
2139
- @user_config.inject(Hash.new) do |h, (k, v)|
2140
- h[k] = v.first
2141
- h
2142
- end
2337
+ config.override(option_name, value)
2143
2338
  end
2144
-
2339
+ # @deprecated use config.reset instead
2145
2340
  def self.reset_option(key)
2146
- @user_config.delete(key)
2341
+ config.reset(key)
2147
2342
  end
2148
-
2343
+ # @deprecated use config.set(key, value, user_validated) instead
2149
2344
  def self.change_option(key, value, user_validated = false)
2150
- @user_config[key] = [value, user_validated]
2345
+ config.set(key, value, user_validated)
2151
2346
  end
2152
-
2347
+ # @deprecated use config.validated_values instead
2348
+ def self.option_set
2349
+ config.validated_values
2350
+ end
2351
+ # @deprecated use config.get(key) instead
2153
2352
  def self.user_config(key)
2154
- value, seen = @user_config[key]
2155
- # All non-user options are always considered as "seen"
2156
- seen ||= !@declared_options.has_key?(key)
2157
-
2158
- if value.nil? || (!seen && Autoproj.reconfigure?)
2159
- value = configure(key)
2160
- else
2161
- if !seen
2162
- doc = @declared_options[key].short_doc
2163
- if doc[-1, 1] != "?"
2164
- doc = "#{doc}:"
2165
- end
2166
- Autoproj.message " #{doc} #{value}"
2167
- @user_config[key] = [value, true]
2168
- end
2169
- value
2170
- end
2353
+ config.get(key)
2171
2354
  end
2172
-
2173
- @declared_options = Hash.new
2355
+ # @deprecated use config.declare(name, type, options, &validator) instead
2174
2356
  def self.configuration_option(name, type, options, &validator)
2175
- @declared_options[name] = BuildOption.new(name, type, options, validator)
2357
+ config.declare(name, type, options, &validator)
2176
2358
  end
2177
-
2359
+ # @deprecated use config.declared?(name, type, options, &validator) instead
2178
2360
  def self.declared_option?(name)
2179
- @declared_options.has_key?(name)
2361
+ config.declared?(name)
2180
2362
  end
2181
-
2363
+ # @deprecated use config.configure(option_name) instead
2182
2364
  def self.configure(option_name)
2183
- if opt = @declared_options[option_name]
2184
- if current_value = @user_config[option_name]
2185
- current_value = current_value.first
2186
- end
2187
- value = opt.ask(current_value)
2188
- @user_config[option_name] = [value, true]
2189
- value
2190
- else
2191
- raise ConfigError.new, "undeclared option '#{option_name}'"
2192
- end
2365
+ config.configure(option_name)
2193
2366
  end
2194
-
2195
- def self.save_config
2196
- File.open(File.join(Autoproj.config_dir, "config.yml"), "w") do |io|
2197
- config = Hash.new
2198
- @user_config.each_key do |key|
2199
- config[key] = @user_config[key].first
2200
- end
2201
-
2202
- io.write YAML.dump(config)
2203
- end
2367
+ # @deprecated use config.has_value_for?(name)
2368
+ def self.has_config_key?(name)
2369
+ config.has_value_for?(name)
2204
2370
  end
2205
2371
 
2206
- def self.has_config_key?(name)
2207
- @user_config.has_key?(name)
2372
+ def self.save_config
2373
+ config.save(File.join(Autoproj.config_dir, "config.yml"))
2208
2374
  end
2209
2375
 
2210
2376
  def self.load_config
2377
+ @config ||= Configuration.new
2378
+
2211
2379
  config_file = File.join(Autoproj.config_dir, "config.yml")
2212
2380
  if File.exists?(config_file)
2213
- config = YAML.load(File.read(config_file))
2214
- if !config
2215
- return
2216
- end
2217
-
2218
- config.each do |key, value|
2219
- @user_config[key] = [value, false]
2220
- end
2381
+ config.load(config_file, reconfigure?)
2221
2382
  end
2222
2383
  end
2223
2384
 
@@ -2432,33 +2593,16 @@ module Autoproj
2432
2593
  end
2433
2594
  end
2434
2595
 
2435
- # Load a definition file given at +path+. +source+ is the package set from
2436
- # which the file is taken.
2437
- #
2438
- # If any error is detected, the backtrace will be filtered so that it is
2439
- # easier to understand by the user. Moreover, if +source+ is non-nil, the
2440
- # package set name will be mentionned.
2596
+ # @deprecated use Ops.loader.load or add a proper Loader object to your
2597
+ # class
2441
2598
  def self.load(package_set, *path)
2442
- path = File.join(*path)
2443
- in_package_set(package_set, File.expand_path(path).gsub(/^#{Regexp.quote(Autoproj.root_dir)}\//, '')) do
2444
- begin
2445
- Kernel.load path
2446
- rescue Interrupt
2447
- raise
2448
- rescue ConfigError => e
2449
- raise
2450
- rescue Exception => e
2451
- filter_load_exception(e, package_set, path)
2452
- end
2453
- end
2599
+ Ops.loader.load(package_set, *path)
2454
2600
  end
2455
2601
 
2456
- # Same as #load, but runs only if the file exists.
2602
+ # @deprecated use Ops.loader.load_if_present or add a proper Loader object
2603
+ # to your class
2457
2604
  def self.load_if_present(package_set, *path)
2458
- path = File.join(*path)
2459
- if File.file?(path)
2460
- self.load(package_set, *path)
2461
- end
2605
+ Ops.loader.load_if_present(package_set, *path)
2462
2606
  end
2463
2607
 
2464
2608
  # Look into +dir+, searching for shared libraries. For each library, display