Compare commits

..

No commits in common. "07e7f214f19a0c276fac0f07c70120ae9a6776a4" and "f5ab51c477aacd46eddc2e87d6fbe8f75ba3b74e" have entirely different histories.

182 changed files with 1957 additions and 3609 deletions

View File

@ -1,31 +1,3 @@
## v3.0.1
### Fixes
- #156 - Avoid running configure operation twice
## v3.0.0
- #136 - Move rsconscache into build directory
- #140 - Support naming environments
- #143 - Add Size builder
- #142 - Add 'sh' script DSL method
- #144 - Add FileUtils class methods to script DSL
- #145 - Support environment variable to set rscons build directory
- #146 - Add ^^/ shortcut to top-level build directory
- #139 - Add tasks
- #147 - Add task options
- #148 - Add license/copyright to distributable script
- #150 - Add env.expand() shortcut method to expand paths and construction variables
- #152 - Add download script method
- #153 - Allow passing spawn options to sh
- #154 - Record build directory absolute path
- #149 - Add shortcut method for creating environments
- #131 - Only configure if necessary
- #151 - Store configure task parameters in configuration cache data
- #137 - Add variants
- #155 - Add build_dir script method
## v2.3.0 ## v2.3.0
### New Features ### New Features
@ -35,7 +7,7 @@
### Fixes ### Fixes
- #121 - env.depends() does not work with build-root-relative "^/" paths - #121 - env.depends() does not work with built-root-relative "^/" paths
- #130 - Document -f command line option - #130 - Document -f command line option
- #133 - Clarify failed command error message indicating to run -F - #133 - Clarify failed command error message indicating to run -F
- #134 - Document CMD_STDOUT variable for Command builder - #134 - Document CMD_STDOUT variable for Command builder

View File

@ -1,38 +1,32 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
diff-lcs (1.5.0) diff-lcs (1.4.4)
docile (1.1.5) docile (1.1.5)
json (2.6.1) json (2.5.1)
psych (4.0.3)
stringio
rake (13.0.6) rake (13.0.6)
rdoc (6.4.0) rdoc (6.3.2)
psych (>= 4.0.0)
redcarpet (3.5.1) redcarpet (3.5.1)
rspec (3.11.0) rspec (3.10.0)
rspec-core (~> 3.11.0) rspec-core (~> 3.10.0)
rspec-expectations (~> 3.11.0) rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.11.0) rspec-mocks (~> 3.10.0)
rspec-core (3.11.0) rspec-core (3.10.1)
rspec-support (~> 3.11.0) rspec-support (~> 3.10.0)
rspec-expectations (3.11.0) rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0) rspec-support (~> 3.10.0)
rspec-mocks (3.11.0) rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0) rspec-support (~> 3.10.0)
rspec-support (3.11.0) rspec-support (3.10.2)
simplecov (0.15.1) simplecov (0.15.1)
docile (~> 1.1.0) docile (~> 1.1.0)
json (>= 1.8, < 3) json (>= 1.8, < 3)
simplecov-html (~> 0.10.0) simplecov-html (~> 0.10.0)
simplecov-html (0.10.2) simplecov-html (0.10.2)
stringio (3.0.1)
syntax (1.2.2) syntax (1.2.2)
webrick (1.7.0) yard (0.9.26)
yard (0.9.27)
webrick (~> 1.7.0)
PLATFORMS PLATFORMS
ruby ruby
@ -49,4 +43,4 @@ DEPENDENCIES
yard yard
BUNDLED WITH BUNDLED WITH
2.2.31 2.1.4

View File

@ -1,4 +1,4 @@
Copyright (c) 2013-2022 Josh Holtrop Copyright (c) 2013-2019 Josh Holtrop
MIT License MIT License

View File

@ -4,39 +4,7 @@
Rscons (https://github.com/holtrop/rscons) is an open-source build system Rscons (https://github.com/holtrop/rscons) is an open-source build system
for developers. for developers.
It supports the following features:
* multi-threaded job execution Rscons is written in Ruby, and is inspired by [SCons](https://scons.org/) and [waf](https://waf.io/).
* auto-configuration
* built-in builders for several common operations
* out-of-the-box support for C, C++, and D languages
* extensibility for other languages or custom builders
* compatible with Windows, Linux, OS X, and FreeBSD
* colorized output with build progress
* build hooks
* user-defined tasks with dependencies and custom parameters
* build variants
At its core, Rscons is mainly an engine to:
* determine the proper order to perform build steps,
* determine whether each build target is up to date or in need of rebuild, and
* schedule those build steps across multiple threads as efficiently as possible.
Along the way, Rscons provides a concise syntax for specifying common types of
build steps, but also provides an extensible framework for performing
custom build operations as well.
Rscons takes inspiration from:
* [SCons](https://scons.org/)
* [waf](https://waf.io/)
* [rake](https://github.com/ruby/rake)
* [CMake](https://cmake.org/)
* [Autoconf](https://www.gnu.org/software/autoconf/)
Rscons is written in Ruby.
The only requirement to run Rscons is that the system has a Ruby interpreter
installed.
See [https://holtrop.github.io/rscons/index.html](https://holtrop.github.io/rscons/index.html) for User Guide and Installation instructions. See [https://holtrop.github.io/rscons/index.html](https://holtrop.github.io/rscons/index.html) for User Guide and Installation instructions.

View File

@ -35,7 +35,7 @@ task :dspec, [:example_string] => :build_dist do |task, args|
FileUtils.mkdir_p("test") FileUtils.mkdir_p("test")
FileUtils.cp("dist/rscons", "test/rscons.rb") FileUtils.cp("dist/rscons", "test/rscons.rb")
ENV["dist_specs"] = "1" ENV["dist_specs"] = "1"
Rake::Task["spec"].execute(args) Rake::Task["spec"].execute(args.example_string)
ENV.delete("dist_specs") ENV.delete("dist_specs")
FileUtils.rm_f(Dir.glob(".rscons-*")) FileUtils.rm_f(Dir.glob(".rscons-*"))
end end
@ -76,7 +76,7 @@ task :gen_large_project, [:size] => :build_dist do |task, args|
end end
File.open("large_project/Rsconscript", "w") do |fh| File.open("large_project/Rsconscript", "w") do |fh|
fh.puts <<EOF fh.puts <<EOF
default do build do
Environment.new do |env| Environment.new do |env|
env.Program("project", glob("src/*.c")) env.Program("project", glob("src/*.c"))
end end

View File

@ -3,5 +3,5 @@
require "rscons/cli" require "rscons/cli"
if __FILE__ == $0 if __FILE__ == $0
Rscons::Cli.new.run(ARGV) Rscons::Cli.run(ARGV)
end end

View File

@ -1,4 +1,6 @@
env do |env| build do
env.CFile("lexer.c", "lexer.l") Environment.new do |env|
env.CFile("parser.c", "parser.y") env.CFile("lexer.c", "lexer.l")
env.CFile("parser.c", "parser.y")
end
end end

View File

@ -1,3 +1,5 @@
env do |env| build do
env.CFile("file.c", "foo.bar") Environment.new do |env|
env.CFile("file.c", "foo.bar")
end
end end

View File

@ -1,10 +1,12 @@
debug = env(echo: :command) do |env| build do
env['CFLAGS'] = '-O2' debug = Environment.new(echo: :command) do |env|
env['CPPFLAGS'] = '-DSTRING="Debug Version"' env['CFLAGS'] = '-O2'
env.Program('program-debug.exe', Dir['src/*.c']) env['CPPFLAGS'] = '-DSTRING="Debug Version"'
end env.Program('program-debug.exe', Dir['src/*.c'])
end
release = debug.clone do |env| release = debug.clone do |env|
env["CPPFLAGS"] = '-DSTRING="Release Version"' env["CPPFLAGS"] = '-DSTRING="Release Version"'
env.Program('program-release.exe', Dir['src/*.c']) env.Program('program-release.exe', Dir['src/*.c'])
end
end end

View File

@ -1,14 +1,16 @@
env1 = env(echo: :command) do |env| build do
env['CFLAGS'] = '-O2' env1 = Environment.new(echo: :command) do |env|
env.add_build_hook do |builder| env['CFLAGS'] = '-O2'
builder.vars['CPPFLAGS'] = '-DSTRING="Hello"' env.add_build_hook do |builder|
builder.vars['CPPFLAGS'] = '-DSTRING="Hello"'
end
env.add_post_build_hook do |builder|
$stdout.puts "post #{builder.target}"
end
env.Program('program.exe', Dir['src/*.c'])
end end
env.add_post_build_hook do |builder|
$stdout.puts "post #{builder.target}"
end
env.Program('program.exe', Dir['src/*.c'])
end
env2 = env1.clone do |env| env2 = env1.clone do |env|
env.Program('program2.exe', Dir['src/*.c']) env.Program('program2.exe', Dir['src/*.c'])
end
end end

View File

@ -1,4 +1,3 @@
configure do configure do
check_c_compiler "nope.nope" check_c_compiler "nope.nope"
end end
default

View File

@ -1,3 +1 @@
autoconf false autoconf false
env do |env|
end

View File

@ -3,6 +3,8 @@ configure do
check_c_header "stdio.h" check_c_header "stdio.h"
end end
env do |env| build do
env.Program("simple.exe", "simple.c") Environment.new do |env|
env.Program("simple.exe", "simple.c")
end
end end

View File

@ -1,4 +1,3 @@
configure do configure do
check_c_compiler check_c_compiler
end end
default

View File

@ -1,6 +0,0 @@
configure do
check_c_compiler "clang"
end
env do |env|
env.Program("simple.exe", "simple.c")
end

View File

@ -3,6 +3,8 @@ configure do
check_c_header "frobulous.h", check_cpppath: ["./usr2"] check_c_header "frobulous.h", check_cpppath: ["./usr2"]
end end
env do |env| build do
env.Object("test.o", "test.c") Environment.new do |env|
env.Object("test.o", "test.c")
end
end end

View File

@ -2,6 +2,8 @@ configure do
check_c_header "not___found.h", set_define: "HAVE_NOT___FOUND_H" check_c_header "not___found.h", set_define: "HAVE_NOT___FOUND_H"
end end
env(echo: :command) do |env| build do
env.Object("simple.o", "simple.c") Environment.new(echo: :command) do |env|
env.Object("simple.o", "simple.c")
end
end end

View File

@ -2,6 +2,8 @@ configure do
check_c_header "string.h", set_define: "HAVE_STRING_H" check_c_header "string.h", set_define: "HAVE_STRING_H"
end end
env(echo: :command) do |env| build do
env.Object("simple.o", "simple.c") Environment.new(echo: :command) do |env|
env.Object("simple.o", "simple.c")
end
end end

View File

@ -2,6 +2,8 @@ configure do
check_cfg program: "my-config" check_cfg program: "my-config"
end end
env(echo: :command) do |env| build do
env.Program("myconfigtest", "simple.c") Environment.new(echo: :command) do |env|
env.Program("myconfigtest", "simple.c")
end
end end

View File

@ -2,6 +2,8 @@ configure do
check_cfg package: "mypackage" check_cfg package: "mypackage"
end end
env(echo: :command) do |env| build do
env.Program("myconfigtest", "simple.c") Environment.new(echo: :command) do |env|
env.Program("myconfigtest", "simple.c")
end
end end

View File

@ -2,12 +2,14 @@ configure do
check_cfg package: "mypackage", use: "myp" check_cfg package: "mypackage", use: "myp"
end end
env(echo: :command) do |env| build do
env.Copy("myconfigtest1.c", "simple.c") Environment.new(echo: :command) do |env|
env.Program("myconfigtest1.exe", "myconfigtest1.c") env.Copy("myconfigtest1.c", "simple.c")
end env.Program("myconfigtest1.exe", "myconfigtest1.c")
end
env(echo: :command, use: "myp") do |env| Environment.new(echo: :command, use: "myp") do |env|
env.Copy("myconfigtest2.c", "simple.c") env.Copy("myconfigtest2.c", "simple.c")
env.Program("myconfigtest2.exe", "myconfigtest2.c") env.Program("myconfigtest2.exe", "myconfigtest2.c")
end
end end

View File

@ -3,6 +3,8 @@ configure do
check_cxx_header "frobulous.h", check_cpppath: ["./usr2"] check_cxx_header "frobulous.h", check_cpppath: ["./usr2"]
end end
env do |env| build do
env.Object("test.o", "test.cc") Environment.new do |env|
env.Object("test.o", "test.cc")
end
end end

View File

@ -4,6 +4,8 @@ configure do
check_d_import "frobulous", check_d_import_path: ["./usr2"] check_d_import "frobulous", check_d_import_path: ["./usr2"]
end end
env do |env| build do
env.Object("test.o", "test.d") Environment.new do |env|
env.Object("test.o", "test.d")
end
end end

View File

@ -1,3 +1,5 @@
env(echo: :command) do |env| build do
env.Library("usr2/libfrobulous.a", "two.c") Environment.new(echo: :command) do |env|
env.Library("usr2/libfrobulous.a", "two.c")
end
end end

View File

@ -3,6 +3,8 @@ configure do
check_lib "frobulous", check_libpath: ["./usr2"] check_lib "frobulous", check_libpath: ["./usr2"]
end end
env(echo: :command) do |env| build do
env.Program("simple.exe", "simple.c") Environment.new(echo: :command) do |env|
env.Program("simple.exe", "simple.c")
end
end end

View File

@ -2,6 +2,8 @@ configure do
check_lib "m" check_lib "m"
end end
env(echo: :command) do |env| build do
env.Program("simple.exe", "simple.c") Environment.new(echo: :command) do |env|
env.Program("simple.exe", "simple.c")
end
end end

View File

@ -2,12 +2,14 @@ configure do
check_lib "m", use: :m check_lib "m", use: :m
end end
env(echo: :command) do |env| build do
env.Copy("test1.c", "simple.c") Environment.new(echo: :command) do |env|
env.Program("test2.exe", "test1.c") env.Copy("test1.c", "simple.c")
end env.Program("test2.exe", "test1.c")
end
env(echo: :command, use: %w[m]) do |env| Environment.new(echo: :command, use: %w[m]) do |env|
env.Copy("test2.c", "simple.c") env.Copy("test2.c", "simple.c")
env.Program("test2.exe", "test2.c") env.Program("test2.exe", "test2.c")
end
end end

View File

@ -2,7 +2,9 @@ configure do
check_lib "m", use: false check_lib "m", use: false
end end
env(echo: :command) do |env| build do
env.Copy("test1.c", "simple.c") Environment.new(echo: :command) do |env|
env.Program("test2.exe", "test1.c") env.Copy("test1.c", "simple.c")
env.Program("test2.exe", "test1.c")
end
end end

View File

@ -1,5 +0,0 @@
configure do
check_c_compiler
end
env do |env|
end

View File

@ -23,6 +23,8 @@ configure do
end end
end end
env do |env| build do
puts env["CPPDEFINES"] Environment.new do |env|
puts env["CPPDEFINES"]
end
end end

View File

@ -0,0 +1,3 @@
Environment.new do |env|
env.Object("simple.o", "simple.cc")
end

View File

@ -3,6 +3,8 @@ configure do
check_c_header "stdio.h", set_define: "HAVE_STDIO_H" check_c_header "stdio.h", set_define: "HAVE_STDIO_H"
end end
env(echo: :command) do |env| build do
env.Object("simple.o", "simple.c") Environment.new(echo: :command) do |env|
env.Object("simple.o", "simple.c")
end
end end

View File

@ -1,3 +0,0 @@
default do
puts "default"
end

View File

@ -9,8 +9,10 @@ EOF
end end
end end
env do |env| build do
env.add_builder(MySource) Environment.new do |env|
env.MySource('inc.h', []) env.add_builder(MySource)
env.Program('program.exe', Dir['*.c']) env.MySource('inc.h', [])
env.Program('program.exe', Dir['*.c'])
end
end end

View File

@ -1,11 +1,13 @@
env do |env| build do
env.Command("inc.c", Environment.new do |env|
[], env.Command("inc.c",
"CMD" => %w[ruby gen.rb ${_TARGET}], [],
"CMD_DESC" => "Generating") "CMD" => %w[ruby gen.rb ${_TARGET}],
env["build_root"] = env.build_root "CMD_DESC" => "Generating")
env["inc_c"] = "inc.c" env["build_root"] = env.build_root
env.Object("program.o", "program.c") env["inc_c"] = "inc.c"
env.build_after("program.o", "${inc_c}") env.Object("program.o", "program.c")
env.Program("program.exe", ["program.o", "inc.c"]) env.build_after("program.o", "${inc_c}")
env.Program("program.exe", ["program.o", "inc.c"])
end
end end

View File

@ -9,10 +9,12 @@ EOF
end end
end end
env = env do |env| build do
env["hdr"] = "inc.h" env = Environment.new do |env|
env["src"] = "program.c" env["hdr"] = "inc.h"
env.add_builder(MySource) env["src"] = "program.c"
env.MySource('${hdr}') env.add_builder(MySource)
env.Program('program.exe', "${src}") env.MySource('${hdr}')
env.Program('program.exe', "${src}")
end
end end

View File

@ -9,20 +9,22 @@ EOF
end end
end end
e1 = env do |env| build do
env.add_builder(MySource) e1 = Environment.new do |env|
env["one"] = "5" env.add_builder(MySource)
env[:cfg] = {val: "9"} env["one"] = "5"
env["two"] = lambda do |args| env[:cfg] = {val: "9"}
args[:env][:cfg][:val] env["two"] = lambda do |args|
args[:env][:cfg][:val]
end
env["the_value"] = lambda do |args|
"${one}${two}78"
end
end end
env["the_value"] = lambda do |args|
"${one}${two}78"
end
end
e1.clone do |env| e1.clone do |env|
env[:cfg][:val] = "6" env[:cfg][:val] = "6"
env.MySource('inc.h', []) env.MySource('inc.h', [])
env.Program('program.exe', Dir['*.c']) env.Program('program.exe', Dir['*.c'])
end
end end

View File

@ -1,6 +1,8 @@
env do |env| build do
env.add_builder(:MyBuilder) do |options| Environment.new do |env|
"hi" env.add_builder(:MyBuilder) do |options|
"hi"
end
env.MyBuilder("foo")
end end
env.MyBuilder("foo")
end end

View File

@ -1,6 +1,8 @@
env do |env| build do
env.add_builder(:MyBuilder) do |options| Environment.new do |env|
wait_for(1) env.add_builder(:MyBuilder) do |options|
wait_for(1)
end
env.MyBuilder("foo")
end end
env.MyBuilder("foo")
end end

View File

@ -12,8 +12,10 @@ class CHGen < Rscons::Builder
end end
end end
env do |env| build do
env.add_builder(CHGen) Environment.new do |env|
env.CHGen("inc.c", ["program.c"]) env.add_builder(CHGen)
env.Program("program.exe", %w[program.c inc.c]) env.CHGen("inc.c", ["program.c"])
env.Program("program.exe", %w[program.c inc.c])
end
end end

View File

@ -1,15 +1,17 @@
env do |env| build do
env["build_root"] = env.build_root Environment.new do |env|
env["inc_h"] = "inc.h" env["build_root"] = env.build_root
env["inc_h"] = "inc.h"
env.Copy("copy_inc.h", "${inc_h}") env.Copy("copy_inc.h", "${inc_h}")
env.depends("program.o", "${inc_h}") env.depends("program.o", "${inc_h}")
env.Object("program.o", "program.c") env.Object("program.o", "program.c")
env.Program("program.exe", ["program.o", "inc.c"]) env.Program("program.exe", ["program.o", "inc.c"])
inc_c = env.Command("inc.c", inc_c = env.Command("inc.c",
[], [],
"CMD" => %w[ruby gen.rb ${_TARGET}], "CMD" => %w[ruby gen.rb ${_TARGET}],
"CMD_DESC" => "Generating") "CMD_DESC" => "Generating")
inc_c.produces("inc.h") inc_c.produces("inc.h")
end
end end

View File

@ -1,15 +1,17 @@
env do |env| build do
env["build_root"] = env.build_root Environment.new do |env|
env["inc_h"] = "inc.h" env["build_root"] = env.build_root
env["inc_h"] = "inc.h"
env.Copy("copy_inc.h", "${inc_h}") env.Copy("copy_inc.h", "${inc_h}")
env.depends("program.o", "${inc_h}") env.depends("program.o", "${inc_h}")
env.Object("program.o", "program.c") env.Object("program.o", "program.c")
env.Program("program.exe", ["program.o", "inc.c"]) env.Program("program.exe", ["program.o", "inc.c"])
env.Command("inc.c", env.Command("inc.c",
[], [],
"CMD" => %w[ruby gen.rb ${_TARGET}], "CMD" => %w[ruby gen.rb ${_TARGET}],
"CMD_DESC" => "Generating") "CMD_DESC" => "Generating")
env.produces("inc.c", "inc.h") env.produces("inc.c", "inc.h")
end
end end

View File

@ -13,7 +13,9 @@ class MyBuilder < Rscons::Builder
end end
end end
env do |env| build do
env.add_builder(MyBuilder) Environment.new do |env|
env.MyBuilder("foo") env.add_builder(MyBuilder)
env.MyBuilder("foo")
end
end end

View File

@ -2,6 +2,8 @@ configure do
check_d_compiler "gdc" check_d_compiler "gdc"
end end
env(echo: :command) do |env| build do
env.Program("hello-d.exe", glob("*.d")) Environment.new(echo: :command) do |env|
env.Program("hello-d.exe", glob("*.d"))
end
end end

View File

@ -2,6 +2,8 @@ configure do
check_d_compiler "ldc2" check_d_compiler "ldc2"
end end
env(echo: :command) do |env| build do
env.Program("hello-d.exe", glob("*.d")) Environment.new(echo: :command) do |env|
env.Program("hello-d.exe", glob("*.d"))
end
end end

View File

@ -1,5 +1,7 @@
env(echo: :command) do |env| build do
env.Object("main.o", "main.d") Environment.new(echo: :command) do |env|
env.Object("mod.o", "mod.d") env.Object("main.o", "main.d")
env.Program("hello-d.exe", ["main.o", "mod.o"]) env.Object("mod.o", "mod.d")
env.Program("hello-d.exe", ["main.o", "mod.o"])
end
end end

View File

@ -1,3 +1,5 @@
env do |env| build do
env.Program("test.exe", glob("*.c"), direct: true) Environment.new do |env|
env.Program("test.exe", glob("*.c"), direct: true)
end
end end

View File

@ -1,5 +1,7 @@
env do |env| build do
lib = env.SharedLibrary("mylib", ["two.c", "three.c"], direct: true) Environment.new do |env|
program = env.Program("test.exe", "main.c", "LIBS" => ["mylib"], "LIBPATH" => ["."]) lib = env.SharedLibrary("mylib", ["two.c", "three.c"], direct: true)
env.depends(program, lib) program = env.Program("test.exe", "main.c", "LIBS" => ["mylib"], "LIBPATH" => ["."])
env.depends(program, lib)
end
end end

View File

@ -1,3 +1,5 @@
env do |env| build do
env.Program('header.exe', Dir['*.c']) Environment.new do |env|
env.Program('header.exe', Dir['*.c'])
end
end end

View File

@ -1,16 +1,18 @@
env do |env| build do
require 'json' Environment.new do |env|
require 'yaml' require 'json'
env.add_builder(:JsonToYaml) do |params| require 'yaml'
unless @cache.up_to_date?(@target, :JsonToYaml, @sources, @env) env.add_builder(:JsonToYaml) do |params|
print_run_message("JsonToYaml #{@target}", nil) unless @cache.up_to_date?(@target, :JsonToYaml, @sources, @env)
@cache.mkdir_p(File.dirname(@target)) print_run_message("JsonToYaml #{@target}", nil)
File.open(@target, 'w') do |f| @cache.mkdir_p(File.dirname(@target))
f.write(YAML.dump(JSON.load(IO.read(@sources.first)))) File.open(@target, 'w') do |f|
f.write(YAML.dump(JSON.load(IO.read(@sources.first))))
end
@cache.register_build(@target, :JsonToYaml, @sources, @env)
end end
@cache.register_build(@target, :JsonToYaml, @sources, @env) true
end end
true env.JsonToYaml('foo.yml', 'foo.json')
end end
env.JsonToYaml('foo.yml', 'foo.json')
end end

View File

@ -1,7 +1,6 @@
env(echo: :command) do |env| build do
env["LIBS"] << "mylib" Environment.new(echo: :command) do |env|
env["LIBPATH"] << "." env.Program('library.exe', ['lib.a', 'three.c'])
env.Program("library.exe", "one.c") env.Library("lib.a", ['one.c', 'two.c'], 'CPPFLAGS' => ['-Dmake_lib'])
env.depends("library.exe", "libmylib.a") end
env.Library("libmylib.a", ["two.c", "three.c"], "CPPFLAGS" => ["-Dmake_lib"])
end end

View File

@ -1,5 +1,7 @@
env do |env| build do
env.Program("library.exe", ["lib.a", "three.c"]) Environment.new do |env|
env.Object("two.o", "two.c") env.Program("library.exe", ["lib.a", "three.c"])
env.Library("lib.a", ["one.c", "two.o"], 'CPPFLAGS' => ['-Dmake_lib']) env.Object("two.o", "two.c")
env.Library("lib.a", ["one.c", "two.o"], 'CPPFLAGS' => ['-Dmake_lib'])
end
end end

View File

@ -1,11 +1,8 @@
#include <stdio.h> #include <stdio.h>
void two(); #ifdef make_lib
void three();
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
two();
printf("Library\n"); printf("Library\n");
three();
} }
#endif

View File

@ -1,4 +1,6 @@
env(echo: :command) do |env| build do
env["ARCMD"] = %w[ar rc ${_TARGET} ${_SOURCES}] Environment.new(echo: :command) do |env|
env.Library("lib.a", glob("*.c")) env["ARCMD"] = %w[ar rcf ${_TARGET} ${_SOURCES}]
env.Library("lib.a", glob("*.c"))
end
end end

View File

@ -1,3 +0,0 @@
void three(void)
{
}

View File

@ -1,3 +0,0 @@
void two(void)
{
}

View File

@ -1,3 +1,5 @@
env do |env| build do
env.Program("foo.exe", glob("*.cc", "*.c")) Environment.new do |env|
env.Program("foo.exe", glob("*.cc", "*.c"))
end
end end

View File

@ -1,3 +1,5 @@
env do |env| build do
env.Preprocess("pp", "foo.h") Environment.new do |env|
env.Preprocess("pp", "foo.h")
end
end end

View File

@ -1,4 +1,4 @@
default do build do
sh "echo", "hi there" sh "echo", "hi there"
sh(["echo 1 2"]) sh(["echo 1 2"])
end end

View File

@ -1,4 +1,4 @@
default do build do
sh "foobar42" sh "foobar42"
sh "echo", "continued" sh "echo", "continued"
end end

View File

@ -1,4 +1,4 @@
default do build do
sh "foobar42", continue: true sh "foobar42", continue: true
sh "echo", "continued" sh "echo", "continued"
end end

View File

@ -1,11 +1,13 @@
env do |env| build do
env["CPPPATH"] << "src/lib" Environment.new do |env|
libmine = env.SharedLibrary("mine", glob("src/lib/*.c")) env["CPPPATH"] << "src/lib"
env.Program("test-shared.exe", libmine = env.SharedLibrary("mine", glob("src/lib/*.c"))
glob("src/*.c"), env.Program("test-shared.exe",
"LIBPATH" => %w[.], glob("src/*.c"),
"LIBS" => %w[mine]) "LIBPATH" => %w[.],
env.build_after("test-shared.exe", libmine) "LIBS" => %w[mine])
env.Program("test-static.exe", env.build_after("test-shared.exe", libmine)
glob("src/**/*.c")) env.Program("test-static.exe",
glob("src/**/*.c"))
end
end end

View File

@ -1,6 +1,8 @@
env do |env| build do
File.open("foo.xyz", "wb") do |fh| Environment.new do |env|
fh.puts("hi") File.open("foo.xyz", "wb") do |fh|
fh.puts("hi")
end
env.SharedObject("foo.o", "foo.xyz")
end end
env.SharedObject("foo.o", "foo.xyz")
end end

View File

@ -1,5 +1,7 @@
env do |env| build do
env["CPPPATH"] << "src/lib" Environment.new do |env|
env.Object("file.S", "src/lib/one.c", "CFLAGS" => env["CFLAGS"] + ["-S"]) env["CPPPATH"] << "src/lib"
libmine = env.SharedLibrary("mine", "file.S") env.Object("file.S", "src/lib/one.c", "CFLAGS" => env["CFLAGS"] + ["-S"])
libmine = env.SharedLibrary("mine", "file.S")
end
end end

View File

@ -1,11 +1,13 @@
env do |env| build do
env["CPPPATH"] << "src/lib" Environment.new do |env|
libmine = env.SharedLibrary("mine", glob("src/lib/*.cc")) env["CPPPATH"] << "src/lib"
env.Program("test-shared.exe", libmine = env.SharedLibrary("mine", glob("src/lib/*.cc"))
glob("src/*.cc"), env.Program("test-shared.exe",
"LIBPATH" => %w[.], glob("src/*.cc"),
"LIBS" => %w[mine]) "LIBPATH" => %w[.],
env.build_after("test-shared.exe", libmine) "LIBS" => %w[mine])
env.Program("test-static.exe", env.build_after("test-shared.exe", libmine)
glob("src/**/*.cc")) env.Program("test-static.exe",
glob("src/**/*.cc"))
end
end end

View File

@ -1,9 +1,11 @@
env do |env| build do
env["CPPPATH"] << "src/lib" Environment.new do |env|
libmine = env.SharedLibrary("mine", glob("src/lib/*.d")) env["CPPPATH"] << "src/lib"
env.Program("test-shared.exe", libmine = env.SharedLibrary("mine", glob("src/lib/*.d"))
glob("src/*.c"), env.Program("test-shared.exe",
"LIBPATH" => %w[.], glob("src/*.c"),
"LIBS" => %w[mine]) "LIBPATH" => %w[.],
env.build_after("test-shared.exe", libmine) "LIBS" => %w[mine])
env.build_after("test-shared.exe", libmine)
end
end end

View File

@ -1,5 +1,7 @@
env do |env| build do
env["CPPPATH"] << "src/lib" Environment.new do |env|
env.SharedObject("one.o", "src/lib/one.c") env["CPPPATH"] << "src/lib"
libmine = env.SharedLibrary("mine", ["one.o", "src/lib/two.c"]) env.SharedObject("one.o", "src/lib/one.c")
libmine = env.SharedLibrary("mine", ["one.o", "src/lib/two.c"])
end
end end

View File

@ -1,12 +1,14 @@
env do |env| build do
env["CPPPATH"] << "src/lib" Environment.new do |env|
env["SHLD"] = "gcc" env["CPPPATH"] << "src/lib"
libmine = env.SharedLibrary("mine", glob("src/lib/*.c")) env["SHLD"] = "gcc"
env.Program("test-shared.exe", libmine = env.SharedLibrary("mine", glob("src/lib/*.c"))
glob("src/*.c"), env.Program("test-shared.exe",
"LIBPATH" => %w[.], glob("src/*.c"),
"LIBS" => %w[mine]) "LIBPATH" => %w[.],
env.build_after("test-shared.exe", libmine) "LIBS" => %w[mine])
env.Program("test-static.exe", env.build_after("test-shared.exe", libmine)
glob("src/**/*.c")) env.Program("test-static.exe",
glob("src/**/*.c"))
end
end end

View File

@ -1,3 +1,5 @@
env do |env| build do
env.Program('simple.exe', Dir['*.c']) Environment.new do |env|
env.Program('simple.exe', Dir['*.c'])
end
end end

View File

@ -1,13 +1,15 @@
env(echo: :command) do |env| build do
tempdir = ENV["TEMP"] || ENV["TMP"] || "/tmp" Environment.new(echo: :command) do |env|
source_file = File.join(tempdir, "abs.c") tempdir = ENV["TEMP"] || ENV["TMP"] || "/tmp"
File.open(source_file, "w") do |fh| source_file = File.join(tempdir, "abs.c")
fh.puts(<<-EOF) File.open(source_file, "w") do |fh|
int main() fh.puts(<<-EOF)
{ int main()
return 29; {
} return 29;
EOF }
EOF
end
env.Program("abs.exe", source_file)
end end
env.Program("abs.exe", source_file)
end end

View File

@ -10,13 +10,15 @@ class ThreadedTestBuilder < Rscons::Builder
end end
end end
env do |env| build do
env.add_builder(ThreadedTestBuilder) Environment.new do |env|
env.ThreadedTestBuilder("T3", [], "delay" => 3) env.add_builder(ThreadedTestBuilder)
env.ThreadedTestBuilder("T2", [], "delay" => 1.0) env.ThreadedTestBuilder("T3", [], "delay" => 3)
env.ThreadedTestBuilder("T1", [], "delay" => 0.5) env.ThreadedTestBuilder("T2", [], "delay" => 1.0)
env.barrier env.ThreadedTestBuilder("T1", [], "delay" => 0.5)
env.ThreadedTestBuilder("T6", [], "delay" => 1.5) env.barrier
env.ThreadedTestBuilder("T5", [], "delay" => 1.0) env.ThreadedTestBuilder("T6", [], "delay" => 1.5)
env.ThreadedTestBuilder("T4", [], "delay" => 0.5) env.ThreadedTestBuilder("T5", [], "delay" => 1.0)
env.ThreadedTestBuilder("T4", [], "delay" => 0.5)
end
end end

View File

@ -1,4 +1,6 @@
env do |env| build do
object = env.Object("simple.o", "simple.c") Environment.new do |env|
env.Program("simple.exe", object) object = env.Object("simple.o", "simple.c")
env.Program("simple.exe", object)
end
end end

View File

@ -3,8 +3,9 @@ class TestBuilder < Rscons::Builder
true true
end end
end end
build do
env do |env| Environment.new do |env|
env.add_builder(TestBuilder) env.add_builder(TestBuilder)
env.TestBuilder("file") env.TestBuilder("file")
end
end end

View File

@ -14,8 +14,10 @@ class MyObject < Rscons::Builder
end end
end end
env do |env| build do
env.add_builder(MyObject) Environment.new do |env|
env.MyObject("simple.o", "simple.c") env.add_builder(MyObject)
env.Program("simple.exe", "simple.o") env.MyObject("simple.o", "simple.c")
env.Program("simple.exe", "simple.o")
end
end end

View File

@ -1,4 +1,6 @@
env do |env| build do
env["LIBS"] += ["m"] Environment.new do |env|
env.Program('simple.exe', Dir['*.c']) env["LIBS"] += ["m"]
env.Program('simple.exe', Dir['*.c'])
end
end end

View File

@ -4,17 +4,17 @@ class DebugBuilder < Rscons::Builder
finalize_command finalize_command
else else
@command = %W[gcc -c -o #{@target} #{@sources.first}] @command = %W[gcc -c -o #{@target} #{@sources.first}]
if ENV["test"] == "command_change" if Rscons.vars["command_change"]
@command += %w[-Wall] @command += %w[-Wall]
end end
if ENV["test"] == "new_dep" if Rscons.vars["new_dep"]
@sources += ["extra"] @sources += ["extra"]
end end
if ENV["test"] == "strict_deps1" if Rscons.vars["strict_deps1"]
@sources += ["extra"] @sources += ["extra"]
strict_deps = true strict_deps = true
end end
if ENV["test"] == "strict_deps2" if Rscons.vars["strict_deps2"]
@sources = ["extra"] + @sources @sources = ["extra"] + @sources
strict_deps = true strict_deps = true
end end
@ -27,10 +27,12 @@ class DebugBuilder < Rscons::Builder
end end
end end
env do |env| build do
env.add_builder(DebugBuilder) Environment.new do |env|
if ENV["test"] == "new_user_dep" env.add_builder(DebugBuilder)
env.depends("foo.o", "new_dep") if Rscons.vars["new_user_dep"]
env.depends("foo.o", "new_dep")
end
env.DebugBuilder("foo.o", "simple.c")
end end
env.DebugBuilder("foo.o", "simple.c")
end end

View File

@ -1,3 +1,5 @@
env do |env| build do
env.Copy("simple.copy", "simple.c") Environment.new do |env|
env.Copy("simple.copy", "simple.c")
end
end end

View File

@ -1,6 +1,8 @@
env do |env| build do
env.Object("simple.o", "simple.c") Environment.new do |env|
env.process env.Object("simple.o", "simple.c")
env["LDCMD"] = %w[gcc -o ${_TARGET} simple.o] env.process
env.Program('simple.exe', []) env["LDCMD"] = %w[gcc -o ${_TARGET} simple.o]
env.Program('simple.exe', [])
end
end end

View File

@ -1,5 +1,7 @@
env do |env| build do
env.Object("simple.o", "simple.c") Environment.new do |env|
env["LDCMD"] = %w[gcc -o ${_TARGET} simple.o] env.Object("simple.o", "simple.c")
env.Program('simple.exe', ["simple.o"]) env["LDCMD"] = %w[gcc -o ${_TARGET} simple.o]
env.Program('simple.exe', ["simple.o"])
end
end end

View File

@ -1,4 +1,6 @@
env do |env| build do
env.Object("simple.o", "simple.c") Environment.new do |env|
env.Object("two.o", "two.c") env.Object("simple.o", "simple.c")
env.Object("two.o", "two.c")
end
end end

View File

@ -1,5 +1,7 @@
env do |env| build do
target = env.Program("simple.exe", "simple.c") Environment.new do |env|
user_deps = File.read("user_deps", mode: "rb").split(" ") target = env.Program("simple.exe", "simple.c")
target.depends(*user_deps) user_deps = File.read("user_deps", mode: "rb").split(" ")
target.depends(*user_deps)
end
end end

View File

@ -13,7 +13,9 @@ class TestBuilder < Rscons::Builder
end end
end end
env do |env| build do
env.add_builder(TestBuilder) Environment.new do |env|
env.TestBuilder("foo") env.add_builder(TestBuilder)
env.TestBuilder("foo")
end
end end

View File

@ -1,7 +0,0 @@
env do |env|
env.Program('simple.exe', Dir['*.c'])
end
clean do
puts "custom clean action"
end

View File

@ -1,4 +1,6 @@
env do |env| build do
env.Program("simple.exe", "simple.c") Environment.new do |env|
env.clear_targets env.Program("simple.exe", "simple.c")
env.clear_targets
end
end end

View File

@ -1,7 +1,9 @@
base_env = env do |env| build do
env.n_threads = 165 base_env = Environment.new do |env|
end env.n_threads = 165
end
my_env = base_env.clone do |env| my_env = base_env.clone
puts env.n_threads
puts my_env.n_threads
end end

View File

@ -1,4 +1,6 @@
env(echo: :command) do |env| build do
env["LD"] = "gcc" Environment.new(echo: :command) do |env|
env.Program('simple.exe', Dir['*.c']) env["LD"] = "gcc"
env.Program('simple.exe', Dir['*.c'])
end
end end

View File

@ -1,7 +1,9 @@
env do |env| build do
command = %W[gcc -o ${_TARGET} ${_SOURCES}] Environment.new do |env|
env.Command("simple.exe", command = %W[gcc -o ${_TARGET} ${_SOURCES}]
"simple.c", env.Command("simple.exe",
"CMD" => command, "simple.c",
"CMD_DESC" => "BuildIt") "CMD" => command,
"CMD_DESC" => "BuildIt")
end
end end

View File

@ -1,8 +1,10 @@
env do |env| build do
env.Object("simple.o", "simple.c") Environment.new do |env|
env.Command("simple.txt", env.Object("simple.o", "simple.c")
"simple.o", env.Command("simple.txt",
"CMD" => %w[objdump --disassemble --source ${_SOURCES}], "simple.o",
"CMD_STDOUT" => "${_TARGET}", "CMD" => %w[objdump --disassemble --source ${_SOURCES}],
"CMD_DESC" => "My Disassemble") "CMD_STDOUT" => "${_TARGET}",
"CMD_DESC" => "My Disassemble")
end
end end

View File

@ -1,4 +1,6 @@
env do |env| build do
env["sources"] = glob("*.c") Environment.new do |env|
env.Program("simple.exe", "${sources}") env["sources"] = glob("*.c")
env.Program("simple.exe", "${sources}")
end
end end

View File

@ -1,3 +1,5 @@
env do |env| build do
env.Directory("teh_dir") Environment.new do |env|
env.Directory("teh_dir")
end
end end

View File

@ -1,4 +1,6 @@
env do |env| build do
env.Object("simple.o", "simple.c") Environment.new do |env|
env.Disassemble("simple.txt", "simple.o") env.Object("simple.o", "simple.c")
env.Disassemble("simple.txt", "simple.o")
end
end end

View File

@ -1,3 +1,5 @@
env do |env| build do
env.Object("simple.o", "simple.c") Environment.new do |env|
env.Object("simple.o", "simple.c")
end
end end

View File

@ -1,5 +1,5 @@
default do build do
env = env do |env| env = Environment.new do |env|
env["CFLAGS"] += %w[-O2 -fomit-frame-pointer] env["CFLAGS"] += %w[-O2 -fomit-frame-pointer]
env[:foo] = :bar env[:foo] = :bar
end end

View File

@ -1,5 +0,0 @@
default do
env do |env|
env.Program('simple.exe', Dir['*.c'])
end
end

View File

@ -1,5 +1,7 @@
env do |env| build do
env.Command("foo", "bar") Environment.new do |env|
env.Command("bar", "baz") env.Command("foo", "bar")
env.Command("baz", "foo") env.Command("bar", "baz")
env.Command("baz", "foo")
end
end end

View File

@ -1,3 +1,5 @@
env do |env| build do
env.Command("foo", "foo") Environment.new do |env|
env.Command("foo", "foo")
end
end end

View File

@ -1,3 +1,5 @@
env do |env| build do
env.produces("foo", "bar") Environment.new do |env|
env.produces("foo", "bar")
end
end end

View File

@ -1,6 +1,8 @@
env do |env| build do
File.open("foo.xyz", "wb") do |fh| Environment.new do |env|
fh.puts("hi") File.open("foo.xyz", "wb") do |fh|
fh.puts("hi")
end
env.Object("foo.o", "foo.xyz")
end end
env.Object("foo.o", "foo.xyz")
end end

View File

@ -1,6 +1,7 @@
env(echo: :command) do |env| build do
env["LD"] = "gcc" Environment.new(echo: :command) do |env|
mkdir_p("libdir") env["LD"] = "gcc"
env["LIBPATH"] += ["libdir"] env["LIBPATH"] += ["libdir"]
env.Program('simple.exe', Dir['*.c']) env.Program('simple.exe', Dir['*.c'])
end
end end

View File

@ -1,4 +1,6 @@
env(echo: :command) do |env| build do
env.Object("simple.o", "simple.c", Environment.new(echo: :command) do |env|
"CCCMD" => %w[${CC} -c -o ${_TARGET} -Dfoobar ${_SOURCES}]) env.Object("simple.o", "simple.c",
"CCCMD" => %w[${CC} -c -o ${_TARGET} -Dfoobar ${_SOURCES}])
end
end end

Some files were not shown because too many files have changed in this diff Show More