provide Environment construction option to use stored configuration settings - close #78
This commit is contained in:
1 parent
fa5aa51daa
commit
eaac473f44
6 files changed
+79
-6
No files matched your search
@@ -3,8 +3,14 @@ module Rscons
|
||||
class BasicEnvironment
|
||||
|
||||
# Create a BasicEnvironment object.
|
||||
def initialize
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# @param options [Hash]
|
||||
# Construction options.
|
||||
def initialize(options = {})
|
||||
@varset = VarSet.new(Rscons.application.default_varset)
|
||||
load_configuration_data!(options)
|
||||
end
|
||||
|
||||
# Get a construction variable's value.
|
||||
@@ -185,15 +191,24 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
# Load construction variables saved from the configure operation.
|
||||
def load_configuration_data!
|
||||
# Load all construction variables saved from the configure operation.
|
||||
def load_configuration_data!(options)
|
||||
if vars = Cache.instance.configuration_data["vars"]
|
||||
if default_vars = vars["_default_"]
|
||||
apply_configuration_data!(default_vars)
|
||||
end
|
||||
if options[:use]
|
||||
Array(options[:use]).each do |use|
|
||||
if use_vars = vars[use]
|
||||
apply_configuration_data!(use_vars)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Load a specific set of construction variables saved from the configure
|
||||
# operation.
|
||||
def apply_configuration_data!(vars)
|
||||
if merge_vars = vars["merge"]
|
||||
append(merge_vars)
|
||||
|
||||
@@ -360,7 +360,12 @@ module Rscons
|
||||
# @return [Hash]
|
||||
# Configuration Hash for storing vars.
|
||||
def store_common(options)
|
||||
usename = options[:use] || "_default_"
|
||||
usename =
|
||||
if options[:use]
|
||||
options[:use].to_s
|
||||
else
|
||||
"_default_"
|
||||
end
|
||||
cache = Cache.instance
|
||||
cache.configuration_data["vars"] ||= {}
|
||||
cache.configuration_data["vars"][usename] ||= {}
|
||||
|
||||
@@ -64,7 +64,7 @@ module Rscons
|
||||
# If a block is given, the Environment object is yielded to the block and
|
||||
# when the block returns, the {#process} method is automatically called.
|
||||
def initialize(options = {})
|
||||
super()
|
||||
super(options)
|
||||
@id = self.class.get_id
|
||||
self.class.register(self)
|
||||
@threaded_commands = Set.new
|
||||
@@ -83,7 +83,6 @@ module Rscons
|
||||
end
|
||||
@echo = options[:echo] || :short
|
||||
@build_root = "#{Cache.instance.configuration_data["build_dir"]}/e.#{@id}"
|
||||
load_configuration_data!
|
||||
|
||||
if block_given?
|
||||
yield self
|
||||
|
||||
Reference in new issue
Block a user