diff --git a/lib/rscons.rb b/lib/rscons.rb index c543e0d..90e4dba 100644 --- a/lib/rscons.rb +++ b/lib/rscons.rb @@ -1,4 +1,5 @@ require "rscons/builder" +require "rscons/cache" require "rscons/environment" require "rscons/version" diff --git a/lib/rscons/cache.rb b/lib/rscons/cache.rb new file mode 100644 index 0000000..65ea184 --- /dev/null +++ b/lib/rscons/cache.rb @@ -0,0 +1,41 @@ +require 'yaml' +require 'fileutils' +require 'digest/md5' + +module Rscons + class Cache + # Constants + CACHE_FILE = '.rsconscache' + + # Class Methods + def self.clear + FileUtils.rm_f(CACHE_FILE) + end + + # Instance Methods + def initialize + @cache = YAML.load(File.read(CACHE_FILE)) rescue {} + end + + def write + File.open(CACHE_FILE, 'w') do |fh| + fh.puts(YAML.dump(@cache)) + end + end + + def up_to_date?(file, deps = nil) + # TODO + end + + def register_build(target, deps) + # TODO + end + + # Private Instance Methods + private + + def calculate_checksum(file) + Digest::MD5.hexdigest(File.read(file)).encode(__ENCODING__) + end + end +end diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 750b13d..5098d6e 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -57,6 +57,8 @@ module Rscons end def process + cache = Cache.new + cache.write end alias_method :orig_method_missing, :method_missing