lib/autoproj/autobuild.rb in autoproj-1.7.11 vs lib/autoproj/autobuild.rb in autoproj-1.7.12.rc1
- old
+ new
@@ -236,65 +236,63 @@
end
end
# Returns the information about the file that is currently being loaded
#
- # The return value is [source, path], where +source+ is the Source instance
- # and +path+ is the path of the file w.r.t. the autoproj root directory
+ # The return value is [package_set, path], where +package_set+ is the
+ # PackageSet instance and +path+ is the path of the file w.r.t. the autoproj
+ # root directory
def self.current_file
@file_stack.last
end
+ # The PackageSet object representing the package set that is currently being
+ # loaded
+ def self.current_package_set
+ current_file.first
+ end
+
def self.define(package_type, spec, &block)
package = Autobuild.send(package_type, spec)
Autoproj.manifest.register_package(package, block, *current_file)
package
end
@loaded_autobuild_files = Set.new
- def self.filter_load_exception(error, source, path)
+ def self.filter_load_exception(error, package_set, path)
raise error if Autoproj.verbose
rx_path = Regexp.quote(path)
if error_line = error.backtrace.find { |l| l =~ /#{rx_path}/ }
if line_number = Integer(/#{rx_path}:(\d+)/.match(error_line)[1])
line_number = "#{line_number}:"
end
- if source.local?
+ if package_set.local?
raise ConfigError.new(path), "#{path}:#{line_number} #{error.message}", error.backtrace
else
- raise ConfigError.new(path), "#{File.basename(path)}(source=#{source.name}):#{line_number} #{error.message}", error.backtrace
+ raise ConfigError.new(path), "#{File.basename(path)}(package_set=#{package_set.name}):#{line_number} #{error.message}", error.backtrace
end
else
raise error
end
end
- def self.in_package_set(source, path)
- @file_stack.push([source, File.expand_path(path).gsub(/^#{Regexp.quote(Autoproj.root_dir)}\//, '')])
+ def self.in_package_set(package_set, path)
+ @file_stack.push([package_set, File.expand_path(path).gsub(/^#{Regexp.quote(Autoproj.root_dir)}\//, '')])
yield
ensure
@file_stack.pop
end
class << self
attr_reader :loaded_autobuild_files
end
- def self.import_autobuild_file(source, path)
+ def self.import_autobuild_file(package_set, path)
return if @loaded_autobuild_files.include?(path)
-
- in_package_set(source, File.expand_path(path).gsub(/^#{Regexp.quote(Autoproj.root_dir)}\//, '')) do
- begin
- Kernel.load path
- rescue ConfigError => e
- raise
- rescue Exception => e
- filter_load_exception(e, source, path)
- end
- @loaded_autobuild_files << path
- end
+ Autoproj.load(package_set, path)
+ @loaded_autobuild_files << path
end
# Tries to find a handler automatically for 'full_path'
def self.package_handler_for(full_path)
if !Dir.enum_for(:glob, File.join(full_path, "*.orogen")).to_a.empty?
@@ -655,5 +653,30 @@
# Moves the given package to a new subdirectory
def move_package(name, new_dir)
Autoproj.manifest.move_package(name, new_dir)
end
+
+# Removes all the packages currently added from the given metapackage
+#
+# Calling this function will make sure that the given metapackage is now empty.
+def clear_metapackage(name)
+ meta = Autoproj.manifest.metapackage(name)
+ meta.packages.clear
+end
+
+# Declares a new metapackage, or adds packages to an existing one
+def metapackage(name, *packages)
+ Autoproj.manifest.metapackage(name, *packages)
+end
+
+# This can be used only during the load of a package set
+#
+# It defines the set of packages that will be built if 'package_set_name' is
+# used. By default, all of the package set's packages are included. After a call
+# to default_packages, only the packages listed (and their dependencies) are.
+def default_packages(*names)
+ pkg_set = Autoproj.current_package_set
+ clear_metapackage(pkg_set.name)
+ metapackage(pkg_set.name, *names)
+end
+