From b377940252f73e11803a457fcf5b0335aa5064cb Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 6 Nov 2013 12:45:50 -0500 Subject: [PATCH] begin expanding README documentation --- README.md | 139 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 127 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 59b99f3..df18178 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Software construction library inspired by SCons and implemented in Ruby Add this line to your application's Gemfile: - gem 'rscons' + gem "rscons" And then execute: @@ -18,20 +18,135 @@ Or install it yourself as: ## Usage - RScons::Environment.new do |env| - env.Program('program', Dir['*.c']) - end +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. - main_env = RScons::Environment.new do |env| - env.build_dir('src', 'build/main') - env.Program('program', Dir['src/**/*.cc']) - end +### Example: Building a C Program - debug_env = main_env.clone do |env| - env.build_dir('src', 'build/debug') - env['CFLAGS'] = ['-g', '-O0'] - env.Program('program-debug', Dir['src/**/*.cc']) +```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 + +```ruby +class GenerateFoo < Rscons::Builder + def run(target, sources, cache, env, vars) + File.open(target, "w") do |fh| + fh.puts <