# Rscons Software construction library inspired by SCons and implemented in Ruby [![Gem Version](https://badge.fury.io/rb/rscons.png)](http://badge.fury.io/rb/rscons) ## Installation Add this line to your application's Gemfile: gem "rscons" And then execute: $ bundle install Or install it yourself as: $ gem install rscons ## Usage Rscons is a Ruby library. It can be called from a standalone Ruby script or it can be used with rake and called from your Rakefile. ### Example: Building a C Program ```ruby Rscons::Environment.new do |env| env["CFLAGS"] << "-Wall" env.Program("program", Dir["**/*.c"]) end ``` ### Example: Building a D Program ```ruby Rscons::Environment.new do |env| env["DFLAGS"] << "-Wall" env.Program("program", Dir["**/*.d"]) end ``` ### Example: Cloning an Environment ```ruby main_env = Rscons::Environment.new do |env| # Store object files from sources under "src" in "build/main" env.build_dir("src", "build/main") env["CFLAGS"] = ["-DSOME_DEFINE", "-O3"] env["LIBS"] = ["SDL"] env.Program("program", Dir["src/**/*.cc"]) end debug_env = main_env.clone do |env| # Store object files from sources under "src" in "build/debug" env.build_dir("src", "build/debug") env["CFLAGS"] -= ["-O3"] env["CFLAGS"] += ["-g", "-O0"] env.Program("program-debug", Dir["src/**/*.cc"]) end ``` ### Example: Custom Builder Custom builders are implemented as classes which extend from `Rscons::Builder`. The builder must have a `run` method which is called to invoke the builder. The `run` method should return the name of the target built on success, and `false` on failure. ```ruby class GenerateFoo < Rscons::Builder def run(target, sources, cache, env, vars) cache.mkdir_p(File.dirname(target)) File.open(target, "w") do |fh| fh.puts <