]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
Updated build-system to migrate away from rake
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 31 Oct 2014 19:33:41 +0000 (15:33 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 31 Oct 2014 19:33:41 +0000 (15:33 -0400)
Gemfile
Gemfile.lock
build-system
build.rb [new file with mode: 0644]

diff --git a/Gemfile b/Gemfile
index 278750098ad15f4ed157414dac30340890a8f971..1750c4a9bea4fa015ee9e7dc6c202e0ebd6f3725 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,4 @@
-source 'http://rubygems.org'
-gem 'rscons'
-gem 'rake'
-gem 'rspec'
+gem 'rake', '>= 0'\r
+gem 'rscons', '>= 0'\r
+gem 'rspec', '>= 0'\r
+gem 'trollop', '>= 0'\r
index 03860b24ad1ed6c53db77742fc7fe7b61bd93a0e..935b02bd5f649614dadb8c264fa4462dcf8421d1 100644 (file)
@@ -1,10 +1,9 @@
 GEM
-  remote: http://rubygems.org/
   specs:
     diff-lcs (1.2.5)
     json (1.8.1)
     rake (10.3.2)
-    rscons (1.7.0)
+    rscons (1.8.1)
       json (~> 1.0)
     rspec (3.1.0)
       rspec-core (~> 3.1.0)
@@ -18,12 +17,13 @@ GEM
     rspec-mocks (3.1.3)
       rspec-support (~> 3.1.0)
     rspec-support (3.1.2)
+    trollop (2.0)
 
 PLATFORMS
-  ruby
   x86-mingw32
 
 DEPENDENCIES
   rake
   rscons
   rspec
+  trollop
index 727e6f5ffd84778e13f16fffafbc42a987dd1796..35189ce8dadd9924e8f2eddb35ed1d3167a6cb42 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 727e6f5ffd84778e13f16fffafbc42a987dd1796
+Subproject commit 35189ce8dadd9924e8f2eddb35ed1d3167a6cb42
diff --git a/build.rb b/build.rb
new file mode 100644 (file)
index 0000000..f950738
--- /dev/null
+++ b/build.rb
@@ -0,0 +1,84 @@
+#!/bin/env ruby
+require './build-system/setup'
+
+def windows?
+  RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
+end
+
+#------------------------------------------------------------------------------
+# Environment Definitions
+#------------------------------------------------------------------------------
+# Define the default compiler environment
+base_env = BuildEnv.new do |env|
+  # Move the object files to the build dir
+  env.build_dir('source','build/obj/source')
+  env.build_dir('modules','build/obj/modules')
+
+  # Use gcc toolchain
+  env.set_toolset(:gcc)
+
+  # Add a builder for creating directories
+  env.add_builder :MakeDir do |target, sources, cache, env, vars|
+    cache.mkdir_p(target)
+    target if Dir.exists?(target)
+  end
+
+  # CMake Configuration
+  env['CMAKE_GENERATOR'] = ENV['CMAKE_GENERATOR'] || "#{windows? ? 'NMake' : 'Unix'} Makefiles"
+  env['CMAKE_FLAGS']     = []
+  env['CMAKE_CMD']       = ['cmake', '-G', '${CMAKE_GENERATOR}', '${CMAKE_FLAGS}']
+  env['MAKE_CMD']        = windows? ? 'nmake' : 'make'
+
+  # Compiler options
+  env["CFLAGS"] += ['-DLEAK_DETECT_LEVEL=1', '--std=c99', '-Wall', '-Wextra']#, '-Werror']
+  env["CPPPATH"] += ['modules/libopts/source'] + Dir['modules/libcds/source/**/']
+end
+
+# Define the release environment
+main_env = base_env.clone do |env|
+  # Move the object files to the build dir
+  env.build_dir('source','build/obj/source')
+  env.build_dir('modules','build/obj/modules')
+  env["CFLAGS"] += ['-O3']
+end
+
+# Define the test environment
+test_env = base_env.clone do |env|
+  # Move the object files to the build dir
+  env.build_dir('source','build/obj_test/source')
+  env.build_dir('modules','build/obj_test/modules')
+  env['CFLAGS'] +=  ['-O0', '--coverage']
+  env['LDFLAGS'] += ['--coverage']
+end
+
+#------------------------------------------------------------------------------
+# Clang Toolchain Targets
+#------------------------------------------------------------------------------
+main_env.MakeDir('build/llvm', [])
+main_env.Command('build/llvm/Makefile',
+                 Dir['source/vendor/llvm-3.4.2/CMakeLists.txt',
+                     'source/vendor/llvm-3.4.2/cmake/**/*/'],
+                 'CMD' => ['cd', 'build/llvm/', '&&', '${CMAKE_CMD}', '../../source/vendor/llvm-3.4.2/'])
+main_env.Command("build/llvm/bin/clang#{windows? ? '.exe':''}",
+                 Dir['source/vendor/llvm-3.4.2/tools/**/*.*'],
+                 'CMD' => ['cd', 'build/llvm', '&&', '${MAKE_CMD}'])
+
+# Register clang with the environment
+ENV['PATH'] = "build/llvm/bin/#{windows? ? ';':':'}#{ENV['PATH']}"
+
+#------------------------------------------------------------------------------
+# Release Build Targets
+#------------------------------------------------------------------------------
+main_env.Library('build/lib/libcds.a', FileList['modules/libcds/source/**/*.c'])
+main_env.Library('build/lib/libopts.a', FileList['modules/libopts/source/**/*.c'])
+main_env.Program('build/bin/sclpl',
+  FileList['source/sclpl/*.c', 'build/lib/libopts.a', 'build/lib/libcds.a'])
+
+#------------------------------------------------------------------------------
+# Test Build Targets
+#------------------------------------------------------------------------------
+test_env.Program('build/bin/sclpl-test',
+  FileList['source/sclpl/*.c', 'build/lib/libopts.a', 'build/lib/libcds.a'])
+test_env.Command('RSpec', [], 'CMD' => [
+    'rspec', '--pattern', 'spec/**{,/*/**}/*_spec.rb', '--format', 'documentation'])
+