save configured environment construction flags for separate build step - close #60
This commit is contained in:
parent
ba3d656110
commit
add9f9c50d
@ -134,6 +134,10 @@ module Rscons
|
|||||||
rv = 1
|
rv = 1
|
||||||
end
|
end
|
||||||
co.close
|
co.close
|
||||||
|
cache = Cache.instance
|
||||||
|
cache.set_configured(rv == 0)
|
||||||
|
cache.set_default_environment_vars(@default_environment.to_h)
|
||||||
|
cache.write
|
||||||
rv
|
rv
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,6 +85,45 @@ module Rscons
|
|||||||
@lookup_checksums = {}
|
@lookup_checksums = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return whether the project has been configured.
|
||||||
|
#
|
||||||
|
# @return [Boolean]
|
||||||
|
# Whether the project has been configured.
|
||||||
|
def configured?
|
||||||
|
@cache["configured"]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Set whether the project has been configured.
|
||||||
|
#
|
||||||
|
# @param configured [Boolean]
|
||||||
|
# Whether the project has been configured.
|
||||||
|
#
|
||||||
|
# @return [void]
|
||||||
|
def set_configured(configured)
|
||||||
|
@cache["configured"] = configured
|
||||||
|
@dirty = true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get the default environment construction variables.
|
||||||
|
#
|
||||||
|
# @return [Hash]
|
||||||
|
# Default environment construction variables.
|
||||||
|
def get_default_environment_vars
|
||||||
|
@cache["default_environment_vars"]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Set the default environment construction variables.
|
||||||
|
#
|
||||||
|
# @param vars [Hash]
|
||||||
|
# Default environment construction variables.
|
||||||
|
#
|
||||||
|
# @return [void]
|
||||||
|
def set_default_environment_vars(vars)
|
||||||
|
validate_json_object(vars)
|
||||||
|
@cache["default_environment_vars"] = vars
|
||||||
|
@dirty = true
|
||||||
|
end
|
||||||
|
|
||||||
# Write the cache to disk to be loaded next time.
|
# Write the cache to disk to be loaded next time.
|
||||||
#
|
#
|
||||||
# @return [void]
|
# @return [void]
|
||||||
@ -314,6 +353,7 @@ module Rscons
|
|||||||
end
|
end
|
||||||
@cache["targets"] ||= {}
|
@cache["targets"] ||= {}
|
||||||
@cache["directories"] ||= {}
|
@cache["directories"] ||= {}
|
||||||
|
@cache["default_environment_vars"] ||= {}
|
||||||
@lookup_checksums = {}
|
@lookup_checksums = {}
|
||||||
@dirty = false
|
@dirty = false
|
||||||
end
|
end
|
||||||
@ -336,5 +376,21 @@ module Rscons
|
|||||||
def calculate_checksum(file)
|
def calculate_checksum(file)
|
||||||
@lookup_checksums[file] = Digest::MD5.hexdigest(File.read(file, mode: "rb")) rescue ""
|
@lookup_checksums[file] = Digest::MD5.hexdigest(File.read(file, mode: "rb")) rescue ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Validate that an object is one of a known set of values that can be
|
||||||
|
# serialized properly with JSON.
|
||||||
|
#
|
||||||
|
# @param o [Object]
|
||||||
|
# Object to validate.
|
||||||
|
def validate_json_object(o)
|
||||||
|
if o.is_a?(Array)
|
||||||
|
o.each {|v| validate_json_object(v)}
|
||||||
|
elsif o.is_a?(Hash)
|
||||||
|
o.each {|*kv| validate_json_object(kv)}
|
||||||
|
elsif [NilClass, TrueClass, FalseClass, String].none? {|c| o.is_a?(c)}
|
||||||
|
raise "Unexpected cache value for serialization: #{o.inspect}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -278,14 +278,26 @@ module Rscons
|
|||||||
#
|
#
|
||||||
# @see VarSet#[]
|
# @see VarSet#[]
|
||||||
def [](*args)
|
def [](*args)
|
||||||
@varset.send(:[], *args)
|
@varset.__send__(:[], *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set a construction variable's value.
|
# Set a construction variable's value.
|
||||||
#
|
#
|
||||||
# @see VarSet#[]=
|
# @see VarSet#[]=
|
||||||
def []=(*args)
|
def []=(*args)
|
||||||
@varset.send(:[]=, *args)
|
@varset.__send__(:[]=, *args)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Return the Environment construction variables as a Hash.
|
||||||
|
#
|
||||||
|
# @since 2.0.0
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
# @return [Hash]
|
||||||
|
# Environment construction variables.
|
||||||
|
def to_h
|
||||||
|
@varset.to_h
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a set of construction variables to the Environment.
|
# Add a set of construction variables to the Environment.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user