Compare commits

..
138 Commits
Author SHA1 Message Date
josh 784bbd471b wip 2019-04-21 21:08:02 -04:00
josh c60589a9c9 move a few Install builder tests to Copy builder 2019-04-19 14:32:25 -04:00
josh 04fc9866c4 recurse to configure before build rather than calling configure() directly 2019-04-19 14:15:33 -04:00
josh 7a807575b2 only use build_tests/typical/install.rb for Install builder specs 2019-04-19 14:12:33 -04:00
josh 787b3249a7 raise error if user constructs an Environment before configuration is complete 2019-04-14 20:45:31 -04:00
josh 3115e55739 move Application#determine_n_threads -> Util.determine_n_threads 2019-04-14 15:49:46 -04:00
josh 0c07ea0437 compress rscons script like waf - close #76 2019-04-14 15:26:28 -04:00
josh 0e7c976089 fix inconsistent type handling in VarSet#expand_varref - #73 2019-04-14 14:11:48 -04:00
josh 921f0d2cb1 expose glob method directly to Rsconscript - close #97 2019-04-14 12:51:37 -04:00
josh c23426c5aa remove SharedObject special handling in Environment#get_build_fname - close #96 2019-04-14 12:41:12 -04:00
josh ea2b1e73d1 add direct mode to Program builder - close #61 2019-04-14 12:35:28 -04:00
josh 9bf4b8fa96 add barriers - close #53 2019-04-09 22:29:22 -04:00
josh 008fa4844d allow passing Builder objects as sources to build targets - close #95 2019-04-09 20:35:46 -04:00
josh 568b78e2e2 test tracking object file source language - #87 2019-04-09 19:52:25 -04:00
josh 3b00016278 Program builder cleanup, track object file source language - #94, #87 2019-04-09 19:41:13 -04:00
josh a655d04541 Add Depfile builder mixin - #94 2019-04-09 18:41:02 -04:00
josh 5534878f68 Object builder cleanup - #94 2019-04-09 18:28:42 -04:00
josh 1efee50b2c add Builders::Mixins::ObjectDeps to commonize some builder functionality 2019-03-16 22:34:07 -04:00
josh 3ff09978f4 remove Builder.features and Builder.produces? 2019-03-16 21:54:20 -04:00
josh ac1fc6d106 move default construction variables into one place 2019-03-13 21:17:37 -04:00
josh 06b9c98ed0 support false :use value for configure operations - close #93 2019-02-28 21:09:56 -05:00
josh f58744d31f mv build_dist.rb -> rb/build_dist.rb 2019-02-28 21:00:39 -05:00
josh bf136e79f2 rework showing failed command - close #89 2019-02-26 06:52:43 -05:00
josh ab2fa1662f Replace specialized Cache accessors with general #[]/#[]= methods. 2019-02-25 21:22:54 -05:00
josh 68118c2707 Remove Cache dirty-tracking
It really wasn't necessary since Cache#write is not called often.
2019-02-25 21:16:48 -05:00
josh 6ce3d59ad9 Add integration test for copying multiple sources with Copy builder 2019-02-25 21:13:57 -05:00
josh 983862a528 update builder messages - close #77 2019-02-18 22:30:11 -05:00
josh 658b73e4de add build test for a builder waiting on another builder 2019-02-17 22:20:51 -05:00
josh b882f8de99 Rework builder interface to only use #run method - close #91
The builder's #run method will be called repeatedly until it returns
true or false. The Builder#wait_for method can be used to cause a
builder to wait for a Thread, Command, or another Builder.
2019-02-17 22:08:39 -05:00
josh 8426a54a57 replace JobSet with BuilderSet 2019-02-17 14:17:31 -05:00
josh ee1640008c simplify JobSet logic a little 2019-02-17 13:59:03 -05:00
josh 7cfd23e16f remove :builder and :cache from build_operation 2019-02-16 19:12:33 -05:00
josh 5c3b615aee remove unused :which parameter to Environment#wait_for_threaded_commands 2019-02-16 18:36:44 -05:00
josh 935848c3b5 remove some builder-tracked fields from the build_operation Hash 2019-02-16 18:21:19 -05:00
josh d047a1bf29 JobSet only stores builders instead of build info hashes 2019-02-16 18:06:03 -05:00
josh 016bf5eac7 use Builder instance variables as much as possible in #finalize 2019-02-16 17:53:21 -05:00
josh 33504f586b pass Builder object to build hooks instead of build_operation Hash 2019-02-13 21:13:13 -05:00
josh 86594c62b6 begin transitioning builders to using instance variables instead of #run options Hash fields 2019-02-11 22:53:41 -05:00
josh ea25f62f7c remove deprecated Environment#add_target parameter - #84 2019-02-10 22:20:34 -05:00
josh f2cfc25604 Remove Environment#run_builder :allow_delayed_execution option - #84 2019-02-10 22:13:37 -05:00
josh a1f5f022d1 test build hooks overwriting entire vars hash as a non-backwards-compatiblity test 2019-02-10 22:07:08 -05:00
josh 7992450383 Drop support for 5-argument form of Builder#run - #84 2019-02-10 21:47:34 -05:00
josh b41a368da1 alphabetize Util public methods 2019-02-10 21:26:37 -05:00
josh 1b63dc7503 move Environment.parse_makefile_deps to Util 2019-02-10 21:23:52 -05:00
josh db788cdd35 Move Environment#command_to_s to Util. 2019-02-10 21:16:56 -05:00
josh 3f8b4d616f Remove BuildTarget, Builder#create_build_target, and Builder#setup - close #90 2019-02-10 18:24:49 -05:00
josh aac32d20b0 create Builder instance for each build operation - close #88 2019-02-10 17:27:40 -05:00
josh 12f1909d35 remove a few deprecated methods - #84 2019-01-04 13:55:00 -05:00
josh 31ef45258f make global CLI options available under subcommands - close #86 2019-01-03 13:50:01 -05:00
josh 9f9b7f0bf4 preserve .mf dependency files - close #58 2019-01-01 21:17:28 -05:00
josh 918c629435 add verbose CLI option to set Environment default echo mode - close #70 2019-01-01 16:15:22 -05:00
josh eaac473f44 provide Environment construction option to use stored configuration settings - close #78 2019-01-01 15:49:15 -05:00
josh fa5aa51daa Do not rebuild after building after auto-configuration. - close #80
Split Environment into BasicEnvironment and Environment.
2018-12-30 15:57:05 -05:00
josh 347d651ab6 Add builder construction variables to Environments before the builder is added. 2018-12-29 17:57:41 -05:00
josh 08085f09c4 libs found with check_lib should be added to LIBS - close #79 2018-12-17 23:05:18 -05:00
josh 5915ac2b95 ConfigureOp: refactor some logic into #store_common 2018-12-17 22:54:34 -05:00
josh a98c111cd2 implement distclean operation - close #81 2018-12-17 22:47:00 -05:00
josh 93ffed2eb2 Use "Environment" instead of "Rscons::Environment" in build tests 2018-12-17 22:14:35 -05:00
josh f8e6666a2c Add 'build' DSL method.
Disallow processing Environments until configuration is performed.
2018-12-17 22:14:35 -05:00
josh 5720662b7c avoid mkdir() race conditions - close #75 2018-12-11 22:13:52 -05:00
josh 432d221be2 remove build_dir functionality - close #65 2018-12-11 22:06:20 -05:00
John Lindgren a1efb1c1b3 Reduce recursion of VarSet#expand_varref by expanding vars earlier.
It's common for a build command to contain a reference like:

    ${INCPREFIX}${CPPPATH}

Where ${INCPREFIX} is "-I" and ${CPPPATH} is an array of include
paths.  Without this change, Rscons expands ${INCPREFIX} (and then
tries to expand "-I") repeatedly, once for each path.

This change simply makes Rscons intelligent enough to expand
${INCPREFIX} only once, then join the expanded value to each path.

In a mid-sized rake project, ruby-prof shows that the number of
calls to expand_varref is reduced from ~80,000 to ~30,000., and the
total CPU time spent in expand_varref is reduced by about 30%.

In a larger project, the improvement in real build time is small
but consistent enough to be measurable (~0.5 seconds off a total
of ~20 seconds).
2018-12-09 21:20:44 -05:00
josh 7c7ee142e0 implement autoconf - close #63, close #68, closes #67 2018-12-03 22:23:42 -05:00
josh ba69f05e99 remove backtrace from stderr for unknown CLI options - close #69 2018-11-30 23:29:19 -05:00
josh 6180410cc4 add spec for Cache validating JSON contents 2018-11-30 23:11:52 -05:00
josh 2d44a88fb6 add spec for unknown CLI operation 2018-11-30 23:08:16 -05:00
josh 28e3781331 add configure spec testing --prefix 2018-11-30 23:05:41 -05:00
josh c0a28d0207 add configure spec to check multiple set_define's being stored 2018-11-29 22:14:10 -05:00
josh 0e27e967d0 configure: fix handling build_dir and prefix options 2018-11-29 22:06:36 -05:00
josh 1ecce7e99e add configure spec to check as much as possible 2018-11-29 22:02:42 -05:00
josh 25b73ebd8f move logic to find an executable from ConfigureOp to Util 2018-11-29 21:51:30 -05:00
josh bca963af5c add configure spec for check_cfg not finding the specified program 2018-11-29 21:28:37 -05:00
josh ba5377a1ce add configure specs to check for unknown compiler names 2018-11-29 20:51:24 -05:00
josh 8d7fd4bda8 test all known compiler invocation commands - close #66 2018-11-29 17:44:36 -05:00
josh e3e2e46d6e fix configure :set_define handling to append to CPPDEFINES array 2018-11-25 22:00:55 -05:00
josh 9e0ce5a55c add spec for check_cfg with a :package argument 2018-11-25 21:58:22 -05:00
josh b88131eb2f add specs testing configure :set_define option and fix the same 2018-11-25 21:45:46 -05:00
josh dff80587ac move Rscons.absolute_path?() to Util 2018-11-25 21:31:48 -05:00
josh cd2696dd0b add Util specs 2018-11-25 21:22:37 -05:00
josh 36643c1ab1 add Util module and Util.make_relative_path() 2018-11-25 21:17:11 -05:00
josh 778d9ed8b2 add simplecov filters to filter out spec/dspec tests when the opposite spec task is executed 2018-11-25 21:11:00 -05:00
josh 660d30558a remove Environment#to_h 2018-11-25 21:00:29 -05:00
josh 82fbd34149 add dspec task to test dist file; revert spec task to normal behavior 2018-11-25 20:45:32 -05:00
josh e0b82d37af cache: remove obsolete "default_environment_vars" entry 2018-11-25 17:02:02 -05:00
josh 7a90325b67 set Environment build root automatically - close #64 2018-11-25 16:58:19 -05:00
josh 49116e6b59 store build_dir and prefix configuration options in cache 2018-11-25 16:06:36 -05:00
josh 90300a1606 pass operation options via Hash instead of setting Application attributes 2018-11-25 16:02:04 -05:00
josh 1eb07e9a22 use Rsconscript instead of Rsconsfile - close #62 2018-11-25 15:42:53 -05:00
josh 9975eec165 add build test for check_cfg - close #59 2018-11-23 22:23:01 -05:00
josh 04c0a6a86f colorize configure messages more consistently 2018-11-23 21:55:02 -05:00
josh bfdf3a12fd load configuration data when constructing a new Environment - close #60 2018-11-23 21:23:19 -05:00
josh 6dd9c835ce store configuration data more opaquely in Cache 2018-11-23 20:15:39 -05:00
josh cfec0dcadc simplify Application/Script/ConfigureOp interaction with direct calls to configure methods 2018-11-23 19:59:47 -05:00
josh a1c1cc1855 check_cfg: print something 2018-11-15 17:14:11 -05:00
josh add9f9c50d save configured environment construction flags for separate build step - close #60 2018-11-15 17:04:04 -05:00
josh ba3d656110 consolidate some configure check reporting 2018-11-14 23:30:47 -05:00
josh ab4ca71ac7 implement ConfigureOp#check_cfg - not tested yet 2018-11-14 23:28:00 -05:00
josh aba11155a4 rename check_executable to check_program 2018-11-14 23:00:40 -05:00
josh 3b586cb476 implement ConfigureOp#check_lib 2018-11-14 22:53:00 -05:00
josh 88fd4bd405 robustify Ansi module a bit 2018-11-12 21:50:16 -05:00
josh 7869d38dd8 implement ConfigureOp#check_executable 2018-11-07 22:22:07 -05:00
josh e8990199ef configure: output project name and build directory 2018-11-07 21:56:23 -05:00
josh 6078cb0977 implement ConfigureOp#check_d_import 2018-11-07 21:49:44 -05:00
josh 85b0111a6e implement ConfigureOp#check_cxx_header 2018-11-07 21:44:04 -05:00
josh 6bb0a55a55 implement ConfigureOp#check_c_header 2018-11-07 21:39:42 -05:00
josh 95d5ada865 specs: run each build test from separate directory; keep directory if test fails 2018-11-07 21:33:28 -05:00
josh cd9fffd828 Script: change the way configuration arguments are stored 2018-11-07 20:52:39 -05:00
josh 30511a3443 pass the Environment to configure to ConfigureOp; begin modifying it in the tests 2018-11-07 20:46:07 -05:00
josh d656df5407 implement ConfigureOp#check_d_compiler 2018-11-07 19:05:08 -05:00
josh d54d363a25 implement ConfigureOp#check_cxx_compiler 2018-11-07 18:53:06 -05:00
josh 697db2a987 specs: check_c_compiler: also test when no arguments are given 2018-11-06 22:39:13 -05:00
josh daa90e431c check_c_compiler: add integration test for finding second listed C compiler 2018-11-06 22:28:23 -05:00
josh bdeaec11ba Ansi: add some other colors 2018-11-06 22:19:49 -05:00
josh 7eeb6312ba check_c_compiler: print output; add a integration test 2018-11-06 22:16:38 -05:00
josh 07d9b97ddc set default rake task back to spec 2018-11-06 22:14:34 -05:00
josh af033ee4e0 fill in ConfigureOp#test_c_compiler 2018-11-06 21:45:29 -05:00
josh c9de4f37e6 allow configure to fail; application should return error code from operation 2018-11-06 15:42:10 -05:00
josh 64caaa9a53 add ConfigureOp class 2018-11-06 00:17:22 -05:00
josh d196845c85 parse 'configure' command-line options 2018-11-04 00:16:53 -04:00
josh 5288a47bfb start on specs for configure command 2018-11-03 23:19:54 -04:00
josh 9bd9abcad1 update CHANGELOG.md for v1.17.0 2018-11-02 17:02:46 -04:00
josh b5a8b6f628 remove makefile target name check when parsing dependencies - close #57 2018-11-02 14:24:02 -04:00
michael.metivier 7edcef2b30 Environment.expand_varref has the same allowed parameter types and returns as Varset.expand_varref 2018-11-02 11:42:32 -04:00
michael.metivier c34821864e Allow construction variable expansion on _true_ and _false_ literals 2018-11-02 00:57:20 -04:00
josh 97c24eec6b specs: fix Application#determine_n_threads specs 2018-10-30 17:39:43 -04:00
josh 053df2360f add Rscons.vars back again at least for now 2018-10-30 17:36:30 -04:00
josh 8d766e4804 specs: fix cache_varset.rb builder message 2018-10-30 17:36:30 -04:00
josh e29ec5a126 move clean logic to Application 2018-10-30 17:36:30 -04:00
josh de46bb0cc1 specs: remove usage test when no operation given 2018-10-30 17:00:57 -04:00
josh 084080a682 specs: do not run separate 'configure' step before main build test 2018-10-30 17:00:10 -04:00
josh 3a564c0ca2 add Dsl and ConfigureDsl 2018-10-26 21:17:04 -04:00
josh ac89a122d8 add Application class; update CLI and Script for new architecture 2018-10-21 01:24:15 -04:00
josh ea6ae1be10 remove unneeded OptionParser separators 2018-10-12 17:20:34 -04:00
josh a649c7f4cb add Script class 2018-10-12 17:18:04 -04:00
josh 2f83f36659 start adding subcommand interface to Cli module 2018-09-10 20:35:00 -04:00
josh a46936bc0b change default task to build_dist 2018-09-04 16:04:58 -04:00
josh 95ee63292e Rscons is no longer a gem.
Run specs against the combined distributable standalone script.
2018-09-03 19:32:53 -04:00
josh bcd33fe098 add build_dist.rb to create dist/rscons as a standalone script 2018-09-01 17:00:04 -04:00
231 changed files with 5156 additions and 3555 deletions

No files matched your search

+2
View File
@@ -3,5 +3,7 @@
/_yardoc/ /_yardoc/
/build_test_run/ /build_test_run/
/coverage/ /coverage/
/dist/
/doc/ /doc/
/pkg/ /pkg/
/test/
-23
View File
@@ -1,28 +1,5 @@
## ChangeLog ## ChangeLog
### v1.19.0
#### New Features
- #117 - ruby 2.7 compatibility
#### Fixes
- #115 - Check that user dependencies exist before running builders.
### v1.18.0
#### Performance Improvements
- Backport 2.x VarSet performance improvements to 1.x branch.
- Remove Cache dirty-tracking
- Reduce recursion of VarSet#expand_varref by expanding vars earlier.
#### Fixes
- #73 - fix inconsistent type handling in VarSet#expand_varref
- #75 - avoid mkdir() race conditions
### v1.17.0 ### v1.17.0
#### New Features #### New Features
+6 -2
View File
@@ -1,4 +1,8 @@
source 'https://rubygems.org' source 'https://rubygems.org'
# Specify your gem's dependencies in rscons.gemspec gem "json"
gemspec gem "rspec"
gem "rake"
gem "simplecov"
gem "yard"
gem "rdoc"
+19 -25
View File
@@ -1,48 +1,42 @@
PATH
remote: .
specs:
rscons (1.19.0)
json (>= 1.8, < 3.0)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
diff-lcs (1.3) diff-lcs (1.3)
docile (1.1.5) docile (1.1.5)
json (2.3.0) json (2.1.0)
rake (13.0.1) rake (12.3.1)
rdoc (6.2.1) rdoc (5.1.0)
rspec (3.9.0) rspec (3.6.0)
rspec-core (~> 3.9.0) rspec-core (~> 3.6.0)
rspec-expectations (~> 3.9.0) rspec-expectations (~> 3.6.0)
rspec-mocks (~> 3.9.0) rspec-mocks (~> 3.6.0)
rspec-core (3.9.1) rspec-core (3.6.0)
rspec-support (~> 3.9.1) rspec-support (~> 3.6.0)
rspec-expectations (3.9.1) rspec-expectations (3.6.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0) rspec-support (~> 3.6.0)
rspec-mocks (3.9.0) rspec-mocks (3.6.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0) rspec-support (~> 3.6.0)
rspec-support (3.9.2) rspec-support (3.6.0)
simplecov (0.15.1) simplecov (0.15.0)
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)
yard (0.9.24) yard (0.9.12)
PLATFORMS PLATFORMS
ruby ruby
x86-mingw32 x86-mingw32
DEPENDENCIES DEPENDENCIES
json
rake rake
rdoc rdoc
rscons!
rspec rspec
simplecov (~> 0.15.0) simplecov
yard yard
BUNDLED WITH BUNDLED WITH
2.1.4 1.16.2
+4 -4
View File
@@ -1,13 +1,13 @@
# Rscons # Rscons
Rscons (https://github.com/holtrop/rscons) is a software construction framework Rscons (https://github.com/holtrop/rscons) is a software construction framework
inspired by SCons and implemented in Ruby. inspired by SCons and waf but implemented in Ruby.
[![Gem Version](https://badge.fury.io/rb/rscons.png)](http://badge.fury.io/rb/rscons)
## Installation ## Installation
$ gem install rscons Rscons is distributed as a standalone Ruby script named ``rscons``. This file
(containing the complete rscons build system) can be checked into your project
and versioned along with your project.
## Usage ## Usage
+20 -3
View File
@@ -5,13 +5,17 @@ rescue Bundler::BundlerError => e
raise LoadError.new("Unable to setup Bundler; you might need to `bundle install`: #{e.message}") raise LoadError.new("Unable to setup Bundler; you might need to `bundle install`: #{e.message}")
end end
require "bundler/gem_tasks"
require "rspec/core/rake_task" require "rspec/core/rake_task"
require "yard" require "yard"
require "rake/clean" require "rake/clean"
require "fileutils"
CLEAN.include %w[build_test_run .yardoc doc coverage] CLEAN.include %w[build_test_run .yardoc doc coverage test]
CLOBBER.include %w[pkg] CLOBBER.include %w[dist pkg]
task :build_dist do
sh "ruby rb/build_dist.rb"
end
RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args| RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
if args.example_string if args.example_string
@@ -19,6 +23,19 @@ RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
task.rspec_opts = %W[-e "#{args.example_string}" -f documentation] task.rspec_opts = %W[-e "#{args.example_string}" -f documentation]
end end
end end
task :spec => :build_dist
# dspec task is useful to test the distributable release script, but is not
# useful for coverage information.
desc "Dist Specs"
task :dspec, [:example_string] => :build_dist do |task, args|
FileUtils.mkdir_p("test")
FileUtils.cp("dist/rscons", "test/rscons.rb")
ENV["dist_specs"] = "1"
Rake::Task["spec"].invoke(args.example_string)
ENV.delete("dist_specs")
FileUtils.rm_f(Dir.glob(".rscons-*"))
end
YARD::Rake::YardocTask.new do |yard| YARD::Rake::YardocTask.new do |yard|
yard.files = ['lib/**/*.rb'] yard.files = ['lib/**/*.rb']
+3 -1
View File
@@ -2,4 +2,6 @@
require "rscons/cli" require "rscons/cli"
Rscons::Cli.run(ARGV) if __FILE__ == $0
Rscons::Cli.run(ARGV)
end
-5
View File
@@ -1,5 +0,0 @@
Rscons::Environment.new do |env|
env.append('CPPPATH' => Rscons.glob('src/**'))
env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/')
env.Program('build_dir.exe', Rscons.glob('src/**/*.c'))
end
@@ -1,22 +0,0 @@
class MyObject < Rscons::Builder
def run(target, sources, cache, env, vars)
env.run_builder(env.builders["Object"], target, sources, cache, vars)
end
end
Rscons::Environment.new(echo: :command) do |env|
env.add_builder(MyObject.new)
env.append('CPPPATH' => Rscons.glob('src/**'))
env.add_build_hook do |build_op|
if build_op[:builder].name == "MyObject" && build_op[:sources].first =~ %r{one\.c}
build_op[:vars]["CFLAGS"] << "-O1"
build_op[:sources] = ['src/two/two.c']
elsif build_op[:builder].name == "MyObject" && build_op[:target] =~ %r{two\.o}
new_vars = build_op[:vars].clone
new_vars["CFLAGS"] << "-O2"
build_op[:vars] = new_vars
end
end
env.MyObject('one.o', 'src/one/one.c')
env.MyObject('two.o', 'src/two/two.c')
end
@@ -1,6 +0,0 @@
env = Rscons::Environment.new do |env|
env.append('CPPPATH' => Rscons.glob('src/**/*/'))
env.build_dir("src", "build")
env.build_root = "build_root"
env.Program('build_dir.exe', Rscons.glob('src/**/*.c'))
end
-12
View File
@@ -1,12 +0,0 @@
Rscons::Environment.new(echo: :command) do |env|
env.append('CPPPATH' => Rscons.glob('src/**/*/'))
env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/')
env.add_build_hook do |build_op|
if build_op[:target] =~ %r{build_one/.*\.o}
build_op[:vars]["CFLAGS"] << "-O1"
elsif build_op[:target] =~ %r{build_two/.*\.o}
build_op[:vars]["CFLAGS"] << "-O2"
end
end
env.Program('build_hook.exe', Rscons.glob('src/**/*.c'))
end
-8
View File
@@ -1,8 +0,0 @@
Rscons::Environment.new(echo: :command) do |env|
env.append('CPPPATH' => Rscons.glob('src/**').sort)
env.build_root = "build_root"
FileUtils.mkdir_p(env.build_root)
FileUtils.mv("src/one/one.c", "build_root")
env.Object("^/one.o", "^/one.c")
env.Program("build_dir.exe", Rscons.glob('src/**/*.c') + ["^/one.o"])
end
-3
View File
@@ -1,3 +0,0 @@
Rscons::Environment.new do |env|
env.Copy("inst.exe", "copy.rb")
end
-6
View File
@@ -1,6 +0,0 @@
Rscons::Environment.new do |env|
env["CSUFFIX"] = %w[.yargh .c]
env["CFLAGS"] += %w[-x c]
env["CPPPATH"] += Rscons.glob("src/**")
env.Program("build_dir.exe", Rscons.glob("src/**/*.{c,yargh}"))
end
@@ -1,5 +0,0 @@
Rscons::Environment.new do |env|
env.echo = :command
env.Install("inst.exe", "install.rb")
end
@@ -1,13 +0,0 @@
class MyBuilder < Rscons::Builder
def run(options)
env, target = options.values_at(:env, :target)
env.print_builder_run_message("MyBuilder #{target}", "MyBuilder #{target} command")
target
end
end
Rscons::Environment.new do |env|
env.echo = :command
env.add_builder(MyBuilder.new)
env.MyBuilder("foo")
end
-3
View File
@@ -1,3 +0,0 @@
Rscons::Environment.new do |env|
env.Install("inst.exe", "install.rb")
end
@@ -1,9 +0,0 @@
Rscons::Environment.new do |env|
env.Directory("inst")
env.Install("inst", "install_directory.rb")
env.Install("noexist/src", "src")
env.Directory("exist/src")
env.Install("exist/src", "src")
end
@@ -1,5 +0,0 @@
Rscons::Environment.new do |env|
env["CPPPATH"] << "src/two"
env.Object("one.o", "src/one/one.c")
env.Object("one.o", "src/two/two.c")
end
@@ -1,6 +0,0 @@
Rscons::Environment.new do |env|
env.append('CPPPATH' => Rscons.glob('src/**'))
env.build_dir("src2", "build")
env.build_root = "build_root"
env.Program('build_dir.exe', Rscons.glob('src/**/*.c'))
end
@@ -1,10 +0,0 @@
Rscons::Environment.new do |env|
env["CPPPATH"] << "src/two"
env.Object("one.o", "src/one/one.c")
env.add_post_build_hook do |build_op|
if build_op[:target] == "one.o"
env["MODULE"] = "two"
env.Object("${MODULE}.o", "src/${MODULE}/${MODULE}.c")
end
end
end
-6
View File
@@ -1,6 +0,0 @@
Rscons::Environment.new do |env|
env.append("CPPPATH" => Rscons.glob("src/**"))
env.build_dir("src/one/", "build_one/")
env.build_dir("src/two", "build_two")
env.Program("build_dir.exe", Rscons.glob("src/**/*.c"))
end
+6
View File
@@ -0,0 +1,6 @@
build do
Environment.new do |env|
env.CFile("lexer.c", "lexer.l")
env.CFile("parser.c", "parser.y")
end
end
-4
View File
@@ -1,4 +0,0 @@
Rscons::Environment.new do |env|
env.CFile("lexer.c", "lexer.l")
env.CFile("parser.c", "parser.y")
end
+4 -2
View File
@@ -1,3 +1,5 @@
Rscons::Environment.new do |env| build do
env.CFile("file.c", "foo.bar") Environment.new do |env|
env.CFile("file.c", "foo.bar")
end
end end
+12
View File
@@ -0,0 +1,12 @@
build do
debug = Environment.new(echo: :command) do |env|
env['CFLAGS'] = '-O2'
env['CPPFLAGS'] = '-DSTRING="Debug Version"'
env.Program('program-debug.exe', Dir['src/*.c'])
end
release = debug.clone do |env|
env["CPPFLAGS"] = '-DSTRING="Release Version"'
env.Program('program-release.exe', Dir['src/*.c'])
end
end
-12
View File
@@ -1,12 +0,0 @@
debug = Rscons::Environment.new(echo: :command) do |env|
env.build_dir('src', 'debug')
env['CFLAGS'] = '-O2'
env['CPPFLAGS'] = '-DSTRING="Debug Version"'
env.Program('program-debug.exe', Dir['src/*.c'])
end
release = debug.clone do |env|
env["CPPFLAGS"] = '-DSTRING="Release Version"'
env.build_dir('src', 'release')
env.Program('program-release.exe', Dir['src/*.c'])
end
+13 -12
View File
@@ -1,15 +1,16 @@
env1 = Rscons::Environment.new(echo: :command) do |env| build do
env.build_dir('src', 'build') env1 = Environment.new(echo: :command) do |env|
env['CFLAGS'] = '-O2' env['CFLAGS'] = '-O2'
env.add_build_hook do |build_op| env.add_build_hook do |builder|
build_op[:vars]['CPPFLAGS'] = '-DSTRING="Hello"' 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 |build_op|
$stdout.puts "post #{build_op[: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
+3
View File
@@ -0,0 +1,3 @@
configure do
check_c_compiler "nope.nope"
end
+1
View File
@@ -0,0 +1 @@
autoconf false
+10
View File
@@ -0,0 +1,10 @@
configure do
check_c_compiler
check_c_header "stdio.h"
end
build do
Environment.new do |env|
env.Program("simple.exe", "simple.c")
end
end
@@ -0,0 +1,3 @@
configure do
check_c_compiler
end
@@ -0,0 +1,3 @@
configure do
check_c_compiler "mycompiler"
end
@@ -0,0 +1,3 @@
configure do
check_c_compiler "gcc", "clang"
end
@@ -0,0 +1,3 @@
configure do
check_c_header "not___found.h"
end
@@ -0,0 +1,3 @@
configure do
check_c_header "not___found.h", fail: false
end
@@ -0,0 +1,9 @@
configure do
check_c_header "not___found.h", fail: false, set_define: "HAVE_NOT___FOUND_H"
end
build do
Environment.new(echo: :command) do |env|
env.Object("simple.o", "simple.c")
end
end
@@ -0,0 +1,3 @@
configure do
check_c_header "string.h"
end
@@ -0,0 +1,9 @@
configure do
check_c_header "string.h", set_define: "HAVE_STRING_H"
end
build do
Environment.new(echo: :command) do |env|
env.Object("simple.o", "simple.c")
end
end
+9
View File
@@ -0,0 +1,9 @@
configure do
check_cfg program: "my-config"
end
build do
Environment.new(echo: :command) do |env|
env.Program("myconfigtest", "simple.c")
end
end
@@ -0,0 +1,9 @@
configure do
check_cfg package: "mypackage"
end
build do
Environment.new(echo: :command) do |env|
env.Program("myconfigtest", "simple.c")
end
end
+15
View File
@@ -0,0 +1,15 @@
configure do
check_cfg package: "mypackage", use: "myp"
end
build do
Environment.new(echo: :command) do |env|
env.Copy("myconfigtest1.c", "simple.c")
env.Program("myconfigtest1.exe", "myconfigtest1.c")
end
Environment.new(echo: :command, use: "myp") do |env|
env.Copy("myconfigtest2.c", "simple.c")
env.Program("myconfigtest2.exe", "myconfigtest2.c")
end
end
@@ -0,0 +1,3 @@
configure do
check_cxx_compiler
end
@@ -0,0 +1,3 @@
configure do
check_cxx_compiler "mycompiler"
end
@@ -0,0 +1,3 @@
configure do
check_cxx_compiler "g++", "clang++"
end
@@ -0,0 +1,3 @@
configure do
check_cxx_header "not___found.h"
end
@@ -0,0 +1,3 @@
configure do
check_cxx_header "not___found.h", fail: false
end
@@ -0,0 +1,3 @@
configure do
check_cxx_header "string.h"
end
@@ -0,0 +1,3 @@
configure do
check_d_compiler
end
@@ -0,0 +1,3 @@
configure do
check_d_compiler "mycompiler"
end
@@ -0,0 +1,3 @@
configure do
check_d_compiler "gdc", "ldc2"
end
@@ -0,0 +1,3 @@
configure do
check_d_import "not.found"
end
@@ -0,0 +1,3 @@
configure do
check_d_import "not.found", fail: false
end
@@ -0,0 +1,3 @@
configure do
check_d_import "std.stdio"
end
@@ -0,0 +1,3 @@
configure do
check_lib "mfoofoo"
end
@@ -0,0 +1,3 @@
configure do
check_lib "mfoofoo", fail: false
end
@@ -0,0 +1,9 @@
configure do
check_lib "m"
end
build do
Environment.new(echo: :command) do |env|
env.Program("simple.exe", "simple.c")
end
end
+15
View File
@@ -0,0 +1,15 @@
configure do
check_lib "m", use: :m
end
build do
Environment.new(echo: :command) do |env|
env.Copy("test1.c", "simple.c")
env.Program("test2.exe", "test1.c")
end
Environment.new(echo: :command, use: %w[m]) do |env|
env.Copy("test2.c", "simple.c")
env.Program("test2.exe", "test2.c")
end
end
@@ -0,0 +1,10 @@
configure do
check_lib "m", use: false
end
build do
Environment.new(echo: :command) do |env|
env.Copy("test1.c", "simple.c")
env.Program("test2.exe", "test1.c")
end
end
@@ -0,0 +1,3 @@
configure do
check_program "program-that-is-not-found"
end
@@ -0,0 +1,3 @@
configure do
check_program "program-that-is-not-found", fail: false
end
@@ -0,0 +1,3 @@
configure do
check_program "find"
end
@@ -0,0 +1,3 @@
Environment.new do |env|
env.Object("simple.o", "simple.cc")
end
+13
View File
@@ -0,0 +1,13 @@
project_name "configure test"
autoconf false
configure do
check_c_compiler
check_cxx_compiler
check_d_compiler
check_cfg package: "mypackage"
check_c_header "stdio.h"
check_cxx_header "iostream"
check_d_import "std.stdio"
check_lib "m"
check_program "ls"
end
@@ -0,0 +1,10 @@
configure do
check_c_header "math.h", set_define: "HAVE_MATH_H"
check_c_header "stdio.h", set_define: "HAVE_STDIO_H"
end
build do
Environment.new(echo: :command) do |env|
env.Object("simple.o", "simple.c")
end
end
+1
View File
@@ -0,0 +1 @@
check_c_compiler "gcc"
+6
View File
@@ -0,0 +1,6 @@
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("This is a simple C program\n");
}
+18
View File
@@ -0,0 +1,18 @@
class MySource < Rscons::Builder
def run(options)
File.open(@target, 'w') do |fh|
fh.puts <<EOF
#define THE_VALUE 5678
EOF
end
true
end
end
build do
Environment.new do |env|
env.add_builder(MySource)
env.MySource('inc.h', [])
env.Program('program.exe', Dir['*.c'])
end
end
-16
View File
@@ -1,16 +0,0 @@
class MySource < Rscons::Builder
def run(target, sources, cache, env, vars)
File.open(target, 'w') do |fh|
fh.puts <<EOF
#define THE_VALUE 5678
EOF
end
target
end
end
Rscons::Environment.new do |env|
env.add_builder(MySource.new)
env.MySource('inc.h', [])
env.Program('program.exe', Dir['*.c'])
end
+11 -9
View File
@@ -1,10 +1,12 @@
Rscons::Environment.new 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.build_after("${build_root}/program.o", "${inc_c}") env["inc_c"] = "inc.c"
env.Program("program.exe", ["program.c", "inc.c"]) env.build_after("${build_root}/program.o", "${inc_c}")
env.Program("program.exe", ["program.c", "inc.c"])
end
end end
+11 -9
View File
@@ -1,18 +1,20 @@
class MySource < Rscons::Builder class MySource < Rscons::Builder
def run(target, sources, cache, env, vars) def run(options)
File.open(target, 'w') do |fh| File.open(@target, 'w') do |fh|
fh.puts <<EOF fh.puts <<EOF
#define THE_VALUE 678 #define THE_VALUE 678
EOF EOF
end end
target true
end end
end end
env = Rscons::Environment.new 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.new) 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
+20 -18
View File
@@ -1,28 +1,30 @@
class MySource < Rscons::Builder class MySource < Rscons::Builder
def run(target, sources, cache, env, vars) def run(options)
File.open(target, 'w') do |fh| File.open(@target, 'w') do |fh|
fh.puts <<EOF fh.puts <<EOF
#define THE_VALUE #{env.expand_varref("${the_value}")} #define THE_VALUE #{@env.expand_varref("${the_value}")}
EOF EOF
end end
target true
end end
end end
e1 = Rscons::Environment.new do |env| build do
env.add_builder(MySource.new) 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
@@ -0,0 +1,8 @@
build do
Environment.new do |env|
env.add_builder(:MyBuilder) do |options|
"hi"
end
env.MyBuilder("foo")
end
end
@@ -0,0 +1,8 @@
build do
Environment.new do |env|
env.add_builder(:MyBuilder) do |options|
wait_for(1)
end
env.MyBuilder("foo")
end
end
+12 -10
View File
@@ -1,19 +1,21 @@
class CHGen < Rscons::Builder class CHGen < Rscons::Builder
def run(target, sources, cache, env, vars) def run(options)
c_fname = target c_fname = @target
h_fname = target.sub(/\.c$/, ".h") h_fname = @target.sub(/\.c$/, ".h")
unless cache.up_to_date?([c_fname, h_fname], "", sources, env) unless @cache.up_to_date?([c_fname, h_fname], "", @sources, @env)
puts "CHGen #{c_fname}" puts "CHGen #{c_fname}"
File.open(c_fname, "w") {|fh| fh.puts "int THE_VALUE = 42;"} File.open(c_fname, "w") {|fh| fh.puts "int THE_VALUE = 42;"}
File.open(h_fname, "w") {|fh| fh.puts "extern int THE_VALUE;"} File.open(h_fname, "w") {|fh| fh.puts "extern int THE_VALUE;"}
cache.register_build([c_fname, h_fname], "", sources, env) @cache.register_build([c_fname, h_fname], "", @sources, @env)
end end
target true
end end
end end
Rscons::Environment.new do |env| build do
env.add_builder(CHGen.new) 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
+13 -11
View File
@@ -1,14 +1,16 @@
Rscons::Environment.new 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("${build_root}/program.o", "${inc_h}") env.depends("${build_root}/program.o", "${inc_h}")
env.Program("program.exe", ["program.c", "inc.c"]) env.Program("program.exe", ["program.c", "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
@@ -0,0 +1,21 @@
class MyBuilder < Rscons::Builder
def run(options)
if @thread
true
else
print_run_message("#{name} #{target}", nil)
@thread = Thread.new do
sleep 2
FileUtils.touch(@target)
end
wait_for(@thread)
end
end
end
build do
Environment.new do |env|
env.add_builder(MyBuilder)
env.MyBuilder("foo")
end
end
+5
View File
@@ -0,0 +1,5 @@
build do
Environment.new(echo: :command) do |env|
env.Program("hello-d.exe", glob("*.d"))
end
end
-3
View File
@@ -1,3 +0,0 @@
Rscons::Environment.new(echo: :command) do |env|
env.Program("hello-d.exe", Rscons.glob("*.d"))
end
+7
View File
@@ -0,0 +1,7 @@
build do
Environment.new(echo: :command) do |env|
env.Object("main.o", "main.d")
env.Object("mod.o", "mod.d")
env.Program("hello-d.exe", ["main.o", "mod.o"])
end
end
+5
View File
@@ -0,0 +1,5 @@
build do
Environment.new do |env|
env.Program("test.exe", glob("*.c"), direct: true)
end
end
+7
View File
@@ -0,0 +1,7 @@
build do
Environment.new do |env|
lib = env.SharedLibrary("mylib", ["two.c", "three.c"], direct: true)
program = env.Program("test.exe", "main.c", "LIBS" => ["mylib"], "LIBPATH" => ["."])
env.depends(program, lib)
end
end
+7
View File
@@ -0,0 +1,7 @@
#include "two.h"
int main(int argc, char * argv[])
{
two();
return 0;
}
+7
View File
@@ -0,0 +1,7 @@
#include "three.h"
#include <stdio.h>
void three(void)
{
printf("three\n");
}
+1
View File
@@ -0,0 +1 @@
void three(void);
+7
View File
@@ -0,0 +1,7 @@
#include "two.h"
#include "three.h"
void two(void)
{
three();
}
+1
View File
@@ -0,0 +1 @@
void two(void);
+5
View File
@@ -0,0 +1,5 @@
build do
Environment.new do |env|
env.Program('header.exe', Dir['*.c'])
end
end
-3
View File
@@ -1,3 +0,0 @@
Rscons::Environment.new do |env|
env.Program('header.exe', Dir['*.c'])
end
+17
View File
@@ -0,0 +1,17 @@
build do
Environment.new do |env|
require 'json'
require 'yaml'
env.add_builder(:JsonToYaml) do |params|
unless @cache.up_to_date?(@target, :JsonToYaml, @sources, @env)
@cache.mkdir_p(File.dirname(@target))
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
true
end
env.JsonToYaml('foo.yml', 'foo.json')
end
end
-15
View File
@@ -1,15 +0,0 @@
Rscons::Environment.new do |env|
require 'json'
require 'yaml'
env.add_builder(:JsonToYaml) do |target, sources, cache, env, vars|
unless cache.up_to_date?(target, :JsonToYaml, sources, env)
cache.mkdir_p(File.dirname(target))
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
target
end
env.JsonToYaml('foo.yml', 'foo.json')
end
+6
View File
@@ -0,0 +1,6 @@
build do
Environment.new(echo: :command) do |env|
env.Program('library.exe', ['lib.a', 'three.c'])
env.Library("lib.a", ['one.c', 'two.c'], 'CPPFLAGS' => ['-Dmake_lib'])
end
end
-4
View File
@@ -1,4 +0,0 @@
Rscons::Environment.new(echo: :command) do |env|
env.Program('library.exe', ['lib.a', 'three.c'])
env.Library("lib.a", ['one.c', 'two.c'], 'CPPFLAGS' => ['-Dmake_lib'])
end
@@ -0,0 +1,7 @@
build do
Environment.new do |env|
env.Program("library.exe", ["lib.a", "three.c"])
env.Object("two.o", "two.c")
env.Library("lib.a", ["one.c", "two.o"], 'CPPFLAGS' => ['-Dmake_lib'])
end
end
+5 -3
View File
@@ -1,4 +1,6 @@
Rscons::Environment.new(echo: :command) do |env| build do
env["ARCMD"] = %w[ar rcf ${_TARGET} ${_SOURCES}] Environment.new(echo: :command) do |env|
env.Library("lib.a", Rscons.glob("*.c")) env["ARCMD"] = %w[ar rcf ${_TARGET} ${_SOURCES}]
env.Library("lib.a", glob("*.c"))
end
end end
+5
View File
@@ -0,0 +1,5 @@
build do
Environment.new do |env|
env.Preprocess("pp", "foo.h")
end
end
-3
View File
@@ -1,3 +0,0 @@
Rscons::Environment.new do |env|
env.Preprocess("pp", "foo.h")
end
+13
View File
@@ -0,0 +1,13 @@
build do
Environment.new do |env|
env["CPPPATH"] << "src/lib"
libmine = env.SharedLibrary("mine", glob("src/lib/*.c"))
env.Program("test-shared.exe",
glob("src/*.c"),
"LIBPATH" => %w[.],
"LIBS" => %w[mine])
env.build_after("test-shared.exe", libmine)
env.Program("test-static.exe",
glob("src/**/*.c"))
end
end
-11
View File
@@ -1,11 +0,0 @@
Rscons::Environment.new do |env|
env["CPPPATH"] << "src/lib"
libmine = env.SharedLibrary("mine", Rscons.glob("src/lib/*.c"))
env.Program("test-shared.exe",
Rscons.glob("src/*.c"),
"LIBPATH" => %w[.],
"LIBS" => %w[mine])
env.build_after("test-shared.exe", libmine.to_s)
env.Program("test-static.exe",
Rscons.glob("src/**/*.c"))
end
@@ -1,6 +1,8 @@
Rscons::Environment.new 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
Loaded 100 of 231 files, more files were not shown because too many files have changed in this diff. Show more