autoproj 1.7.0.b1 → 1.7.0.b2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ begin
14
14
  self.changes = paragraphs_of('History.txt', 0..1).join("\n\n")
15
15
 
16
16
  extra_deps <<
17
- ['autobuild', '>= 1.5.24'] <<
17
+ ['autobuild', '>= 1.5.25'] <<
18
18
  ['rmail', '>= 1.0.0'] <<
19
19
  ['utilrb', '>= 1.3.3'] <<
20
20
  ['nokogiri', '>= 1.3.3'] <<
@@ -1,12 +1,5 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
- if !ARGV.grep("--env").empty?
4
- require 'autoproj/system'
5
- puts File.join(Autoproj.root_dir, "env.sh")
6
- exit
7
- end
8
-
9
-
10
3
  if RUBY_VERSION < "1.8.7"
11
4
  STDERR.puts "autoproj requires Ruby >= 1.8.7"
12
5
  exit 1
@@ -6,6 +6,7 @@ require 'autoproj/manifest'
6
6
  require 'autoproj/osdeps'
7
7
  require 'autoproj/system'
8
8
  require 'autoproj/options'
9
+ require 'autoproj/cmdline'
9
10
  require 'logger'
10
11
  require 'utilrb/logger'
11
12
 
@@ -468,6 +468,12 @@ def package(name)
468
468
  Autobuild::Package[name]
469
469
  end
470
470
 
471
+ # Returns true if +name+ is a valid package and is neither excluded nor ignored
472
+ # from the build
473
+ def package_selected?(name)
474
+ Autoproj.manifest.package_selected?(name, false)
475
+ end
476
+
471
477
  # Returns true if +name+ is a valid package and is included in the build
472
478
  def package_enabled?(name)
473
479
  Autoproj.manifest.package_enabled?(name, false)
@@ -479,3 +485,7 @@ def disable_imports_from(name)
479
485
  Autoproj.manifest.disable_imports_from(name)
480
486
  end
481
487
 
488
+ # Moves the given package to a new subdirectory
489
+ def move_package(name, new_dir)
490
+ Autoproj.manifest.move_package(name, new_dir)
491
+ end
@@ -219,28 +219,28 @@ module Autoproj
219
219
  #
220
220
  # First, we allow to user to specify packages based on disk paths, so
221
221
  # resolve those
222
- seen = Set.new
223
- manifest.each_layout_level do |name, packages, enabled_packages|
224
- packages -= seen
225
-
226
- packages.each do |pkg_name|
227
- place =
228
- if randomize_layout?
229
- Digest::SHA256.hexdigest(pkg_name)[0, 12]
230
- else name
231
- end
222
+ manifest.packages.each_value do |pkg_def|
223
+ pkg = pkg_def.autobuild
224
+ pkg_name = pkg.name
225
+
226
+ layout =
227
+ if randomize_layout?
228
+ Digest::SHA256.hexdigest(pkg_name)[0, 12]
229
+ else manifest.whereis(pkg_name)
230
+ end
232
231
 
233
- srcdir = File.join(Autoproj.root_dir, place)
234
- prefix = File.join(Autoproj.build_dir, place)
235
- logdir = File.join(prefix, "log")
232
+ place =
233
+ if target = manifest.moved_packages[pkg_name]
234
+ File.join(layout, target)
235
+ else
236
+ File.join(layout, pkg_name)
237
+ end
236
238
 
237
- pkg = Autobuild::Package[pkg_name]
238
- pkg.srcdir = File.join(srcdir, pkg_name)
239
- pkg.prefix = prefix
240
- pkg.doc_target_dir = File.join(Autoproj.build_dir, 'doc', name, pkg_name)
241
- pkg.logdir = logdir
242
- end
243
- seen |= packages
239
+ pkg = Autobuild::Package[pkg_name]
240
+ pkg.srcdir = File.join(Autoproj.root_dir, place)
241
+ pkg.prefix = File.join(Autoproj.build_dir, layout)
242
+ pkg.doc_target_dir = File.join(Autoproj.build_dir, 'doc', name, pkg_name)
243
+ pkg.logdir = File.join(pkg.prefix, "log")
244
244
  end
245
245
 
246
246
  # Now call the blocks that the user defined in the autobuild files. We do it
@@ -268,20 +268,24 @@ module Autoproj
268
268
 
269
269
 
270
270
  def self.display_configuration(manifest, package_list = nil)
271
- # We can't have the Manifest class load the source.yml file, as it
272
- # cannot resolve all constants. So we need to do it ourselves to get
273
- # the name ...
274
- sets = manifest.each_package_set(false).to_a
275
-
276
- if sets.empty?
277
- Autoproj.progress("autoproj: no package sets defined in autoproj/manifest", :bold, :red)
278
- return
271
+ # Load the manifest for packages that are already present on the
272
+ # file system
273
+ manifest.packages.each_value do |pkg|
274
+ if File.directory?(pkg.autobuild.srcdir)
275
+ manifest.load_package_manifest(pkg.autobuild.name)
276
+ end
279
277
  end
280
278
 
281
279
  all_packages = Hash.new
282
280
  if package_list
283
- package_sets = Set.new
281
+ all_selected_packages = Set.new
284
282
  package_list.each do |name|
283
+ all_selected_packages << name
284
+ Autobuild::Package[name].all_dependencies(all_selected_packages)
285
+ end
286
+
287
+ package_sets = Set.new
288
+ all_selected_packages.each do |name|
285
289
  pkg_set = manifest.definition_source(name)
286
290
  package_sets << pkg_set
287
291
  all_packages[name] = [manifest.package(name).autobuild, pkg_set.name]
@@ -295,6 +299,11 @@ module Autoproj
295
299
  end
296
300
  end
297
301
 
302
+ if package_sets.empty?
303
+ Autoproj.progress("autoproj: no package sets defined in autoproj/manifest", :bold, :red)
304
+ return
305
+ end
306
+
298
307
  Autoproj.progress
299
308
  Autoproj.progress("autoproj: package sets", :bold)
300
309
  package_sets.each do |pkg_set|
@@ -338,6 +347,11 @@ module Autoproj
338
347
  vcs_def = manifest.importer_definition_for(pkg.name)
339
348
  Autoproj.progress "#{pkg.name}#{": #{pkg_manifest.short_documentation}" if pkg_manifest && pkg_manifest.short_documentation}", :bold
340
349
  Autoproj.progress " defined in #{pkg_set}"
350
+ if File.directory?(pkg.srcdir)
351
+ Autoproj.progress " checked out in #{pkg.srcdir}"
352
+ else
353
+ Autoproj.progress " will be checked out in #{pkg.srcdir}"
354
+ end
341
355
  Autoproj.progress " #{vcs_def.to_s}"
342
356
 
343
357
  if !File.directory?(pkg.srcdir)
@@ -463,7 +477,13 @@ module Autoproj
463
477
  raise ConfigError.new, "#{pkg.name} has no VCS, but is not checked out in #{pkg.srcdir}"
464
478
  end
465
479
 
466
- Rake::Task["#{pkg.name}-import"].invoke
480
+ ## COMPLETELY BYPASS RAKE HERE
481
+ # The reason is that the ordering of import/prepare between
482
+ # packages is not important BUT the ordering of import vs.
483
+ # prepare in one package IS important: prepare is the method
484
+ # that takes into account dependencies.
485
+ pkg.import
486
+ Rake::Task["#{pkg.name}-import"].instance_variable_set(:@already_invoked, true)
467
487
  manifest.load_package_manifest(pkg.name)
468
488
  pkg.resolve_optional_dependencies
469
489
  verify_package_availability(pkg.name)
@@ -471,7 +491,8 @@ module Autoproj
471
491
 
472
492
  current_packages.each do |pkg|
473
493
  verify_package_availability(pkg.name)
474
- Rake::Task["#{pkg.name}-prepare"].invoke
494
+ pkg.prepare
495
+ Rake::Task["#{pkg.name}-prepare"].instance_variable_set(:@already_invoked, true)
475
496
 
476
497
  # Verify that its dependencies are there, and add
477
498
  # them to the selected_packages set so that they get
@@ -1430,6 +1451,33 @@ export PATH=$GEM_HOME/bin:$PATH
1430
1451
  end
1431
1452
  end
1432
1453
  end
1454
+
1455
+ # This method sets up autoproj and loads the configuration available in
1456
+ # the current autoproj installation. It is meant as a simple way to
1457
+ # initialize an autoproj environment for standalone tools
1458
+ #
1459
+ # Beware, it changes the current directory to the autoproj root dir
1460
+ def self.initialize_and_load
1461
+ require 'autoproj/autobuild'
1462
+ require 'open-uri'
1463
+ require 'autoproj/cmdline'
1464
+
1465
+ Autoproj::CmdLine.parse_arguments(ARGV.dup, false)
1466
+ Dir.chdir(Autoproj.root_dir)
1467
+
1468
+ Autoproj::CmdLine.update_os_dependencies = false
1469
+ Autoproj::CmdLine.initialize
1470
+ Autoproj::CmdLine.load_configuration
1471
+ Autoproj::CmdLine.initial_package_setup
1472
+
1473
+ # Load the manifest for packages that are already present on the
1474
+ # file system
1475
+ manifest.packages.each_value do |pkg|
1476
+ if File.directory?(pkg.autobuild.srcdir)
1477
+ manifest.load_package_manifest(pkg.autobuild.name)
1478
+ end
1479
+ end
1480
+ end
1433
1481
  end
1434
1482
  end
1435
1483
 
@@ -495,10 +495,6 @@ module Autoproj
495
495
  #
496
496
  # The returned value is a VCSDefinition object.
497
497
  def version_control_field(package_name, section_name, validate = true)
498
- if !source_definition
499
- raise InternalError, "source #{name} has not been loaded"
500
- end
501
-
502
498
  urls = source_definition['urls'] || Hash.new
503
499
  urls['HOME'] = ENV['HOME']
504
500
 
@@ -779,6 +775,7 @@ module Autoproj
779
775
  @automatic_exclusions = Hash.new
780
776
  @constants_definitions = Hash.new
781
777
  @disabled_imports = Set.new
778
+ @moved_packages = Hash.new
782
779
 
783
780
  @constant_definitions = Hash.new
784
781
  if Autoproj.has_config_key?('manifest_source')
@@ -1055,9 +1052,6 @@ module Autoproj
1055
1052
  # internal name used to represent the package and +into+ the directory
1056
1053
  # in which the package should be checked out.
1057
1054
  def self.create_autobuild_package(vcs, text_name, into)
1058
- if !into
1059
- raise
1060
- end
1061
1055
  importer = vcs.create_autobuild_importer
1062
1056
  return if !importer # updates have been disabled by using the 'none' type
1063
1057
 
@@ -1071,9 +1065,6 @@ module Autoproj
1071
1065
  #
1072
1066
  # See create_autobuild_package for informations about the arguments.
1073
1067
  def self.update_package_set(vcs, text_name, into)
1074
- if !into
1075
- raise
1076
- end
1077
1068
  fake_package = create_autobuild_package(vcs, text_name, into)
1078
1069
  fake_package.import
1079
1070
 
@@ -1255,12 +1246,16 @@ module Autoproj
1255
1246
  #
1256
1247
  # If recursive is false, yields only the packages at this level.
1257
1248
  # Otherwise, return all packages.
1258
- def layout_packages(layout_def, recursive, validate = true)
1259
- result = []
1249
+ def layout_packages(result, layout_def, recursive, validate = true)
1260
1250
  layout_def.each do |value|
1261
1251
  if !value.kind_of?(Hash) # sublayout
1262
1252
  begin
1263
- result.concat(resolve_package_set(value))
1253
+ pkgs = resolve_package_set(value)
1254
+ pkgs.each do |p|
1255
+ result << p
1256
+ Autobuild::Package[p].all_dependencies(result)
1257
+ end
1258
+
1264
1259
  rescue ConfigError
1265
1260
  raise if validate
1266
1261
  end
@@ -1269,7 +1264,7 @@ module Autoproj
1269
1264
 
1270
1265
  if recursive
1271
1266
  each_sublayout(layout_def) do |sublayout_name, sublayout_def|
1272
- result.concat(layout_packages(sublayout_def, true))
1267
+ layout_packages(result, sublayout_def, true)
1273
1268
  end
1274
1269
  end
1275
1270
 
@@ -1286,36 +1281,6 @@ module Autoproj
1286
1281
  end
1287
1282
  end
1288
1283
 
1289
- # Looks into the layout setup in the manifest, and yields each layout
1290
- # and sublayout in order
1291
- def each_layout_level(selection = nil, layout_name = '/', layout_def = data['layout'], &block)
1292
- if !layout_def
1293
- yield(layout_name, default_packages, default_packages)
1294
- return nil
1295
- end
1296
-
1297
- selection = selection.to_set if selection
1298
-
1299
- # First of all, do the packages at this level
1300
- packages = layout_packages(layout_def, false)
1301
- # Remove excluded packages
1302
- packages.delete_if { |pkg_name| excluded?(pkg_name) }
1303
-
1304
- if selection
1305
- selected_packages = packages.find_all { |pkg_name| selection.include?(pkg_name) }
1306
- else
1307
- selected_packages = packages.dup
1308
- end
1309
- if !packages.empty?
1310
- yield(layout_name, packages.to_set, selected_packages.to_set)
1311
- end
1312
-
1313
- # Now, enumerate the sublayouts
1314
- each_sublayout(layout_def) do |subname, sublayout|
1315
- each_layout_level(selection, "#{layout_name}#{subname}/", sublayout, &block)
1316
- end
1317
- end
1318
-
1319
1284
  # Returns the set of package names that are explicitely listed in the
1320
1285
  # layout, minus the excluded and ignored ones
1321
1286
  def all_layout_packages(validate = true)
@@ -1336,12 +1301,11 @@ module Autoproj
1336
1301
 
1337
1302
  # Returns true if +name+ is a valid package and is included in the build
1338
1303
  #
1339
- # If +validate+ is true, the layout will have to be well-defined. It can
1340
- # therefore be used only after all sources have been successfully
1341
- # loaded.
1304
+ # If +validate+ is true, the method will raise ArgumentError if the
1305
+ # package does not exists.
1342
1306
  #
1343
- # If it is false, non-defined packages/package sets in the layout will
1344
- # simply be ignored
1307
+ # If it is false, the method will simply return false on non-defined
1308
+ # packages
1345
1309
  def package_enabled?(name, validate = true)
1346
1310
  if !Autobuild::Package[name]
1347
1311
  if validate
@@ -1353,11 +1317,25 @@ module Autoproj
1353
1317
  !excluded?(name)
1354
1318
  end
1355
1319
 
1320
+ # Returns true if +name+ is a valid package and is neither excluded from
1321
+ # the build, nor ignored from the build
1322
+ #
1323
+ # If +validate+ is true, the method will raise ArgumentError if the
1324
+ # package does not exists.
1325
+ #
1326
+ # If it is false, the method will simply return false on non-defined
1327
+ # packages
1328
+ def package_selected?(name, validate = true)
1329
+ if package_enabled?(name)
1330
+ !ignored?(name)
1331
+ end
1332
+ end
1333
+
1356
1334
  # Returns the set of packages that should be built if the user does not
1357
1335
  # specify any on the command line
1358
1336
  def default_packages(validate = true)
1359
1337
  names = if layout = data['layout']
1360
- layout_packages(layout, true, validate)
1338
+ layout_packages(Set.new, layout, true, validate)
1361
1339
  else
1362
1340
  # No layout, all packages are selected
1363
1341
  all_packages
@@ -1367,15 +1345,27 @@ module Autoproj
1367
1345
  names.to_set
1368
1346
  end
1369
1347
 
1348
+ def search_layout(layout_level, layout_data, *names)
1349
+ layout_data.each do |value|
1350
+ if value.kind_of?(Hash)
1351
+ each_sublayout(value) do |subname, subdef|
1352
+ if result = search_layout("#{layout_level}/#{subname}", subdef)
1353
+ return result
1354
+ end
1355
+ end
1356
+
1357
+ elsif names.include?(value)
1358
+ return layout_level
1359
+ end
1360
+ end
1361
+ nil
1362
+ end
1363
+
1370
1364
  # Returns the package directory for the given package name
1371
1365
  def whereis(package_name)
1372
1366
  Autoproj.in_file(self.file) do
1373
- each_layout_level do |layout_name, packages, _|
1374
- if packages.include?(package_name)
1375
- return layout_name
1376
- end
1377
- end
1378
- raise ArgumentError, "cannot find #{package_name} in the layout section"
1367
+ set_name = definition_source(package_name).name
1368
+ return (search_layout("/", (data['layout'] || Hash.new), package_name, set_name) || "/")
1379
1369
  end
1380
1370
  end
1381
1371
 
@@ -1501,23 +1491,13 @@ module Autoproj
1501
1491
  !packages.empty? || !sources.empty?
1502
1492
  end
1503
1493
 
1504
- # Now, search for layout names
1505
- each_layout_level(nil) do |layout_name, packages, _|
1506
- selected_packages.each do |sel|
1507
- if layout_name[0..-1] =~ Regexp.new("#{sel}\/?$")
1508
- expanded_packages |= packages.to_set
1509
- end
1510
- end
1511
- end
1512
-
1513
1494
  # Finally, check for package source directories
1514
1495
  all_packages = self.all_package_names
1515
1496
  selected_packages.each do |sel|
1516
- match_dir = Regexp.new("^#{Regexp.quote(sel)}")
1517
1497
  match_pkg_name = Regexp.new(Regexp.quote(sel))
1518
1498
  all_packages.each do |pkg_name|
1519
1499
  pkg = Autobuild::Package[pkg_name]
1520
- if pkg_name =~ match_pkg_name || pkg.srcdir =~ match_dir
1500
+ if pkg_name =~ match_pkg_name || sel =~ Regexp.new("^#{Regexp.quote(pkg.srcdir)}") || pkg.srcdir =~ Regexp.new("^#{Regexp.quote(sel)}")
1521
1501
  # Check-out packages that are not in the manifest only
1522
1502
  # if they are explicitely selected
1523
1503
  if pkg_name != sel && pkg.srcdir != sel && !all_layout_packages.include?(pkg.name)
@@ -1533,6 +1513,20 @@ module Autoproj
1533
1513
  expanded_packages.delete_if { |pkg_name| excluded?(pkg_name) || ignored?(pkg_name) }
1534
1514
  expanded_packages.to_set
1535
1515
  end
1516
+
1517
+ attr_reader :moved_packages
1518
+
1519
+ # Moves the given package name from its current subdirectory to the
1520
+ # provided one.
1521
+ #
1522
+ # For instance, for a package called drivers/xsens_imu
1523
+ #
1524
+ # move("drivers/xsens_imu", "data_acquisition")
1525
+ #
1526
+ # will move the package into data_acquisition/xsens_imu
1527
+ def move_package(package_name, new_dir)
1528
+ moved_packages[package_name] = File.join(new_dir, File.basename(package_name))
1529
+ end
1536
1530
  end
1537
1531
 
1538
1532
  class << self
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "1.7.0.b1"
2
+ VERSION = "1.7.0.b2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoproj
3
3
  version: !ruby/object:Gem::Version
4
- hash: 6629751
4
+ hash: 6629748
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 7
9
9
  - 0
10
- - b1
11
- version: 1.7.0.b1
10
+ - b2
11
+ version: 1.7.0.b2
12
12
  platform: ruby
13
13
  authors:
14
14
  - Sylvain Joyeux
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-18 00:00:00 +01:00
19
+ date: 2010-11-24 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- hash: 51
30
+ hash: 49
31
31
  segments:
32
32
  - 1
33
33
  - 5
34
- - 24
35
- version: 1.5.24
34
+ - 25
35
+ version: 1.5.25
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency