]> git.mdlowis.com Git - archive/build-system.git/commitdiff
Added first version of build scripts
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 23 Sep 2014 17:53:59 +0000 (13:53 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 23 Sep 2014 17:53:59 +0000 (13:53 -0400)
setup.rb [new file with mode: 0644]
toolsets.rb [new file with mode: 0644]

diff --git a/setup.rb b/setup.rb
new file mode 100644 (file)
index 0000000..5513d27
--- /dev/null
+++ b/setup.rb
@@ -0,0 +1,52 @@
+#------------------------------------------------------------------------------
+# Check Bundle Dependencies
+#------------------------------------------------------------------------------
+require 'bundler'
+begin
+  Bundler.setup(:default, :development)
+rescue Bundler::BundlerError => e
+  raise LoadError.new("Unable to Bundler.setup(): Please run 'bundle install': #{e.message}")
+end
+require 'rake'
+require 'rscons'
+require_relative 'toolsets'
+
+#------------------------------------------------------------------------------
+# Environment Manager
+#------------------------------------------------------------------------------
+module BuildEnvManager
+  @@environments = []
+
+  def self.register(env)
+    @@environments << env
+  end
+
+  def self.process()
+    @@environments.each {|env| env.process }
+  end
+end
+
+#------------------------------------------------------------------------------
+# Environment Class
+#------------------------------------------------------------------------------
+class BuildEnv < Rscons::Environment
+  attr_reader :toolset
+
+  def initialize(options = {})
+    super(options)
+    BuildEnvManager.register(self)
+  end
+
+  def set_toolset(name, options = {})
+    if Toolsets.respond_to?(name)
+      Toolsets.send(name, self, options)
+      @toolset = name
+    else
+      raise "No toolset found for selection '#{name}'"
+    end
+  end
+end
+
+# Make sure we process any environments before rake exits
+at_exit { BuildEnvManager.process }
+
diff --git a/toolsets.rb b/toolsets.rb
new file mode 100644 (file)
index 0000000..a798008
--- /dev/null
@@ -0,0 +1,12 @@
+module Toolsets
+  class << self
+    @@location = File.dirname(__FILE__) + '/toolsets'
+    Dir["#{@@location}/*.rb"].each do |fname|
+      name = File.basename(fname).gsub(/\.rb$/,'')
+      define_method(name) do |env, options = {}|
+        require_relative "toolsets/#{name}"
+        self.send(name, env, options)
+      end
+    end
+  end
+end