Compare commits

..
515 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
josh 5cf77f1f58 v1.16.0 2018-08-24 09:24:03 -04:00
josh b4cc45c381 update documentation 2018-08-24 09:17:23 -04:00
josh 750506201f add github URL to README.md 2018-08-23 15:37:18 -04:00
josh 284312a21c support command-line variables - close #51 2018-08-23 14:58:08 -04:00
josh d081a4695f add shebang line to bin/rscons 2018-08-23 11:30:18 -04:00
josh c7f66694ab add Rscons.glob - close #50 2018-08-23 11:26:20 -04:00
josh 57de94a3fb improve debuggability of cache.up_to_date? - close #46 2018-08-23 10:10:05 -04:00
josh 53ba7dad41 allow passing a VarSet into cache methods - close #47 2018-08-22 16:32:05 -04:00
josh 8cb02a7e34 generate dependencies for D builds - close #49 2018-08-22 15:23:48 -04:00
josh dbbce9e476 update a few dependencies 2018-05-24 15:32:39 -04:00
josh 0dc3a90660 v1.15.0 2017-09-08 15:13:04 -04:00
josh d48c7587d6 add v1.15.0 release notes 2017-09-08 15:06:55 -04:00
josh 70d4740a69 split CHANGELOG.md out of README.md 2017-09-08 15:06:23 -04:00
josh aaae845d60 allow json 1.x or 2.x 2017-09-08 15:04:40 -04:00
josh e900e74342 v1.14.0 2017-08-03 15:55:54 -04:00
josh 62ae3f162d add v1.14.0 release notes 2017-08-03 15:55:38 -04:00
josh 099d26f33c Add Rscons::VarSet#values_at - close #45 2017-08-03 15:54:24 -04:00
josh 89562c584a Environment#print_builder_run_message should support string commands - close #44 2017-08-03 14:10:53 -04:00
josh a9aeaf2356 v1.13.0 2017-07-14 16:24:27 -04:00
josh 5409b3cb34 add v1.13.0 release notes 2017-07-14 16:24:04 -04:00
josh 6d04500c13 Add ability to record side-effect file production - close #43 2017-07-14 16:17:01 -04:00
josh 45e30662d2 add YARD comment for Rscons::Ansi to get to 100% coverage 2017-07-12 15:51:00 -04:00
josh 8f7e044bfd fix YARD @option tag 2017-07-12 15:50:13 -04:00
josh dbea6f0a26 v1.12.0 2017-07-11 16:16:01 -04:00
josh c923eb5c7c add v1.12.0 release notes 2017-07-11 16:14:49 -04:00
josh 529d9aacaa colorize a couple other builders' output messages 2017-07-11 16:12:38 -04:00
josh 65c1bac4f9 be more colorful - close #41 2017-07-11 13:52:01 -04:00
josh 775363ddbd cloned Environments should inherit n_threads - close #42 2017-07-11 10:29:25 -04:00
josh 2a96495e83 wait for in-progress subcommands to complete on build failure - close #39 2017-06-26 22:44:49 -04:00
josh 15e52e488c env.depends should imply env.build_after - close #40 2017-06-21 10:44:52 -04:00
josh c0b12132f0 1.11.1 release notes 2017-06-14 09:58:09 -04:00
josh 9141cf91e7 v1.11.1 2017-06-14 09:57:11 -04:00
josh 7f7e6ef3da fix circular build dependency detection logic 2017-06-14 09:56:51 -04:00
josh 60b3fdbcac update YARD documentation link 2017-06-14 09:12:13 -04:00
josh 5263ea03c6 v1.11.0 2017-06-14 08:56:21 -04:00
josh 6c91823ce2 v1.11.0 release notes 2017-06-14 08:54:57 -04:00
josh 8deb1eb6f8 Change default :clone option to :all to clone all Environment attributes 2017-06-14 08:53:28 -04:00
josh 6d6319799a add v1.10.1 release notes 2017-06-13 19:47:58 -04:00
josh 694642dfbd Allow overriding n_threads on a per-Environment level - close #34 2017-06-13 19:45:53 -04:00
josh 6dd70ff65e raise error when circular dependencies are found - close #38 2017-06-13 19:37:41 -04:00
josh eca01c38df Fix non-blocking thread-wait if Rscons.n_threads is set to 0 - close #37 2017-06-13 19:07:04 -04:00
josh 4ad6ce1d9c SHCFLAGS and SHCXXFLAGS should inherit non-SH flags by default - close #36 2017-06-13 18:41:47 -04:00
josh a49ebc486e env.build_after should expand paths - close #35 2017-06-13 18:38:47 -04:00
josh 74d19ea235 fix construction variable reference table OBJSUFFIX entries 2017-06-12 09:33:52 -04:00
josh d7a6d69a92 update v1.10.0 release notes 2017-06-12 09:33:13 -04:00
josh 11864eb55b v1.10.0 2017-06-10 00:50:43 -04:00
Michael Metivier 387c40176b Pre-build hooks do not respect modified key values for old-style builders 2017-06-09 19:50:12 -04:00
josh f1b24ee8ba minor formatting: replace missing space 2017-06-08 15:01:30 -04:00
josh ef3150db0f document construction variables and their default values in README.md 2017-06-08 14:58:55 -04:00
josh ed4fb8b681 expand README.md a bit 2017-06-08 14:10:42 -04:00
josh 3a3f6d6d27 add v1.10.0 release notes 2017-06-08 12:02:13 -04:00
josh 20affc0e1d fix SHLD spec for Windows 2017-06-08 12:01:50 -04:00
josh 010607d3b0 Rework builder features to be returned by Builder#features instead of taken into account by Builder#produces? 2017-06-08 11:07:01 -04:00
josh b7f609b7e8 add SHLIBPREFIX 2017-06-07 16:35:20 -04:00
josh 10d4c647b9 add spec for building a shared library using D 2017-06-07 15:22:20 -04:00
josh db2ec82a25 Add more integration tests for SharedLibrary and backwards compatibility 2017-06-07 13:02:51 -04:00
josh aa192d7567 bugfix: Object and SharedObject should respect vars when checking source suffixes 2017-06-07 09:52:11 -04:00
josh ed5d6e9e49 homogenize slashes in Environment#expand_path() 2017-06-07 09:26:13 -04:00
josh 3436dc3a64 Expand target and sources before calling Builder#create_build_target 2017-06-06 16:43:26 -04:00
josh df52a7e0e1 add SharedObject and SharedLibrary builders - close #8 2017-06-06 13:27:38 -04:00
josh 6bd7e6f852 Object builder changes in preparation for adding SharedObject 2017-05-30 16:26:39 -04:00
josh 19a23c2aa9 Create builder features
Pass desired features to Builder#produces?
Allow features to be passed in to Environment#register_builds.
Use features in Environment#get_build_fname to determine build file name.
2017-05-30 15:30:15 -04:00
josh c7e4e1ad9b Always use a build root and default it to "build" 2017-05-30 11:06:32 -04:00
josh 43df46018c Support redirecting standard output using the Command builder - close #28 2017-05-29 12:50:34 -04:00
josh 8cbb9fa30e Place object files for absolute source paths under build_root - close #30 2017-05-29 12:16:46 -04:00
josh 1880e6650e fix PROGSUFFIX handling - close #29 2017-05-29 11:40:01 -04:00
josh d31b4725d2 add LEXSUFFIX, YACCSUFFIX construction variables - close #31 2017-05-29 11:03:01 -04:00
josh 6f242a1c64 Merge branch 'parallelization' - close #23 2017-05-29 10:58:55 -04:00
josh c7943bc2cc ignore .bundle 2017-05-29 10:57:27 -04:00
josh b5826bd7f4 use new Builder#run signature for Command builder 2017-05-25 17:06:34 -04:00
josh 05bbea6fa1 add Environment#build_after 2017-05-25 17:00:21 -04:00
josh 68468b6422 fully parallelize the Command builder 2017-05-25 16:03:05 -04:00
josh 80a80a7cb0 fully parallelize the Preprocess builder 2017-05-25 15:54:33 -04:00
josh 178940cd5d fully parallelize the CFile builder 2017-05-25 15:28:01 -04:00
josh 145d51c825 fully parallelize the Disassemble builder 2017-05-25 14:59:51 -04:00
josh a11fab43cb Update spec task to preserve simplecov coverage info for previous full spec runs when doing a partial spec run 2017-05-24 16:29:17 -04:00
josh 83226e894d add backwards-compatibility test for Builder#standard_build 2017-05-24 16:16:53 -04:00
josh b454208117 fully parallelize the Library builder 2017-05-24 16:10:58 -04:00
josh df420fdf5c use ThreadsWait (only for blocking thread waits) 2017-05-24 16:02:25 -04:00
josh f3bf325c88 add a little more leeway in the multi-threading timing test 2017-05-24 15:58:11 -04:00
josh f815952ab3 add Builder#standard_threaded_build, #standard_finalize
parallelize Program builder command
2017-05-24 15:41:39 -04:00
josh 1af3c5c9a4 pass Builder#run options into Builder#finalize also 2017-05-24 15:13:59 -04:00
josh dce88ece14 pass entire build_operation Hash to Builder#run 2017-05-24 14:32:43 -04:00
josh 2655c119e4 add spec for Environment#find_finished_thread to fully cover 2017-05-23 16:47:00 -04:00
josh 221cde7e5f update run_builder, build_sources integration tests for more coverage 2017-05-23 16:45:21 -04:00
josh adcee373df add integration test for Environment#build_sources 2017-05-23 16:28:13 -04:00
josh e58b8bd109 add integration test for Environment#run_builder 2017-05-23 16:25:03 -04:00
josh 8a1dfb0785 do not catch NameError when looking up Builder#run method 2017-05-23 16:24:45 -04:00
josh d315f86a36 remove unit tests for Environment#run_builder, #build_sources 2017-05-23 16:20:41 -04:00
josh 0d46d616dd change user dependency test to use BuildTarget#depends 2017-05-23 16:09:29 -04:00
josh 032e6d5d0a add some integration tests for the CLI 2017-05-23 16:06:21 -04:00
josh c9946da193 integration tests: only pass -f when a specific rsconsfile is specified 2017-05-23 15:55:28 -04:00
josh 599d10b50f add integration test for overriding PROGSUFFIX 2017-05-23 15:32:55 -04:00
josh 18c6c69871 do not use ThreadsWait to wait for threads; it does not work properly 2017-05-23 15:24:52 -04:00
josh 2ffdf82d9a add multi-threading build test 2017-05-23 14:24:14 -04:00
josh 15e5d15424 Avoid Environment#process race condition
Race condition could have occurred if the last threaded command
was gathered in the non-blocking wait and then a blocking wait was
started because there was no job to run. Do not do a blocking wait
in this case.
2017-05-23 14:12:38 -04:00
josh a99e6e81b2 simplify Environment#process looping 2017-05-23 14:10:45 -04:00
josh 1509c95176 remove Cache.reset! 2017-05-23 14:05:29 -04:00
josh c7bba77581 remove Program builder non-integration specs 2017-05-22 16:57:35 -04:00
josh 957fd8c86d convert Library builder specs to integration tests 2017-05-22 16:54:10 -04:00
josh 7e707e7e3b convert Object builder specs to integration tests 2017-05-22 16:38:57 -04:00
josh 2be738be4f Including trailing newline when printing failed command 2017-05-22 16:26:12 -04:00
josh 7b3bffd329 update some non-integration-test specs 2017-05-22 16:25:49 -04:00
josh 06cb4b7a55 migrate some Cache tests to integration tests 2017-05-22 15:55:18 -04:00
josh bfbbc19728 fix simplecov setup to get coverage for integration build tests 2017-05-22 11:19:55 -04:00
josh 28e56251dd update build_tests_spec to invoke rscons in a subprocess for each test 2017-05-20 15:15:07 -04:00
josh 2d8e08b493 add -j command-line option to set number of threads 2017-05-19 11:38:42 -04:00
josh 5cef9896ac consistently print failed build command if a builder fails 2017-05-19 10:57:30 -04:00
josh 6344692087 update Object builder to support parallelization; update Program and Library builders to register object builds from #setup 2017-05-19 10:49:16 -04:00
josh 267fc7124d process threaded commands until they are all complete 2017-05-17 15:52:34 -04:00
josh e694199f33 delay building targets that depend on builds registered with Environment#register_builds 2017-05-17 15:45:04 -04:00
josh 4ed584701a pass setup_info to the builder's #run method 2017-05-17 13:50:31 -04:00
josh 5de52620e4 JobSet#get_next_job_to_run: take into account targets still building 2017-05-17 10:19:43 -04:00
josh 9cc59a35f0 handle threaded commands in Environment#process 2017-05-17 10:07:15 -04:00
josh ca445f5733 add JobSet#size 2017-05-17 09:36:27 -04:00
josh 7534b29e26 add Environment#wait_for_threaded_commands, use from #run_builder if delayed execution is not allowed 2017-05-17 09:34:19 -04:00
josh 800e7a51a4 add Environment#start_threaded_command 2017-05-17 09:14:42 -04:00
josh 5d36aa74a0 add more fields to ThreadedCommand 2017-05-17 09:07:51 -04:00
josh 01851c2872 refactor into new Environment#command_to_s 2017-05-17 09:04:05 -04:00
josh 5fe55a584e add short description field to ThreadedCommand 2017-05-17 08:49:53 -04:00
josh 9c13634eaf start adding support for threaded commands in Environment#run_builder 2017-05-17 08:47:17 -04:00
josh e4adaab003 add Builder#finalize 2017-05-16 09:18:08 -04:00
josh 6b8fda706d add ThreadedCommand class 2017-05-15 10:57:34 -04:00
josh ef4f9882cd change Builder#run base class method to new signature 2017-05-12 21:08:14 -04:00
josh 7a31039e35 add @since tags for new methods 2017-05-12 21:07:25 -04:00
josh 3e4897c04b store setup_info in the job 2017-05-12 16:30:30 -04:00
josh d46dc2014c update JobSet interface to just take a Hash of job parameters 2017-05-12 16:30:02 -04:00
josh 9cfc0c20b7 call Builder#setup 2017-05-12 16:27:43 -04:00
josh 19a00a7b84 prepare to call new Builder#run interface 2017-05-12 16:25:34 -04:00
josh 9b6d2c5111 add Environment#register_builds 2017-05-12 16:16:25 -04:00
josh 6a0ccad804 add Builder#setup; add new Builder#run signature 2017-05-12 16:16:07 -04:00
josh dab870854a add Rscons.n_threads 2017-05-12 14:38:18 -04:00
josh 695bf84092 expand target and source paths when registering a builder 2017-05-10 15:06:16 -04:00
josh 7cba8c8424 JobSet: target is already stored in job info 2017-05-10 14:57:04 -04:00
josh 551b8fa365 add integration test to verify cache is written if a builder fails 2017-02-16 19:27:18 -05:00
josh 3601359c08 process jobs from the JobSet 2017-02-16 19:27:18 -05:00
josh e1d8dfbab6 add JobSet class 2017-02-16 19:27:18 -05:00
josh c69da1044d update README for v1.9.3 2016-09-30 14:04:58 -04:00
josh f33be07a15 v1.9.3 2016-09-30 14:03:35 -04:00
josh c4c2d5c128 Environment#parse_flags should put -std=XXX flags in CCFLAGS, not CFLAGS 2016-09-30 14:02:30 -04:00
josh 3065dc48ec document passing multiple dependencies to env.depends() 2016-05-02 09:10:14 -04:00
josh 9ca2934695 document explicit dependencies 2016-03-02 13:33:00 -05:00
josh 3af6b6be1b v1.9.2 2016-01-12 10:16:00 -05:00
josh 0442b876a5 allow phony targets in conjunction with a build root 2016-01-12 10:14:10 -05:00
josh bab4641b6e v1.9.1 2015-12-10 15:25:29 -05:00
josh 4698fc41b9 add v1.9.1 release notes 2015-12-10 15:25:16 -05:00
josh 952f423860 use ${INCPREFIX} instead of hard-coded "-I" in Preprocess builder 2015-12-10 15:19:41 -05:00
josh d2da5f7b0d bundle update 2015-12-10 15:18:59 -05:00
josh ab14dc16ed change *SUFFIX defaults to arrays; add various C++ file suffixes 2015-06-15 21:58:37 -04:00
josh aa795eea85 v1.9.0 2015-03-15 20:56:37 -04:00
josh 7dffef6bd0 update README.md 2015-02-15 19:52:33 -05:00
josh dce2114733 document Copy builder class 2015-02-15 18:42:37 -05:00
josh 0bbdda2d41 fix Command builder default short description 2015-02-15 18:41:41 -05:00
josh 3b8910075a use class instance variables instead of class variables 2015-02-15 18:38:09 -05:00
josh 34beda844e reorganize Rscons module class methods 2015-02-15 18:33:00 -05:00
josh 7a04bec2ff support phony targets - close #25 2015-02-15 18:29:33 -05:00
josh 7698fbf618 add "rscons" binary - close #24 2015-02-08 18:04:37 -05:00
josh 4eedea2563 add Copy builder as a copy of Install 2015-02-07 09:57:44 -05:00
josh f678803a5d add Install builder - close #6 2015-02-07 09:49:29 -05:00
josh 9c49a09f69 update :spec rake task to allow example pattern as an argument 2015-01-29 09:58:09 -05:00
josh 859f87ddee add a Directory builder - close #27 2015-01-29 09:31:00 -05:00
josh 73bc71a656 test expanding paths after a build target is registered from within a build hook 2015-01-28 17:15:55 -05:00
josh 29a8684f90 support registering multiple build targets with the same path - close #26 2015-01-28 17:10:36 -05:00
josh 02aff35222 allow overriding Command builder short description with CMD_DESC variable -- close #22 2015-01-24 09:40:07 -05:00
josh 897d31ebe0 fix Command builder example invocation 2015-01-21 14:07:28 -05:00
josh 76610a07a9 fix variable references that expand to arrays in build target sources - fix #20 2015-01-20 21:26:45 -05:00
josh cb3cc9a0de update 1.9.0 release notes 2015-01-20 21:18:19 -05:00
josh 0ea842fffe rework Preprocess builder to consider deep dependencies - fix #21 2015-01-20 21:16:21 -05:00
josh d28722a4bb fix Rscons.set_suffix to append the given suffix if the filename has none 2015-01-20 21:13:27 -05:00
josh 8142d0bbc8 add v1.8.1 release notes 2015-01-20 21:12:57 -05:00
josh a8023ae03c v1.8.1 2014-10-22 14:30:32 -04:00
josh 99ba015630 fix Environment#dump when construction variables are Symbols 2014-10-22 14:30:14 -04:00
josh dcf90cc12b v1.8.0 2014-10-22 10:36:28 -04:00
josh f93ca62c07 add v1.8.0 release notes 2014-10-22 10:31:52 -04:00
josh d9e3129ad5 add Environment#dump 2014-10-22 10:30:57 -04:00
josh d5e0475e6c minor documentation improvements 2014-10-21 17:00:38 -04:00
josh b05eed36eb add VarSet#to_h 2014-10-21 16:06:15 -04:00
josh 7ea0721cc2 add a Builder#run method which raises an error unless overridden 2014-10-16 16:52:26 -04:00
josh e654df008d add rdoc to bundle 2014-10-16 16:42:03 -04:00
Michael D. Lowis 92d4dd8396 Implemented SimpleBuilder and updated Environment#add_builder method to support it 2014-10-16 16:37:37 -04:00
Michael D. Lowis e279959d79 Added a command builder to the list of default builders 2014-10-13 12:27:05 -04:00
josh 469f575564 v1.7.0 2014-09-25 11:35:00 -04:00
josh 07725581e9 add v1.7.0 release notes 2014-09-25 11:34:37 -04:00
josh ebb69cedc2 add @since tag to Environment#add_post_build_hook 2014-09-25 11:31:18 -04:00
josh c98b377ce8 use "rake/clean" module now that it isn' so noisy; clean .yardoc folder 2014-09-25 11:14:39 -04:00
josh a0874e7cf1 add tests for *SUFFIX variables containing Arrays - close #9 2014-09-25 11:12:11 -04:00
josh 0b04229e3d fix Environment#build_dir documentation 2014-09-25 10:47:21 -04:00
josh 20f3da3b04 allow trailing slashes to be passed to env.build_dir() 2014-09-25 10:45:52 -04:00
josh a6a79b8ef1 test cloning post-build hooks 2014-09-23 12:44:02 -04:00
josh 6d4f27602e update README.md notes about build hooks 2014-09-19 12:41:54 -04:00
josh 453295a49b add post-build hooks - close #14 2014-09-19 12:36:57 -04:00
josh dee2b98f6e allow build hooks to register new build targets - close #15 2014-09-19 11:10:59 -04:00
josh b186b3102c clear build targets after processing an Environment - close #17 2014-09-19 10:45:49 -04:00
josh 23c94f7841 fix YARD curly brace escapes 2014-09-11 13:53:10 -04:00
josh 6acb209ef4 v1.6.1 2014-08-19 09:12:35 -04:00
josh 43e12819d7 update .gitignore, version Gemfile.lock 2014-08-19 09:12:21 -04:00
josh 1bfb7dd100 add v1.6.1 release notes 2014-08-19 09:09:37 -04:00
josh df1e3be829 fix #12 - allow overriding dependency file suffix with DEPFILESUFFIX construction variable 2014-08-18 15:53:02 -04:00
josh 851adae66f fix #13 - Environment#depends should expand its arguments for construction variables 2014-08-18 15:39:33 -04:00
josh eb28e09d8c add v1.6.0 release notes 2014-07-10 14:34:35 -04:00
josh 01a84e8819 v1.6.0 2014-06-18 10:45:05 -04:00
josh 28bedfce11 Support lambdas as construction variable values 2014-06-18 10:43:35 -04:00
josh e792fd473b add v1.5.0 release notes 2014-06-18 09:15:49 -04:00
josh 9f738ee175 v1.5.0 2014-06-16 22:20:06 -04:00
josh 912615535a added more documentation to get to 100% YARD coverage; fix YARD warnings 2014-06-16 15:33:22 -04:00
josh d87c4990b1 add redcarpet to bundle 2014-06-16 14:40:43 -04:00
josh 6a17cbcd54 remove unnecessary rspec dependencies 2014-06-16 14:37:24 -04:00
josh 8fc95b5d69 change Builder#create_build_target and BuildTarget#initialize to accept a Hash of options 2014-06-16 12:17:33 -04:00
josh d9eea10363 update D build test for Linux 2014-06-12 16:00:41 -04:00
josh 5045e2e336 fix build test for Linux 2014-06-12 15:59:49 -04:00
josh 31968e7e32 complete spec updates for RSpec 3 using only :expect syntax 2014-06-12 15:52:15 -04:00
josh 5783ed993a update more rspec expectations 2014-06-12 15:43:50 -04:00
josh 0778f043ee update many specs to RSpec 3 format 2014-06-12 15:39:20 -04:00
josh 42597b2dac use new rspec expect syntax 2014-06-12 13:54:35 -04:00
josh 7b13d51d23 environment spec updates for Windows 2014-06-12 13:41:46 -04:00
josh c2d4ece957 build test spec fix for running on Windows 2014-06-12 13:38:15 -04:00
josh 3ab9c8723b fix a build test for MinGW 2014-06-12 13:35:11 -04:00
josh 1b50a9dd3c add Rscons::BuildTarget
Return a BuildTarget object from Environment#method_missing when a build target is registered.
2014-06-12 13:31:17 -04:00
josh 87b25d7bfd add PROGSUFFIX construction variable and default it to ".exe" for mingw/cygwin platforms 2014-06-12 13:02:53 -04:00
josh da457b9138 fix spec typo 2014-06-12 11:31:56 -04:00
josh 0cbf05da49 retry directory removal to work around Windows' inability to remove directories when you ask 2014-06-12 11:31:17 -04:00
josh 08b8a2e6be update gemspec, do not use git to determine files 2014-06-12 11:13:56 -04:00
josh 9f75ea9d21 add Rscons.command_executer to determine command executer
Use "env" to execute commands when in MSYS on Windows
2014-06-12 11:07:09 -04:00
josh ef18c9da35 Environment: add #parse_flags, #parse_flags!, and #merge_flags 2014-06-12 10:40:01 -04:00
josh 7c9e7e833a Unbuffer $stdout 2014-06-12 09:36:24 -04:00
josh eb9aa476b7 update default construction variables to match SCons a little more closely 2014-06-11 16:54:32 -04:00
josh 7f2b685bfb shorten Environment#shell code a bit 2014-06-11 15:31:13 -04:00
josh ae9021a505 add Environment#shell - close #11 2014-06-11 14:59:31 -04:00
josh a1a4cc18cd change json to a runtime gem dependency 2014-06-05 09:19:59 -04:00
josh f5a3b448d3 test supported construction variable types when cloning 2014-05-15 15:54:02 -04:00
josh 9abb47ffe7 v1.4.3 2014-05-14 15:53:52 -04:00
josh f78d13b648 add v1.4.3 release notes 2014-05-14 15:53:33 -04:00
josh ab1ea34941 add specs testing construction variable overrides for built-in builders 2014-05-14 15:48:00 -04:00
josh 08f2248ed7 fix up builders to properly use variable overrides 2014-05-14 15:15:08 -04:00
josh 9d61fa0276 merge Environment#build_command and #expand_varref 2014-05-14 14:33:09 -04:00
josh c0adb64c5d v1.4.2 2014-05-09 10:32:22 -04:00
josh 95da14e029 add release notes in README.md 2014-05-09 10:31:54 -04:00
josh 58b41df426 expand target and sources for construction variable references before invoking builder 2014-05-09 09:45:29 -04:00
josh bd525e2742 rename Environment#clean_target_paths! -> #expand_paths! 2014-05-09 09:19:40 -04:00
josh c08a2243b9 add Environment#expand_path 2014-05-05 16:22:07 -04:00
josh 0de1e8e970 v1.4.1 2014-04-17 12:03:29 -04:00
josh 6f20a1da3f bugfix: support invoking builders with no sources and a build root defined 2014-04-17 12:03:09 -04:00
josh 03ffb39956 v1.4.0 2014-04-15 16:19:19 -04:00
josh 0a10af3f5e update README.md for v1.4.0 release notes 2014-04-15 16:18:58 -04:00
josh ddf00d08a7 shortcut all of Environment#process if @targets is empty 2014-04-15 16:18:33 -04:00
josh 8be1842cf8 update documentation for new builders 2014-04-15 16:06:00 -04:00
josh d424facf7f Add Preprocess and Disassemble builders 2014-04-15 15:21:55 -04:00
josh ee5aca275d Write Cache to disk if an exception occurs while processing the Environment - fix #4 2014-04-15 14:20:30 -04:00
josh ea30b0b5ee Fix Cache#mkdir_p to handle absolute paths - fix #5 2014-04-15 14:15:32 -04:00
josh 5a0d80b781 Cache: implement "dirty" attribute to only re-serialize when necessary 2014-04-15 14:11:10 -04:00
josh a2653a77d1 shortcut Environment#process if @targets is empty 2014-04-15 14:04:59 -04:00
josh 160434b903 Cache: change to a Singleton object so it is only loaded from disk once 2014-04-15 14:02:26 -04:00
josh 5ce8940d54 stop encoding Cache contents 2014-04-15 13:39:45 -04:00
josh 1a5e9ddaa6 Implement copy-on-write semantics for VarSet, speeding up Environment cloning 2014-04-15 11:21:15 -04:00
josh 5924154229 speed up VarSet#deep_dup a bit 2014-04-15 09:47:05 -04:00
josh 5beda54374 do not clone @varset when appending to the cloned environment since appending will do its own clone 2014-04-15 09:36:30 -04:00
josh ae0ad98075 use @varset.append() instead of @varset.send(:append) 2014-04-15 09:32:35 -04:00
josh f5be3a3571 VarSet: implement deep copying ourselves instead of using Marshal for a speed increase 2014-04-15 09:16:30 -04:00
josh fdc5c8773c Issue #7 - store MD5 of build command instead of the full command in the cache 2014-04-14 17:17:54 -04:00
josh c61380b354 Issue #7 - change .rsconscache from using YAML to JSON to speed up parsing 2014-04-14 16:52:21 -04:00
josh d8dda291a5 ensure that Dir[] results are predictable in build tests 2014-04-14 13:13:43 -04:00
josh 1fe2c6401d expand ^/ in target paths to be relative to the build root 2014-03-27 13:30:11 -04:00
josh 4818fd10fe README.md: add more details about Environment cloning 2014-03-27 12:02:46 -04:00
josh 5989e24ee6 update some documentation 2014-03-27 11:57:45 -04:00
josh 1875a2ea66 Pass the Environment object to build hooks in the :env key of the build_op parameter 2014-03-27 10:44:10 -04:00
josh cbd5816b4b add VarSet#include? 2014-03-27 10:39:46 -04:00
josh b2c970c9ca add Environment#add_target and use it from Environment#method_missing 2014-03-26 11:29:02 -04:00
josh 92a9982988 use #super from #method_missing instead of method aliasing 2014-03-26 11:23:32 -04:00
josh 533ee9c16c add CFile builder to create C/C++ sources from lex/yacc input files 2014-03-18 21:57:53 -04:00
josh 831b9bf2c7 v1.3.0 2014-02-25 12:18:02 -05:00
josh 031395bb57 add v1.3.0 release notes 2014-02-25 12:17:49 -05:00
josh e3aeb7f4d7 Change Environment#execute() options Hash to contain :env and :options keys for Kernel#system() 2014-02-25 12:14:52 -05:00
josh 6aa5037234 v1.2.0 2014-02-20 16:42:10 -05:00
josh 0d8f661fd4 add :clone option to Environment#clone to control exactly which Environment attributes are cloned 2014-02-19 15:02:46 -05:00
josh e5ca8776a9 allow nil to be passed in to Environment#build_root= 2014-02-19 15:02:18 -05:00
josh 2dde39a0ec standardize on "Rscons" capitalization 2014-02-18 16:14:44 -05:00
josh af0679708c v1.1.0 2014-02-17 16:37:59 -05:00
josh 4b0d0c3957 README: add Release Notes section 2014-02-17 16:15:49 -05:00
josh 202f10b86f README: add example for custom builder with multiple output files 2014-02-17 16:14:10 -05:00
josh 1d47db3144 support passing multiple targets to Cache#up_to_date? and #register_build 2014-02-17 16:10:15 -05:00
josh f7b7a4fefa v1.0.0 2014-02-14 10:46:31 -05:00
josh 00b038ef50 use require_relative instead of require 2014-02-14 10:37:41 -05:00
josh 98f8f38715 remove String#set_suffix monkey patch 2014-02-14 10:36:15 -05:00
josh 2ffb5d525a remove String#absolute_path? monkey patch 2014-02-14 10:32:57 -05:00
josh fa7d17675b remove String#has_suffix? monkey-patch; use String#end_with? 2014-02-14 10:20:32 -05:00
josh b43c473762 README: add link to API documentation at rubydoc.info 2014-02-14 09:57:46 -05:00
josh f278b211f7 README: add more information about custom builders 2014-02-14 09:50:39 -05:00
josh c897bcf06e README.md fixes/tweaks 2014-02-14 09:42:04 -05:00
josh 7c89dddbd6 v0.3.1 2014-01-23 14:40:45 -05:00
josh c07d9f86a6 bugfix: loading a Cache without deps or user_deps stored causes an exception 2014-01-23 14:40:30 -05:00
josh ff26da8865 fix custom builder examples in README.md 2014-01-15 16:57:46 -05:00
josh 5ff555cf6a add Environment#expand_varref() 2014-01-02 11:49:08 -05:00
josh e3aadc562f Rscons::Varset: remove unused type parameter to #[] 2014-01-02 11:05:15 -05:00
josh 7ff2ec1f1a v0.3.0 2013-12-31 14:10:47 -05:00
josh 5362f761e6 move default builder classes into Rscons::Builders namespace module 2013-12-31 13:31:17 -05:00
josh cdb3352b4e remove module monkey-patching; add Builder#name() 2013-12-31 13:10:00 -05:00
josh 08bc390d40 Rscons::BuildError inherits from RuntimeError instead of Exception 2013-12-31 13:08:38 -05:00
josh f8af0630b0 pass env to Cache#up_to_date?() and #register_build() instead of user_deps 2013-12-31 12:46:30 -05:00
josh 1868193b54 do not prepend build_root to source files that are already inside build_root 2013-12-31 10:15:19 -05:00
josh 8976d7dea2 update README custom builder examples 2013-12-27 15:01:02 -05:00
josh 295324eafd add Environment#depends() to specify user dependencies for a build target 2013-12-27 14:31:46 -05:00
josh 7330e74ab8 modify Cache to store user-specified extra dependencies 2013-12-27 14:20:32 -05:00
josh a28cef9eb7 change "vars" parameters to be required 2013-12-27 13:53:40 -05:00
josh e667046da8 add Environment#clear_targets() 2013-12-27 13:35:16 -05:00
josh 539a49fe90 do not allow construction variables as arguments to Environment#initialize() or Environment#clone() 2013-12-27 12:10:54 -05:00
josh 7681c7584f add String#absolute_path? 2013-12-27 11:40:24 -05:00
josh 8fcbd39057 v0.2.2 2013-11-13 23:52:33 -05:00
josh d0bbc78751 Program: do not continue executing builder if building a source fails 2013-11-13 23:52:15 -05:00
josh 7249e57951 add info to error message when expanding unknown variable types 2013-11-13 23:50:46 -05:00
josh d01913641f v0.2.1 2013-11-11 11:36:10 -05:00
josh d5be569cd5 fix Environment#clone() to allow subclassing 2013-11-11 11:35:59 -05:00
josh 4d7ed373e7 v0.2.0 2013-11-08 15:45:35 -05:00
josh 72558391a2 clarify documentation about cloning Environments 2013-11-08 15:45:24 -05:00
josh d01767981c add Environment#build_root to be used if no build directories match 2013-11-08 14:52:39 -05:00
josh 01c847fa32 v0.1.0 2013-11-06 13:38:59 -05:00
josh 20f509ec27 rename *COM construction variables to *CMD 2013-11-06 13:35:41 -05:00
josh 243eb9a4ab rename "tweakers" to "build hooks" 2013-11-06 13:32:56 -05:00
josh 49be46199f define our own clean/clobber tasks 2013-11-06 13:29:24 -05:00
josh c9b670ae5c change default "echo" setting to :short 2013-11-06 13:22:30 -05:00
josh 6bcb984e8e README: add gem version badge 2013-11-06 13:18:09 -05:00
josh b377940252 begin expanding README documentation 2013-11-06 12:45:50 -05:00
josh 2e0c2688aa VarSet#expand_varref(): fix recursive expansion 2013-11-05 17:06:09 -05:00
josh 66f53a23f6 change construction variable reference format to ${var}
this change is backwards-incompatible
2013-11-05 16:54:01 -05:00
josh 545b893ef4 clean up a couple YARD warnings 2013-11-05 16:37:18 -05:00
josh 30564af558 add build test for D 2013-11-05 16:29:15 -05:00
josh cc2c2733fc move build_tests_spec.rb back into spec, remove build_tests rake task 2013-11-05 16:22:09 -05:00
josh ddb5357b02 explicitly set LD construction variable in one build test 2013-11-05 16:19:02 -05:00
josh b805e5379f execute all build tests in the top-level rake context instead of spawning subprocesses 2013-11-05 16:11:08 -05:00
josh 71344b4782 Program: do not check env.build_sources() return value (it will raise an exception if something was wrong) 2013-11-05 15:41:47 -05:00
josh b1cdd3d1db Object: simplify handling of known suffixes 2013-11-05 15:25:10 -05:00
josh ed11b05b97 add rscons_spec.rb 2013-11-05 14:37:26 -05:00
josh a418d31000 finish up Environment specs 2013-11-05 14:28:43 -05:00
josh 797580e937 Environment: remove support for specifying :builders key in constructor 2013-11-05 14:18:02 -05:00
josh 8b852bd2fd Environment: more specs 2013-11-05 14:14:03 -05:00
josh e863c9a564 Environment: rework process()
- improve efficiency
- give errors for the dependency that failed instead of the top-level target
2013-11-05 12:43:50 -05:00
josh 7ce5a8f9d9 working on Environment specs 2013-11-05 12:26:42 -05:00
josh 1280cfb465 change Environment#parse_makefile_deps() to a class method 2013-11-05 11:44:07 -05:00
josh 0cd9dbd1bd add separate spec_helper.rb for build_tests directory 2013-11-05 11:36:30 -05:00
josh b38c56d446 move build_tests_spec.rb to build_tests directory; add build_tests task 2013-11-05 11:05:45 -05:00
josh d2b7c93f53 rename Rakefile -> Rakefile.rb 2013-11-05 10:52:56 -05:00
josh 67922b887d remove Environment#targets() and Environment#target_sources() which didn't seem to be used 2013-11-05 10:42:01 -05:00
josh 8100830c16 spec Cache 2013-11-05 10:25:36 -05:00
josh cb629bf7ec do not include spec files in simplecov report 2013-11-05 10:25:34 -05:00
josh 65a5838605 Cache: set :version when writing to file 2013-11-05 09:22:46 -05:00
josh 338a49ba9c v0.0.14 2013-10-29 16:18:14 -04:00
josh c23bb8c5e0 add support for building D sources (defaulting to gdc) 2013-10-29 16:17:51 -04:00
josh 31abeed3d5 v0.0.13 2013-10-15 16:29:54 -04:00
josh 446fef931f add "tweakers" functionality
tweakers allow the user to modify construction variables before any build is performed
2013-10-15 16:15:37 -04:00
josh 4a2997feec VarSet: make a deep copy of values passed to VarSet#append() 2013-10-15 16:10:56 -04:00
josh 013995bbc0 refactor into Environment#run_builder() 2013-10-15 13:36:25 -04:00
josh cd266c511e v0.0.12 2013-10-08 11:54:38 -04:00
josh 0f5fee359d cloning an Environment should make a deep copy of its construction variables 2013-10-08 11:54:24 -04:00
josh dc6bac2895 change build_dir build test to test build_dir specified as a Regexp 2013-10-04 21:40:11 -04:00
josh e50aac31c9 tweak custom_builder build test for additional coverage 2013-10-04 21:26:51 -04:00
josh e788f6ec25 claim simplecov coverage from build_tests 2013-10-04 21:05:44 -04:00
josh 8d893d7b72 rspec Module monkey-patching 2013-10-04 20:22:37 -04:00
josh c258dc379f rspec VarSet 2013-10-04 20:18:40 -04:00
josh 0facfb274d turn on simplecov 2013-10-04 19:37:56 -04:00
josh 3339cf5280 Cache: re-encode file names in default encoding 2013-09-20 15:58:55 -04:00
josh e041ea6612 v0.0.11 2013-09-19 17:06:37 -04:00
josh ab51ddcc1b do not try to clean directories that have already been removed 2013-09-19 17:06:20 -04:00
josh 3e4e9cce1c v0.0.10 2013-09-19 16:48:15 -04:00
josh 32d19489cb Cache: encode directory names in __ENCODING__ - close #3 2013-09-19 16:45:35 -04:00
josh 45a0d56c54 recover from, and warn when, .rsconscache loads something other than a Hash 2013-09-19 16:18:07 -04:00
josh 9b954d9d98 v0.0.9 2013-09-19 09:43:17 -04:00
josh e63b4c932f Cache: create missing hash entries from previous versions of the cache file 2013-09-19 09:43:00 -04:00
josh 97e11f45e5 v0.0.8 2013-09-18 21:18:00 -04:00
josh 5c6239ea6d Rscons.clean() removes any directories it created if they are empty 2013-09-18 21:17:42 -04:00
josh 770a22250a add Rscons.clear() class method 2013-09-17 21:48:50 -04:00
josh 983cb7cf21 v0.0.7 2013-09-16 23:03:14 -04:00
josh 986b8f08cc prepend builder-temporary construction variables with "_"; reserve lowercase string variables for user 2013-09-16 22:30:16 -04:00
josh f13664331f create requisite output directories for build targets; refactor common buile functionality into Builder#standard_build() 2013-09-15 15:27:16 -04:00
josh 17c7bf1d31 v0.0.6 2013-09-12 23:37:37 -04:00
josh 64d15602cc add Library default builder 2013-09-12 23:35:34 -04:00
josh e04e67698a add rspec test for overridding construction variables for an individual builer 2013-09-12 23:05:04 -04:00
josh 837dff9374 pass extra construction variables to Builder#run() 2013-09-12 22:57:22 -04:00
josh 75f2418570 refactor some Program functionality into Environment#build_sources() 2013-09-12 22:38:52 -04:00
226 changed files with 9030 additions and 662 deletions

No files matched your search

+9 -18
View File
@@ -1,18 +1,9 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
build_tests_run
/.bundle/
/.yardoc/
/_yardoc/
/build_test_run/
/coverage/
/dist/
/doc/
/pkg/
/test/
+210
View File
@@ -0,0 +1,210 @@
## ChangeLog
### v1.17.0
#### New Features
- allow construction variable expansion on `true` and `false` values.
- remove makefile target name check when parsing dependencies
### v1.16.0
#### New Features
- Add `Rscons.glob`
- Support command-line variables
- improve debuggability of cache.up_to_date?
- allow passing a VarSet into cache methods
#### Fixes
- generate dependencies for D builds
### v1.15.0
- allow json 1.x or 2.x
### v1.14.0
#### New Features
- #45 - Add Rscons::VarSet#values_at
#### Fixes
- #44 - Environment#print_builder_run_message should support string commands
### v1.13.0
#### New Features
- #43 - Add ability to record side-effect file production
### v1.12.0
#### New Features
- #40 - env.depends should imply env.build_after
- #41 - be more colorful
#### Fixes
- #39 - wait for in-progress subcommands to complete on build failure
- #42 - cloned Environments should inherit n_threads
### v1.11.1
#### Fixes
- fix the circular build dependency detection logic
### v1.11.0
#### New Features
- Change default Environment :clone option to :all to clone all attributes
- #38 - raise error when circular dependencies are found
- #34 - Allow overriding n_threads on a per-Environment level
#### Fixes
- #35 - env.build_after should expand paths
- #36 - SHCFLAGS and SHCXXFLAGS should inherit non-SH flags by default
- #37 - Fix non-blocking thread-wait if Rscons.n_threads is set to 0
### v1.10.0
#### New Features
- #23 - add parallelization - builds are now parallelized by default
- #31 - add LEXSUFFIX, YACCSUFFIX construction variables
- #30 - place object files for absolute source paths under build_root
- #28 - support redirecting standard output using the Command builder
- Always use a build root and default it to "build"
- Add builder features
- #8 - add SharedObject and SharedLibrary builders
#### Fixes
- expand target and source paths before calling Builder#create_build_target
- #29 - fix PROGSUFFIX handling
- #32 - Pre-build hooks do not respect modified key values
### v1.9.3
- Environment#parse_flags should put -std=XXX flags in CCFLAGS, not CFLAGS
### v1.9.2
- allow phony targets in conjunction with build roots
### v1.9.1
- change *SUFFIX defaults to arrays
- add various C++ file suffixes
- use ${INCPREFIX} instead of hard-coded "-I" in Preprocess builder
### v1.9.0
#### New Features
- #6 - add Install and Copy builders
- #22 - allow overriding Command builder short description with CMD_DESC variable
- #24 - add "rscons" executable
- #25 - add support for phony targets given as Symbols instead of Strings
- #26 - support registering multiple build targets with the same target name
- #27 - add Directory builder
#### Fixes
- #20 - fix variable references that expand to arrays in build target sources
- #21 - rework Preprocess builder to consider deep dependencies
- fix Rscons.set_suffix to append the given suffix if the filename has none
- remove ${CFLAGS} from default CPP_CMD
### v1.8.1
- fix Environment#dump when construction variables are symbols
### v1.8.0
- new Command builder to execute arbitrary user commands
- new SimpleBuilder class
- create new builders quickly by passing a block to Environment#add_builder
- improved YARD documentation
- add Environment#dump to debug Environment construction variables
### v1.7.0
- allow build hooks to register new build targets
- add post-build hooks (register with Environment#add_post_build_hook)
- clear all build targets after processing an Environment
- allow trailing slashes in arguments to Environment#build_dir
### v1.6.1
- add DEPFILESUFFIX construction variable to override dependency file suffix
- fix Environment#depends to expand its arguments for construction variables
### v1.6.0
- support lambdas as construction variable values
### v1.5.0
- add "json" as a runtime dependency
- update construction variables to match SCons more closely
- add CPPDEFPREFIX, INCPREFIX, CPPDEFINES, CCFLAGS, LIBDIRPREFIX, and LIBLINKPREFIX
- add Environment#shell
- add Environment#parse_flags, #parse_flags!, #merge_flags
- unbuffer $stdout by default
- add PROGSUFFIX construction variable (defaults to .exe on MinGW/Cygwin)
- add Rscons::BuildTarget and Builder#create_build_target
- update specs to RSpec 3.x and fix to run on MinGW/Cygwin/Linux
- add YARD documentation to get to 100% coverage
### v1.4.3
- fix builders properly using construction variable overrides
- expand nil construction variables to empty strings
### v1.4.2
- add Environment#expand_path
- expand construction variable references in builder targets and sources before invoking builder
### v1.4.1
- fix invoking a builder with no sources while a build root defined
### v1.4.0
- add CFile builder
- add Disassemble builder
- add Preprocess builder
- pass the Environment object to build hooks in the :env key of the build_op parameter
- expand target/source paths beginning with "^/" to be relative to the Environment's build root
- many performance improvements, including:
- use JSON instead of YAML for the cache to improve loading speed (Issue #7)
- store a hash of the build command instead of the full command contents in the cache
- implement copy-on-write semantics for construction variables when cloning Environments
- only load the cache once instead of on each Environment#process
- only write the cache when something has changed
- fix Cache#mkdir_p to handle relative paths (Issue #5)
- flush the cache to disk if a builder raises an exception (Issue #4)
### v1.3.0
- change Environment#execute() options parameter to accept the following options keys:
- :env to pass an environment Hash to Kernel#system
- :options to pass an options Hash to Kernel#system
### v1.2.0
- add :clone option to Environment#clone to control exactly which Environment attributes are cloned
- allow nil to be passed in to Environment#build_root=
### v1.1.0
- Change Cache#up_to_date?() and #register_build() to accept a single target
file or an array of target file names
+6 -2
View File
@@ -1,4 +1,8 @@
source 'https://rubygems.org'
# Specify your gem's dependencies in rscons.gemspec
gemspec
gem "json"
gem "rspec"
gem "rake"
gem "simplecov"
gem "yard"
gem "rdoc"
+42
View File
@@ -0,0 +1,42 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.3)
docile (1.1.5)
json (2.1.0)
rake (12.3.1)
rdoc (5.1.0)
rspec (3.6.0)
rspec-core (~> 3.6.0)
rspec-expectations (~> 3.6.0)
rspec-mocks (~> 3.6.0)
rspec-core (3.6.0)
rspec-support (~> 3.6.0)
rspec-expectations (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-mocks (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
simplecov (0.15.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
yard (0.9.12)
PLATFORMS
ruby
x86-mingw32
DEPENDENCIES
json
rake
rdoc
rspec
simplecov
yard
BUNDLED WITH
1.16.2
+570 -21
View File
@@ -1,37 +1,586 @@
# Rscons
Software construction library inspired by SCons and implemented in Ruby
Rscons (https://github.com/holtrop/rscons) is a software construction framework
inspired by SCons and waf but implemented in Ruby.
## Installation
Add this line to your application's Gemfile:
gem 'rscons'
And then execute:
$ bundle
Or install it yourself as:
$ 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
RScons::Environment.new do |env|
env.Program('program', Dir['*.c'])
end
### Standalone
main_env = RScons::Environment.new do |env|
env.build_dir('src', 'build/main')
env.Program('program', Dir['src/**/*.cc'])
Rscons provides a standalone executable ("rscons") with a command-line
interface. The rscons executable will read a build script (by default named
Rsconsfile or Rsconsfile.rb) and execute its contents.
### With Rake
Rscons can be used with rake as well. The same content that would be written
in Rsconsfile can be placed in a Rakefile. It could be placed within a rake
task block or split among multiple tasks.
## Example Build Scripts
### Example: Building a C Program
```ruby
Rscons::Environment.new do |env|
env["CFLAGS"] << "-Wall"
env.Program("program", Rscons.glob("src/**/*.c"))
end
```
### Example: Building a D Program
```ruby
Rscons::Environment.new do |env|
env["DFLAGS"] << "-Wall"
env.Program("program", Rscons.glob("src/**/*.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", Rscons.glob("src/**/*.cc"))
end
debug_env = main_env.clone do |env|
env.build_dir('src', 'build/debug')
env['CFLAGS'] = ['-g', '-O0']
env.Program('program-debug', Dir['src/**/*.cc'])
# 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", Rscons.glob("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 <<EOF
#define GENERATED 42
EOF
end
target
end
end
Rscons::Environment.new do |env|
env.add_builder(GenerateFoo.new)
env.GenerateFoo("foo.h", [])
env.Program("a.out", Rscons.glob("*.c"))
end
```
### Example: Custom Builder That Only Regenerates When Necessary
```ruby
class CmdBuilder < Rscons::Builder
def run(target, sources, cache, env, vars)
cmd = ["cmd", "-i", sources.first, "-o", target]
unless cache.up_to_date?(target, cmd, sources, env)
cache.mkdir_p(File.dirname(target))
system(cmd)
cache.register_build(target, cmd, sources, env)
end
target
end
end
Rscons::Environment.new do |env|
env.add_builder(CmdBuilder.new)
env.CmdBuilder("foo.gen", "foo_gen.cfg")
end
```
The `Cache#up_to_date?` method accepts an optional 5th parameter which is an
options Hash. The `:debug` option can be specified in this Hash with a value
of `true` to aid in debugging builders while developing them. For example:
```ruby
unless cache.up_to_date?(target, cmd, sources, env, debug: true)
end
```
### Example: Custom Builder That Generates Multiple Output Files
```ruby
class CModuleGenerator < Rscons::Builder
def run(target, sources, cache, env, vars)
c_fname = target
h_fname = target.sub(/\.c$/, ".h")
cmd = ["generate_c_and_h", sources.first, c_fname, h_fname]
unless cache.up_to_date?([c_fname, h_fname], cmd, sources, env)
cache.mkdir_p(File.dirname(target))
system(cmd)
cache.register_build([c_fname, h_fname], cmd, sources, env)
end
target
end
end
Rscons::Environment.new do |env|
env.add_builder(CModuleGenerator.new)
env.CModuleGenerator("build/foo.c", "foo_gen.cfg")
end
```
### Example: Custom Builder Using Builder#standard_build()
The `standard_build` method from the `Rscons::Builder` base class can be used
when the builder needs to execute a system command to produce the target file.
The `standard_build` method will return the correct value so its return value
can be used as the return value from the `run` method.
```ruby
class CmdBuilder < Rscons::Builder
def run(target, sources, cache, env, vars)
cmd = ["cmd", "-i", sources.first, "-o", target]
standard_build("CmdBld #{target}", target, cmd, sources, env, cache)
end
end
Rscons::Environment.new do |env|
env.add_builder(CmdBuilder.new)
env.CmdBuilder("foo.gen", "foo_gen.cfg")
end
```
### Example: Custom Builder Using Environment#add_builder()
The `add_builder` method of the `Rscons::Environment` class optionally allows
you to define and register a builder by providing a name and action block. This
can be useful if the builder you are trying to define is easily expressed as a
short ruby procedure. When `add_builder` is called in this manner a new builder
will be registered with the environment with the given name. When this builder
is used it will call the provided block in order to build the target.
```ruby
Rscons::Environment.new do |env|
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
```
### Example: Using different compilation flags for some sources
```ruby
Rscons::Environment.new do |env|
env["CFLAGS"] = ["-O3", "-Wall", "-DDEFINE"]
env.add_build_hook do |build_op|
if build_op[:target] =~ %r{build/third-party}
build_op[:vars]["CFLAGS"] -= ["-Wall"]
end
end
env.build_dir("src", "build")
env.Program("program", Rscons.glob("**/*.cc"))
end
```
### Example: Creating a static library
```ruby
Rscons::Environment.new do |env|
env.Library("mylib.a", Rscons.glob("src/**/*.c"))
end
```
### Example: Creating a C++ parser source from a Yacc/Bison input file
```ruby
Rscons::Environment.new do |env|
env.CFile("#{env.build_root}/parser.tab.cc", "parser.yy")
end
```
## Details
### Environments
The Environment is the main top-level object that Rscons operates with. An
Environment must be created by the user in order to build anything. All build
targets are registered within an Environment. In many cases only a single
Environment will be needed, but more than one can be created (either from
scratch or by cloning another existing Environment) if needed.
An Environment consists of:
* a collection of builders
* a collection of construction variables used by those builders
* a mapping of build directories from source directories
* a default build root to apply if no specific build directories are matched
* a collection of user-defined build targets
* a collection of user-defined build hooks
When cloning an environment, by default the construction variables, builders,
build hooks, build directories, and build root are cloned, but the new
environment does not inherit any of the registered build targets.
The set of environment attributes that are cloned is controllable via the
`:clone` option to the `#clone` method.
For example, `env.clone(clone: [:variables, :builders])` will include
construction variables, and builders but not build hooks, build directories, or
the build root.
The set of pending targets is never cloned.
Cloned environments contain "deep copies" of construction variables.
For example, in:
```ruby
base_env = Rscons::Environment.new
base_env["CPPPATH"] = ["one", "two"]
cloned_env = base_env.clone
cloned_env["CPPPATH"] << "three"
```
`base_env["CPPPATH"]` will not include "three".
### Builders
Builders are the workhorses that Rscons uses to execute build operations.
Each builder is specialized to perform a particular operation.
Rscons ships with a number of builders:
* Command, which executes a user-defined command to produce the target.
* Copy, which is identical to Install.
* CFile, which builds a C or C++ source file from a lex or yacc input file.
* Disassemble, which disassembles an object file to a disassembly listing.
* Install, which installs files or directories to a specified destination.
* Library, which collects object files into a static library archive file.
* Object, which compiles source files to produce an object file.
* Preprocess, which invokes the C/C++ preprocessor on a source file.
* Program, which links object files to produce an executable.
* SharedLibrary, which links object files to produce a dynamically loadable
library.
* SharedObject, which compiles source files to produce an object file, in a way
that is able to be used to create a shared library.
If you want to create an Environment that does not contain any builders,
you can use the `:exclude_builders` key to the Environment constructor.
#### Command
```ruby
env.Command(target, sources, "CMD" => command)
# Example
env.Command("docs.html", "docs.md",
"CMD" => ["pandoc", "-fmarkdown", "-thtml", "-o${_TARGET}", "${_SOURCES}"],
"CMD_DESC" => "PANDOC")
```
The command builder executes a user-defined command in order to produce the
desired target file based on the provided source files.
#### CFile
```ruby
env.CFile(target, source)
# Example
env.CFile("parser.c", "parser.y")
```
The CFile builder will generate a C or C++ source file from a lex (.l, .ll)
or yacc (.y, .yy) input file.
#### Disassemble
```ruby
env.Disassemble(target, source)
# Example
env.Disassemble("module.dis", "module.o")
```
The Disassemble builder generates a disassembly listing using objdump from
and object file.
#### Install
```ruby
env.Install(destination, sources)
# Example
env.Install("dist/bin", "app.exe")
env.Install("dist/share", "share")
```
#### Library
```ruby
env.Library(target, sources)
# Example
env.Library("lib.a", Rscons.glob("src/**/*.c"))
```
The Library builder creates a static library archive from the given source
files.
#### Object
```ruby
env.Object(target, sources)
# Example
env.Object("module.o", "module.c")
```
The Object builder compiles the given sources to an object file. Although it
can be called explicitly, it is more commonly implicitly called by the Program
builder.
#### Preprocess
```ruby
env.Preprocess(target, source)
# Example
env.Preprocess("module-preprocessed.cc", "module.cc")
```
The Preprocess builder invokes either `${CC}` or `${CXX}` (depending on if the
source contains an extension in `${CXXSUFFIX}` or not) and writes the
preprocessed output to the target file.
#### Program
```ruby
env.Program(target, sources)
# Example
env.Program("myprog", Rscons.glob("src/**/*.cc"))
```
The Program builder compiles and links the given sources to an executable file.
Object files or source files can be given as `sources`. A platform-dependent
program suffix will be appended to the target name if one is not specified.
This can be controlled with the `PROGSUFFIX` construction variable.
#### SharedLibrary
```ruby
env.SharedLibrary(target, sources)
# Example
env.SharedLibrary("mydll", Rscons.glob("src/**/*.cc"))
```
The SharedLibrary builder compiles and links the given sources to a dynamically
loadable library. Object files or source files can be given as `sources`.
A platform-dependent prefix and suffix will be appended to the target name if
they are not specified by the user. These values can be controlled by
overriding the `SHLIBPREFIX` and `SHLIBSUFFIX` construction variables.
#### SharedObject
```ruby
env.SharedObject(target, sources)
# Example
env.SharedObject("lib_module.o", "lib_module.c")
```
The SharedObject builder compiles the given sources to an object file. Any
compilation flags necessary to build the object file in a manner that allows it
to be used to create a shared library are added. Although it can be called
explicitly, it is more commonly implicitly called by the SharedLibrary builder.
### Construction Variables
Construction variables are used to define the toolset and any build options
that Rscons will use to build a project. The default construction variable
values are configured to build applications using gcc. However, all
construction variables can be overridden by the user.
| Name | Type | Description | Default |
| --- | --- | --- | --- |
| AR | String | Static library archiver executable | "ar" |
| ARCMD | Array | Static library archiver command line | ["${AR}", "${ARFLAGS}", "${_TARGET}", "${_SOURCES}"] |
| ARFLAGS | Array | Static library archiver flags | ["rcs"] |
| AS | String | Assembler executable | "${CC}" |
| ASCMD | Array | Assembler command line | ["${AS}", "-c", "-o", "${_TARGET}", "${ASDEPGEN}", "${INCPREFIX}${ASPPPATH}", "${ASPPFLAGS}", "${ASFLAGS}", "${_SOURCES}"] |
| ASDEPGEN | Array | Assembly dependency generation flags | ["-MMD", "-MF", "${_DEPFILE}", "-MT", "TARGET"] |
| ASFLAGS | Array | Assembler flags | [] |
| ASPPFLAGS | Array | Assembler preprocessor flags | ["${CPPFLAGS}"] |
| ASPPPATH | Array | Assembler preprocessor path | ["${CPPPATH}"] |
| ASSUFFIX | Array | Assembly file suffixes | [".S"] |
| CC | String | C compiler executable | "gcc" |
| CCCMD | Array | C compiler command line | ["${CC}", "-c", "-o", "${_TARGET}", "${CCDEPGEN}", "${INCPREFIX}${CPPPATH}", "${CPPFLAGS}", "${CFLAGS}", "${CCFLAGS}", "${_SOURCES}"] |
| CCDEPGEN | Array | C compiler dependency generation flags | ["-MMD", "-MF", "${_DEPFILE}", "-MT", "TARGET"] |
| CCFLAGS | Array | Common flags for both C and C++ compiler | [] |
| CFLAGS | Array | C compiler flags | [] |
| CPP_CMD | Array | Preprocess command line | ["${_PREPROCESS_CC}", "-E", "${_PREPROCESS_DEPGEN}", "-o", "${_TARGET}", "${INCPREFIX}${CPPPATH}", "${CPPFLAGS}", "${_SOURCES}"] |
| CPP_TARGET_SUFFIX | String | Suffix used for crt:preprocess target filename. | ".c" |
| CPPDEFINES | Array | C preprocessor defines | [] |
| CPPDEFPREFIX | String | Prefix used for C preprocessor to introduce a define | "-D" |
| CPPFLAGS | Array | C preprocessor flags | ["${CPPDEFPREFIX}${CPPDEFINES}"] |
| CPPPATH | Array | C preprocessor path | [] |
| CSUFFIX | Array | C source file suffixes | [".c"] |
| CXX | String | C++ compiler executable | "g++" |
| CXXCMD | Array | C++ compiler command line | ["${CXX}", "-c", "-o", "${_TARGET}", "${CXXDEPGEN}", "${INCPREFIX}${CPPPATH}", "${CPPFLAGS}", "${CXXFLAGS}", "${CCFLAGS}", "${_SOURCES}"] |
| CXXDEPGEN | Array | C++ compiler dependency generation flags | ["-MMD", "-MF", "${_DEPFILE}", "-MT", "TARGET"] |
| CXXFLAGS | Array | C++ compiler flags | [] |
| CXXSUFFIX | Array | C++ source file suffixes | [".cc", ".cpp", ".cxx", ".C"] |
| D_IMPORT_PATH | Array | D compiler import path | [] |
| DC | String | D compiler executable | "gdc" |
| DCCMD | Array | D compiler command line | ["${DC}", "-c", "-o", "${_TARGET}", "${DDEPGEN}", "${INCPREFIX}${D_IMPORT_PATH}", "${DFLAGS}", "${_SOURCES}"] |
| DDEPGEN | Array | D compiler dependency generation flags | ["-MMD", "-MF", "${_DEPFILE}", "-MT", "TARGET"] |
| DEPFILESUFFIX | String | Dependency file suffix for Makefile-style dependency rules emitted by the compiler (used internally for temporary dependency files used to determine a source file's dependencies) | ".mf" |
| DFLAGS | Array | D compiler flags | [] |
| DISASM_CMD | Array | Disassemble command line | ["${OBJDUMP}", "${DISASM_FLAGS}", "${_SOURCES}"] |
| DISASM_FLAGS | Array | Disassemble flags | ["--disassemble", "--source"] |
| DSUFFIX | String/Array | Default D source file suffix | ".d" |
| INCPREFIX | String | Prefix used for C preprocessor to add an include path | "-I" |
| LD | String | nil | Linker executable (automatically determined when nil) | nil (if nil, ${CC}, ${CXX}, or ${DC} is used depending on the sources being linked) |
| LDCMD | Array | Link command line | ["${LD}", "-o", "${_TARGET}", "${LDFLAGS}", "${_SOURCES}", "${LIBDIRPREFIX}${LIBPATH}", "${LIBLINKPREFIX}${LIBS}"] |
| LDFLAGS | Array | Linker flags | [] |
| LEX | String | Lex executable | "flex" |
| LEX_CMD | Array | Lex command line | ["${LEX}", "${LEX_FLAGS}", "-o", "${_TARGET}", "${_SOURCES}"] |
| LEX_FLAGS | Array | Lex flags | [] |
| LEXSUFFIX | Array | Lex input file suffixes | [".l", ".ll"] |
| LIBDIRPREFIX | String | Prefix given to linker to add a library search path | "-L" |
| LIBLINKPREFIX | String | Prefix given to linker to add a library to link with | "-l" |
| LIBPATH | Array | Library load path | [] |
| LIBS | Array | Libraries to link with | [] |
| LIBSUFFIX | String/Array | Default static library file suffix | ".a" |
| OBJDUMP | String | Objdump executable | "objdump" |
| OBJSUFFIX | String/Array | Default object file suffix | ".o" |
| PROGSUFFIX | String | Default program suffix. | Windows: ".exe", POSIX: "" |
| SHCC | String | Shared object C compiler | "${CC}" |
| SHCCCMD | Array | Shared object C compiler command line | ["${SHCC}", "-c", "-o", "${_TARGET}", "${CCDEPGEN}", "${INCPREFIX}${CPPPATH}", "${CPPFLAGS}", "${SHCFLAGS}", "${SHCCFLAGS}", "${_SOURCES}"] |
| SHCCFLAGS | Array | Shared object C and C++ compiler flags | Windows: ["${CCFLAGS}"], POSIX: ["${CCFLAGS}", -fPIC"] |
| SHCFLAGS | Array | Shared object C compiler flags | ["${CFLAGS}"] |
| SHCXX | String | Shared object C++ compiler | "${CXX}" |
| SHCXXCMD | Array | Shared object C++ compiler command line | ["${SHCXX}", "-c", "-o", "${_TARGET}", "${CXXDEPGEN}", "${INCPREFIX}${CPPPATH}", "${CPPFLAGS}", "${SHCXXFLAGS}", "${SHCCFLAGS}", "${_SOURCES}"] |
| SHCXXFLAGS | Array | Shared object C++ compiler flags | ["${CXXFLAGS}"] |
| SHDC | String | Shared object D compiler | "gdc" |
| SHDCCMD | Array | Shared object D compiler command line | ["${SHDC}", "-c", "-o", "${_TARGET}", "${INCPREFIX}${D_IMPORT_PATH}", "${SHDFLAGS}", "${_SOURCES}"] |
| SHDFLAGS | Array | Shared object D compiler flags | Windows: ["${DFLAGS}"], POSIX: ["${DFLAGS}", "-fPIC"] |
| SHLD | String | Shared library linker | nil (if nil, ${SHCC}, ${SHCXX}, or ${SHDC} is used depending on the sources being linked) |
| SHLDCMD | Array | Shared library linker command line | ["${SHLD}", "-o", "${_TARGET}", "${SHLDFLAGS}", "${_SOURCES}", "${SHLIBDIRPREFIX}${LIBPATH}", "${SHLIBLINKPREFIX}${LIBS}"] |
| SHLDFLAGS | Array | Shared library linker flags | ["${LDFLAGS}", "-shared"] |
| SHLIBDIRPREFIX | String | Prefix given to shared library linker to add a library search path | "-L" |
| SHLIBLINKPREFIX | String | Prefix given to shared library linker to add a library to link with | "-l" |
| SHLIBPREFIX | String | Shared library file name prefix | Windows: "", POSIX: "lib" |
| SHLIBSUFFIX | String | Shared library file name suffix | Windows: ".dll", POSIX: ".so" |
| SIZE | String | Size executable. | "size" |
| YACC | String | Yacc executable | "bison" |
| YACC_CMD | Array | Yacc command line | ["${YACC}", "${YACC_FLAGS}", "-o", "${_TARGET}", "${_SOURCES}"] |
| YACC_FLAGS | Array | Yacc flags | ["-d"] |
| YACCSUFFIX | Array | Yacc input file suffixes | [".y", ".yy"] |
### Build Hooks
Environments can have build hooks which are added with `env.add_build_hook()`.
Build hooks are invoked immediately before a builder executes.
Build hooks can modify the construction variables in use for the build
operation.
They can also register new build targets.
Environments can also have post-build hooks added with `env.add_post_build_hook()`.
Post-build hooks are only invoked if the build operation was a success.
Post-build hooks can invoke commands using the newly-built files, or register
new build targets.
Each build hook block will be invoked for every build operation, so the block
should test the target or sources if its action should only apply to some
subset of build targets or source files.
Example build hook:
```ruby
Rscons::Environment.new do |env|
# Build third party sources without -Wall
env.add_build_hook do |build_op|
if build_op[:builder].name == "Object" and
build_op[:sources].first =~ %r{src/third-party}
build_op[:vars]["CFLAGS"] -= ["-Wall"]
end
end
end
```
The `build_op` parameter to the build hook block is a Hash describing the
build operation with the following keys:
* `:builder` - `Builder` instance in use
* `:env` - `Environment` calling the build hook; note that this may be
different from the Environment that the build hook was added to in the case
that the original Environment was cloned with build hooks!
* `:target` - `String` name of the target file
* `:sources` - `Array` of the source files
* `:vars` - `Rscons::VarSet` containing the construction variables to use.
The build hook can overwrite entries in `build_op[:vars]` to alter the
construction variables in use for this specific build operation.
### Phony Targets
A build target name given as a Symbol instead of a String is interpreted as a
"phony" target.
Phony targets operate similarly to normal build targets, except that a file is
not expected to be produced by the builder.
Phony targets will still be "rebuilt" if any source or the command is out of
date.
### Explicit Dependencies
A target can be marked as depending on another file that Rscons would not
otherwise know about via the `Environment#depends` function. For example,
to force the linker to re-link a Program output when a linker script changes:
```ruby
Rscons::Environment.new do |env|
env.Program("a.out", "foo.c", "LDFLAGS" => %w[-T linker_script.ld])
env.depends("a.out", "linker_script.ld")
end
```
You can pass multiple dependency files to `Environment#depends`:
```ruby
env.depends("my_app", "config/link.ld", "README.txt", *Rscons.glob("assets/**/*"))
```
### Command-Line Variables
Variables can be specified on the rscons command line. For example:
```
rscons VAR=val
```
These variables are accessible in a global VarSet called `Rscons.vars`.
### Construction Variable Naming
* uppercase strings - the default construction variables that Rscons uses
* strings beginning with "_" - set and used internally by builders
* symbols, lowercase strings - reserved as user-defined construction variables
### API documentation
Documentation for the complete Rscons API can be found at
http://www.rubydoc.info/github/holtrop/rscons/master.
## Contributing
-21
View File
@@ -1,21 +0,0 @@
require "bundler"
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
raise LoadError.new("Unable to setup Bundler; you might need to `bundle install`: #{e.message}")
end
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "rake/clean"
require "yard"
CLEAN.include 'build_tests_run'
RSpec::Core::RakeTask.new(:spec)
YARD::Rake::YardocTask.new do |yard|
yard.files = ['lib/**/*.rb']
end
task :default => :spec
+44
View File
@@ -0,0 +1,44 @@
require "bundler"
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
raise LoadError.new("Unable to setup Bundler; you might need to `bundle install`: #{e.message}")
end
require "rspec/core/rake_task"
require "yard"
require "rake/clean"
require "fileutils"
CLEAN.include %w[build_test_run .yardoc doc coverage test]
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|
if args.example_string
ENV["partial_specs"] = "1"
task.rspec_opts = %W[-e "#{args.example_string}" -f documentation]
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.files = ['lib/**/*.rb']
end
task :default => :spec
Executable
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
require "rscons/cli"
if __FILE__ == $0
Rscons::Cli.run(ARGV)
end
-5
View File
@@ -1,5 +0,0 @@
Rscons::Environment.new do |env|
env.append('CPPPATH' => Dir['src/**/*/'])
env.build_dir('src', 'build')
env.Program('build_dir', Dir['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
@@ -0,0 +1,5 @@
build do
Environment.new do |env|
env.CFile("file.c", "foo.bar")
end
end
+4
View File
@@ -0,0 +1,4 @@
%{
%}
%%
+9
View File
@@ -0,0 +1,9 @@
%{
%}
%token ONE
%%
one: ONE
;
+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
-11
View File
@@ -1,11 +0,0 @@
debug = Rscons::Environment.new do |env|
env.build_dir('src', 'debug')
env['CFLAGS'] = '-O2'
env['CPPFLAGS'] = '-DSTRING="Debug Version"'
env.Program('program-debug', Dir['src/*.c'])
end
release = debug.clone('CPPFLAGS' => '-DSTRING="Release Version"') do |env|
env.build_dir('src', 'release')
env.Program('program-release', Dir['src/*.c'])
end
+16
View File
@@ -0,0 +1,16 @@
build do
env1 = Environment.new(echo: :command) do |env|
env['CFLAGS'] = '-O2'
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
env2 = env1.clone do |env|
env.Program('program2.exe', Dir['src/*.c'])
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)
File.open(target, 'w') do |fh|
fh.puts <<EOF
#define THE_VALUE 5678
EOF
end
target
end
end
Rscons::Environment.new(echo: :short) do |env|
env.add_builder(MySource.new)
env.MySource('inc.h', [])
env.Program('program', Dir['*.c'])
end
+12
View File
@@ -0,0 +1,12 @@
build do
Environment.new do |env|
env.Command("inc.c",
[],
"CMD" => %w[ruby gen.rb ${_TARGET}],
"CMD_DESC" => "Generating")
env["build_root"] = env.build_root
env["inc_c"] = "inc.c"
env.build_after("${build_root}/program.o", "${inc_c}")
env.Program("program.exe", ["program.c", "inc.c"])
end
end
@@ -0,0 +1,20 @@
class MySource < Rscons::Builder
def run(options)
File.open(@target, 'w') do |fh|
fh.puts <<EOF
#define THE_VALUE 678
EOF
end
true
end
end
build do
env = Environment.new do |env|
env["hdr"] = "inc.h"
env["src"] = "program.c"
env.add_builder(MySource)
env.MySource('${hdr}')
env.Program('program.exe', "${src}")
end
end
+30
View File
@@ -0,0 +1,30 @@
class MySource < Rscons::Builder
def run(options)
File.open(@target, 'w') do |fh|
fh.puts <<EOF
#define THE_VALUE #{@env.expand_varref("${the_value}")}
EOF
end
true
end
end
build do
e1 = Environment.new do |env|
env.add_builder(MySource)
env["one"] = "5"
env[:cfg] = {val: "9"}
env["two"] = lambda do |args|
args[:env][:cfg][:val]
end
env["the_value"] = lambda do |args|
"${one}${two}78"
end
end
e1.clone do |env|
env[:cfg][:val] = "6"
env.MySource('inc.h', [])
env.Program('program.exe', Dir['*.c'])
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
+9
View File
@@ -0,0 +1,9 @@
sleep 1.0
c_file = ARGV.first
h_file = File.basename(c_file, ".c") + ".h"
File.open(c_file, "w") do |fh|
fh.puts
end
File.open(h_file, "w") do |fh|
fh.puts("#define THE_VALUE 191")
end
@@ -0,0 +1,21 @@
class CHGen < Rscons::Builder
def run(options)
c_fname = @target
h_fname = @target.sub(/\.c$/, ".h")
unless @cache.up_to_date?([c_fname, h_fname], "", @sources, @env)
puts "CHGen #{c_fname}"
File.open(c_fname, "w") {|fh| fh.puts "int THE_VALUE = 42;"}
File.open(h_fname, "w") {|fh| fh.puts "extern int THE_VALUE;"}
@cache.register_build([c_fname, h_fname], "", @sources, @env)
end
true
end
end
build do
Environment.new do |env|
env.add_builder(CHGen)
env.CHGen("inc.c", ["program.c"])
env.Program("program.exe", %w[program.c inc.c])
end
end
+16
View File
@@ -0,0 +1,16 @@
build do
Environment.new do |env|
env["build_root"] = env.build_root
env["inc_h"] = "inc.h"
env.Copy("copy_inc.h", "${inc_h}")
env.depends("${build_root}/program.o", "${inc_h}")
env.Program("program.exe", ["program.c", "inc.c"])
env.Command("inc.c",
[],
"CMD" => %w[ruby gen.rb ${_TARGET}],
"CMD_DESC" => "Generating")
env.produces("inc.c", "inc.h")
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
+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
+7
View File
@@ -0,0 +1,7 @@
import std.stdio;
import mod;
void main()
{
writeln("Hello from D, value is ", Klass.VAL, "!");
}
+4
View File
@@ -0,0 +1,4 @@
class Klass
{
enum VAL = 42;
};
+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(echo: :short) do |env|
env.Program('header', 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
+1
View File
@@ -0,0 +1 @@
{ "key": "value" }
+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
@@ -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
+8
View File
@@ -0,0 +1,8 @@
#include <stdio.h>
#ifdef make_lib
int main(int argc, char *argv[])
{
printf("Library\n");
}
#endif
+6
View File
@@ -0,0 +1,6 @@
build do
Environment.new(echo: :command) do |env|
env["ARCMD"] = %w[ar rcf ${_TARGET} ${_SOURCES}]
env.Library("lib.a", glob("*.c"))
end
end
View File
Whitespace-only changes.
View File
Whitespace-only changes.
+5
View File
@@ -0,0 +1,5 @@
build do
Environment.new do |env|
env.Preprocess("pp", "foo.h")
end
end
+1
View File
@@ -0,0 +1 @@
#define BAR xyz42abc
+2
View File
@@ -0,0 +1,2 @@
#include "bar.h"
BAR
+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
@@ -0,0 +1,8 @@
build do
Environment.new do |env|
File.open("foo.xyz", "wb") do |fh|
fh.puts("hi")
end
env.SharedObject("foo.o", "foo.xyz")
end
end
@@ -0,0 +1,7 @@
build do
Environment.new do |env|
env["CPPPATH"] << "src/lib"
env.Object("file.S", "src/lib/one.c", "CFLAGS" => env["CFLAGS"] + ["-S"])
libmine = env.SharedLibrary("mine", "file.S")
end
end
@@ -0,0 +1,13 @@
build do
Environment.new do |env|
env["CPPPATH"] << "src/lib"
libmine = env.SharedLibrary("mine", glob("src/lib/*.cc"))
env.Program("test-shared.exe",
glob("src/*.cc"),
"LIBPATH" => %w[.],
"LIBS" => %w[mine])
env.build_after("test-shared.exe", libmine)
env.Program("test-static.exe",
glob("src/**/*.cc"))
end
end
@@ -0,0 +1,11 @@
build do
Environment.new do |env|
env["CPPPATH"] << "src/lib"
libmine = env.SharedLibrary("mine", glob("src/lib/*.d"))
env.Program("test-shared.exe",
glob("src/*.c"),
"LIBPATH" => %w[.],
"LIBS" => %w[mine])
env.build_after("test-shared.exe", libmine)
end
end
@@ -0,0 +1,7 @@
build do
Environment.new do |env|
env["CPPPATH"] << "src/lib"
env.SharedObject("one.o", "src/lib/one.c")
libmine = env.SharedLibrary("mine", ["one.o", "src/lib/two.c"])
end
end
@@ -0,0 +1,14 @@
build do
Environment.new do |env|
env["CPPPATH"] << "src/lib"
env["SHLD"] = "gcc"
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
+6
View File
@@ -0,0 +1,6 @@
#include <stdio.h>
void one(void)
{
printf("Hi from one()\n");
}
@@ -0,0 +1,6 @@
#include <stdio.h>
void one(void)
{
printf("Hi from one()\n");
}
+6
View File
@@ -0,0 +1,6 @@
import core.stdc.stdio;
extern (C) void one()
{
printf("Hi from one()\n");
}
Loaded 100 of 226 files, more files were not shown because too many files have changed in this diff. Show more