store configuration data more opaquely in Cache

This commit is contained in:
Josh Holtrop 2018-11-23 20:15:39 -05:00
parent cfec0dcadc
commit 6dd9c835ce
2 changed files with 21 additions and 18 deletions

View File

@ -82,6 +82,8 @@ module Rscons
# #
# @return [void] # @return [void]
def configure def configure
cache = Cache.instance
cache.configuration_data = {}
if project_name = @script.project_name if project_name = @script.project_name
Ansi.write($stdout, "Configuring ", :cyan, project_name, :reset, "...\n") Ansi.write($stdout, "Configuring ", :cyan, project_name, :reset, "...\n")
else else
@ -96,10 +98,8 @@ module Rscons
rv = 1 rv = 1
end end
co.close co.close
cache = Cache.instance
cache.set_configured(rv == 0) cache.set_configured(rv == 0)
cache.set_default_environment_vars(@default_environment.to_h) cache.write!
cache.write
rv rv
end end

View File

@ -104,27 +104,21 @@ module Rscons
@dirty = true @dirty = true
end end
# Get the default environment construction variables. # Access configuration data.
# def configuration_data
# @return [Hash] @cache["configuration_data"]
# Default environment construction variables.
def get_default_environment_vars
@cache["default_environment_vars"]
end end
# Set the default environment construction variables. # Set configuration data.
# #
# @param vars [Hash] # @param value [Hash]
# Default environment construction variables. # Configuration data.
# def configuration_data=(value)
# @return [void] @cache["configuration_data"] = value
def set_default_environment_vars(vars)
validate_json_object(vars)
@cache["default_environment_vars"] = vars
@dirty = true @dirty = true
end end
# Write the cache to disk to be loaded next time. # Write the cache to disk if it is dirty.
# #
# @return [void] # @return [void]
def write def write
@ -137,6 +131,14 @@ module Rscons
@dirty = false @dirty = false
end end
# Force a write of the cache to disk.
#
# @return [void]
def write!
@dirty = true
write
end
# Check if target(s) are up to date. # Check if target(s) are up to date.
# #
# @param targets [Symbol, String, Array<String>] # @param targets [Symbol, String, Array<String>]
@ -354,6 +356,7 @@ module Rscons
@cache["targets"] ||= {} @cache["targets"] ||= {}
@cache["directories"] ||= {} @cache["directories"] ||= {}
@cache["default_environment_vars"] ||= {} @cache["default_environment_vars"] ||= {}
@cache["configuration_data"] ||= {}
@lookup_checksums = {} @lookup_checksums = {}
@dirty = false @dirty = false
end end