]> git.mdlowis.com Git - archive/build-system.git/commitdiff
Added toolset definitions and dependency resolution code
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 23 Sep 2014 18:35:51 +0000 (14:35 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 23 Sep 2014 18:35:51 +0000 (14:35 -0400)
setup.rb
toolsets/clang.rb [new file with mode: 0755]
toolsets/default.rb [new file with mode: 0755]
toolsets/gcc.rb [new file with mode: 0755]

index 5513d277648fbaa68cdd768e6e54ffe30ff780a8..a705f7b21d74e4569bd8b3a60158ecf34395205f 100644 (file)
--- a/setup.rb
+++ b/setup.rb
@@ -1,14 +1,26 @@
 #------------------------------------------------------------------------------
-# Check Bundle Dependencies
+# Setup and Check Bundle Dependencies
 #------------------------------------------------------------------------------
+DefaultDeps = [
+  ['rake',   '>= 0'],
+  ['rscons', '>= 0']
+]
+
+# Generate a default Gemfile if none exists
+if not File.exists? "Gemfile"
+  File.open("Gemfile","w") do |f|
+    DefaultDeps.each {|d| f.puts("gem '#{d[0]}', '#{d[1]}'") }
+  end
+end
+
+# Check that we have the right 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'
+DefaultDeps.each {|d| require d[0] }
 require_relative 'toolsets'
 
 #------------------------------------------------------------------------------
diff --git a/toolsets/clang.rb b/toolsets/clang.rb
new file mode 100755 (executable)
index 0000000..f5d5190
--- /dev/null
@@ -0,0 +1,9 @@
+module Toolsets
+  def self.clang(env, options = {})
+    env.set_toolset(:gcc, options)
+    env['AS']  = 'clang'
+    env['CC']  = 'clang'
+    env['CXX'] = 'clang'
+    env['LD']  = 'clang'
+  end
+end
diff --git a/toolsets/default.rb b/toolsets/default.rb
new file mode 100755 (executable)
index 0000000..a1b7907
--- /dev/null
@@ -0,0 +1,5 @@
+module Toolsets
+  def self.default(env, options = {})
+    env.set_toolset(:gcc, options)
+  end
+end
diff --git a/toolsets/gcc.rb b/toolsets/gcc.rb
new file mode 100755 (executable)
index 0000000..9f7c25e
--- /dev/null
@@ -0,0 +1,44 @@
+module Toolsets
+  def self.gcc(env, options = {})
+      default_vars = {
+        "AR" => "ar",
+        "ARCMD" => ["${AR}", "rcs", "${ARFLAGS}", "${_TARGET}", "${_SOURCES}"],
+        "ARFLAGS" => [],
+
+        "AS" => "${CC}",
+        "ASCMD" => ["${AS}", "-c", "-o", "${_TARGET}", "${ASDEPGEN}", "-I${ASPPPATH}", "${ASPPFLAGS}", "${ASFLAGS}", "${_SOURCES}"],
+        "ASDEPGEN" => ["-MMD", "-MF", "${_DEPFILE}"],
+        "ASFLAGS" => [],
+        "ASPPFLAGS" => ["${CPPFLAGS}"],
+        "ASSUFFIX" => ".S",
+
+        "CC" => "gcc",
+        "CCCMD" => ["${CC}", "-c", "-o", "${_TARGET}", "${CCDEPGEN}", "-I${CPPPATH}", "${CPPFLAGS}", "${CFLAGS}", "${_SOURCES}"],
+        "CCDEPGEN" => ["-MMD", "-MF", "${_DEPFILE}"],
+        "CFLAGS" => [],
+        "CSUFFIX" => ".c",
+
+        "CXX" => "g++",
+        "CXXCMD" => ["${CXX}", "-c", "-o", "${_TARGET}", "${CXXDEPGEN}", "-I${CPPPATH}", "${CPPFLAGS}", "${CXXFLAGS}", "${_SOURCES}"],
+        "CXXDEPGEN" => ["-MMD", "-MF", "${_DEPFILE}"],
+        "CXXFLAGS" => [],
+        "CXXSUFFIX" => ".cc",
+
+        "CPP_CMD" => ["${_PREPROCESS_CC}", "-E", "-o", "${_TARGET}", "-I${CPPPATH}", "${CPPFLAGS}", "${CFLAGS}", "${_SOURCES}"],
+        "CPPFLAGS" => ["-D${defines}"],
+
+        "DISASM_CMD" => ["${OBJDUMP}", "${DISASM_FLAGS}", "${_SOURCES}"],
+        "DISASM_FLAGS" => ["--disassemble", "--source"],
+
+        "LD" => nil,
+        "LDCMD" => ["${LD}", "-o", "${_TARGET}", "${LDFLAGS}", "${_SOURCES}", "-L${LIBPATH}", "-l${LIBS}"],
+        "LDFLAGS" => [],
+
+        "OBJDUMP" => "objdump",
+        "OBJSUFFIX" => ".o",
+      }
+      default_vars.each_pair do |var, val|
+        env[var] = val
+      end
+  end
+end