Compare commits

...
238 Commits
Author SHA1 Message Date
josh 663f4ac04c check_program: do not fail on Windows for non-existent PATH entries 2019-08-27 16:14:19 -04:00
josh 2c7cc61b30 build tests: use -m instead of -lc for mingw 2019-08-27 12:32:36 -04:00
josh 7c4abe9343 build tests: do ldc2 tests even if omit_gdc_tests set 2019-08-27 08:51:56 -04:00
josh 1a4f1a3608 update build test for gdc fix 2019-08-27 08:50:01 -04:00
josh 044ee343ca Use OBJSUFFIX of .obj for ldc2 on Windows. 2019-08-26 19:10:19 -04:00
josh eb54a2b64a fix specs create_exe() on Windows 2019-08-26 18:51:03 -04:00
josh 2dd1ce9f1d Use base64 encoding for compressed script to avoid encoding issues. 2019-08-26 18:33:42 -04:00
josh 1e157c79ec fix dependency parsing with ldc2 - close #110 2019-08-19 22:56:54 -04:00
josh 2385874f4a v2.0.0beta2 2019-08-17 17:07:59 -04:00
josh c5c42e6f4a user guide: document a couple missing configure flags and link to YARD some places 2019-08-17 17:00:36 -04:00
josh 9a627b2150 add YARD comments to get to 100% YARD coverage 2019-08-17 16:42:14 -04:00
josh 937c964c3e document :use better 2019-08-17 16:35:06 -04:00
josh a2a1d08014 user guide: document Custom Configuration Checks 2019-08-17 16:35:06 -04:00
josh 0ccf43cc96 custom config checks - close #108 2019-08-17 16:06:37 -04:00
josh d202e15a57 user guide: document direct mode for Program/SharedLibrary builders 2019-07-29 21:57:38 -04:00
josh 94f808b1fc user guide: add Barriers section 2019-07-29 21:32:04 -04:00
josh 51a9dd365f add :check_libpath option to check_lib configuration method - #107 2019-07-29 21:00:52 -04:00
josh 6e590b62a6 add :check_cpppath option to check_c_header and check_cxx_header
configuration methods
add :check_d_import_path option to check_d_import configuration method - #107
2019-07-09 23:53:17 -04:00
josh 3aac190ad6 configure checks: compile instead of link when looking for C/C++ header files and D imports 2019-07-09 23:41:51 -04:00
josh d6b9487e65 user guide: document -F command-line flag 2019-07-09 23:06:45 -04:00
josh 66d2700faa clarify -F command-line option usage more 2019-07-09 23:06:45 -04:00
josh ba98af1424 default configure checks :fail option to false if :set_define is specified 2019-07-09 22:00:50 -04:00
josh cf4f80c9ae user guide: document first compiler found is used 2019-07-09 21:47:45 -04:00
josh d74785d579 Add v2.0.0 changes to CHANGELOG.md 2019-07-07 22:15:44 -04:00
josh 4fd822fb95 user guide: add warning when viewing markdown source file directly 2019-07-07 21:38:17 -04:00
josh b39fd80d8c user guide: add ./configure && make Appendix section 2019-07-07 21:29:30 -04:00
josh ef00c9f377 add link to github.io site from README.md 2019-07-02 22:39:33 -04:00
josh 1ddc03b285 v2.0.0beta1 2019-07-02 22:31:27 -04:00
josh f686f9e787 user guide: rename Reference -> Appendix
add YARD API Documentation link
2019-07-02 22:27:11 -04:00
josh b6c19b7f00 generate YARD docs to gen/yard 2019-07-02 22:04:06 -04:00
josh 4fc18e5d91 remove README.md content that was moved to user guide 2019-07-02 22:00:03 -04:00
josh cda5584448 user guide: import some content from README.md 2019-07-02 21:59:22 -04:00
josh 30d82392b5 user guide: fill in Default Construction Variables section 2019-07-02 21:25:16 -04:00
josh 63d875da7f bundle update 2019-07-02 19:44:12 -04:00
josh 8593c5e219 user guide: fill in a lot of Adding Custom Builders section 2019-06-23 19:07:20 -04:00
josh 9bf0abbece user guide: fix inter-page links 2019-06-23 17:29:50 -04:00
josh 02ef6e0846 user guide updates 2019-06-23 17:27:16 -04:00
josh f97ee94e44 user guide: fix single-page TOC links 2019-06-14 21:53:57 -04:00
josh 55a2ea6d6b user guide: fill in Adding New Languages section 2019-06-14 21:48:27 -04:00
josh 59ab8e46c4 user guide: change page navigation to a table 2019-06-14 17:24:31 -04:00
josh baebe744b3 user guide: fixed page width 2019-06-14 16:51:14 -04:00
josh 0ad3f815c5 user guide: include section numbers in page navigation links 2019-06-14 16:47:54 -04:00
josh ca6336c715 user guide: add page navigation links 2019-06-14 16:45:59 -04:00
josh a11c27f415 user guide: break more sections into separate pages 2019-06-14 16:23:09 -04:00
josh 5c77cac354 user guide: turn on multi-page generation 2019-06-14 16:16:02 -04:00
josh 46294b2a88 user guide: add Page class to prepare for multi-page output 2019-06-14 16:09:44 -04:00
josh 5f71781806 user guide: preparing for multi-page generation 2019-06-14 16:04:14 -04:00
josh 22b007df3a user guide: create render_toc() and render_section() methods 2019-06-14 15:55:55 -04:00
josh 4339d358f8 user guide: Builders comment about starting path with "^/" 2019-06-14 15:44:06 -04:00
josh e4b96b759f user guide: implement section links 2019-06-14 15:42:21 -04:00
josh fcb686ac5f user guide: keep track of page for sections 2019-06-14 15:34:01 -04:00
josh e5c690a4fc user guide: expand Builders section 2019-06-14 15:16:22 -04:00
josh 5b67ad88d3 user guide: document an Environment a bit more 2019-06-14 15:16:12 -04:00
josh dbd8b47bf9 add Getting Started section 2019-06-14 14:52:56 -04:00
josh 8222958ae3 promote CHANGELOG.md section levels 2019-06-14 14:47:59 -04:00
josh 56f104b5e7 user guide: improve changelog handling 2019-06-14 14:44:00 -04:00
josh 947a65a75e user guide: fix section anchors 2019-06-09 22:45:26 -04:00
josh 66fac4f982 remove link underlines 2019-06-09 22:43:44 -04:00
josh 254584435f user guide: indent table of contents 2019-06-09 22:40:07 -04:00
josh f74d8202d3 user guide: add table of contents 2019-06-09 22:31:47 -04:00
josh bbf2319da6 user guide: generate section numbers 2019-06-09 22:17:00 -04:00
josh 812b1cbe9c user guide: put borders on body content 2019-06-09 15:34:41 -04:00
josh 0d2fe02b9c user guide updates for code sections 2019-06-09 13:22:01 -04:00
josh c7fb88db82 rename rake task gen_user_guide -> user_guide 2019-06-09 13:04:12 -04:00
josh 49f4367125 update LICENSE.txt 2019-06-09 13:01:30 -04:00
josh c4d062752d quote some CHANGELOG entries to avoid Markdown processing 2019-06-09 12:58:35 -04:00
josh 5b3e10ff72 add Ruby syntax highlighting to user guide generator 2019-06-08 22:56:26 -04:00
josh 5f1ad78e8c continue on user guide generator 2019-06-08 22:27:19 -04:00
josh 9f00063d57 add gen_user_guide task 2019-06-08 21:46:04 -04:00
josh 6328ceee2a start on user guide html generator 2019-06-05 00:13:27 -04:00
josh 26a9307533 User Guide: add a couple ${include}'s 2019-06-05 00:06:34 -04:00
josh 90886ed9ad User Guide: add glob() and Builders documentation 2019-06-04 22:59:04 -04:00
josh 8df73e9d11 User Guide: add Build Operations section 2019-06-02 12:20:23 -04:00
josh f239b27c3a add user guide section: Writing the Build Script / configure Block 2019-05-26 19:47:44 -04:00
josh 5e6b83411b User Guide: clarify Build Correctness section 2019-05-22 23:42:49 -04:00
josh 54e77f235f finish documentation for command-line operations 2019-05-22 23:31:37 -04:00
josh 4e08de9043 pull in redcarpet and syntax gems 2019-05-21 23:50:26 -04:00
josh 0d8aec0eb1 fill in a couple links 2019-05-21 23:36:58 -04:00
josh 573a542f84 add doc/user_guide.md 2019-05-21 23:20:45 -04:00
josh ef2a9084db allow --help CLI option with no Rsconscript present - close #106 2019-05-19 12:13:03 -04:00
josh bfcd0c0b05 generate yard docs to /yard instead of /doc 2019-05-14 21:35:56 -04:00
josh 215f5e4b51 move Environment#shell to BasicEnvironment; clean up a few yard warnings 2019-05-09 22:41:28 -04:00
josh 6229cef015 remove @since tags for 2.0.0 2019-05-09 22:33:26 -04:00
josh 6be0d322a7 store expanded .rscons script next to rscons script - close #105 2019-05-09 22:30:20 -04:00
josh 89e43fea1c use 10000 sources for large project instead of 1000 2019-05-09 22:22:14 -04:00
josh 458eeaf93d Add VarSet#get_var and Environment#get_var - #92 2019-05-09 21:52:07 -04:00
josh dd3d468a28 minor clarification to Environment#process_step behavior 2019-05-09 21:36:31 -04:00
josh a4dec210ae slightly reorder VarSet#deep_dup to optimize - #92 2019-05-08 23:16:22 -04:00
josh fa14102ba5 Reorder VarSet#expand_varref class checks so the more common ones match earlier - #92 2019-05-08 22:50:34 -04:00
josh 87a15b3868 Do not calculate checksums for side-effect files - #92 2019-05-08 22:39:50 -04:00
josh f23fbcd6d1 clear file checksum cache less frequently - #92 2019-05-08 22:30:41 -04:00
josh b02a7573b9 speed up handling of registered side-effect files - #92 2019-05-08 22:15:44 -04:00
josh d0cd0a14a4 remove Cache#validate_json_object - #92 2019-04-30 22:30:24 -04:00
josh 5cb895f465 add gen_large_project rake task for testing rscons performance on a large project 2019-04-30 22:25:45 -04:00
josh cd1c54bf0d update output coloring with highlighting for target and source filenames - close #104 2019-04-30 21:05:44 -04:00
josh a4fead7dc6 show build progress - close #98 2019-04-28 22:40:50 -04:00
josh 59a3cb4e10 verbose mode should list operations and their execution times - close #103 2019-04-27 22:29:18 -04:00
josh 785e8e18fd a clean operation should preserve install target cache info - close #101 2019-04-27 21:39:52 -04:00
josh 49e1bca1f7 uninstall operation should list removed entities in verbose mode - close #102 2019-04-27 21:28:56 -04:00
josh fd054a07c4 implement install and uninstall operations - close #82
add "prefix" construction variable - close #99
add InstallDirectory builder - close #100
2019-04-23 22:01:09 -04:00
josh 328babe1f4 imbue Cache with knowledge of whether a target or directory is for a build or install operation 2019-04-22 22:19:39 -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
245 changed files with 8121 additions and 4279 deletions

No files matched your search

+5 -1
View File
@@ -3,5 +3,9 @@
/_yardoc/
/build_test_run/
/coverage/
/doc/
/dist/
/gen/
/large_project/
/pkg/
/test/
/yard/
+108 -68
View File
@@ -1,73 +1,113 @@
## ChangeLog
## v2.0.0
### v1.16.0
- convert rscons from a Ruby gem to a standalone script
- compress rscons distributable script
- add configure operation to detect compilers, check for headers/libraries, etc... (invoked automatically if needed)
- Environments store builder classes instead of instances of builder classes
- use a separate Builder instance for each build operation
- load Rsconscript from Rsconscript/Rsconscript.rb instead of Rsconsfile
- drop support for builder run methods using the old 5 parameter signature
- remove Environment#build_dir
- set Environment build root in configure step
- remove Builder#finalize (now #run called repeatedly until builder completes)
- remove Builder#setup
- remove Builder#features and Builder#produces?
- add functionality to allow builders to wait on Ruby threads or other builders
- add install/uninstall/distclean command-line operations
- preserve makefile dependency files under build directory
- remove a few deprecated methods
- pass a Builder instance to build hooks instead of a build operation Hash
- support a basic markup syntax in builder run messages to colorize target/source files
- hide (but store) failed compilation command by default so the user doesn't have to scroll back as much to see compiler output
- refactor to remove some redundancy among built-in builders
- track object file source language (correctly determine linker when only passed object files previously built by particular toolchains)
- add barriers
- add InstallDirectory builder
- change Install builder to copy files on 'install' operation
- add "prefix" construction variable based on configured installation prefix
- allow passing builder objects as sources to build targets
- differentiate 'build' targets from 'install' targets in cache contents
- add verbose mode
- show build progress as a percentage in builder output messages
- various performance improvements
- wrote a new user guide
- added new website ([https://holtrop.github.io/rscons/](https://holtrop.github.io/rscons/))
#### New Features
## 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?
- improve debuggability of `cache.up_to_date?`
- allow passing a VarSet into cache methods
#### Fixes
### Fixes
- generate dependencies for D builds
### v1.15.0
## v1.15.0
- allow json 1.x or 2.x
### v1.14.0
## v1.14.0
#### New Features
### New Features
- #45 - Add Rscons::VarSet#values_at
- #45 - Add `Rscons::VarSet#values_at`
#### Fixes
### Fixes
- #44 - Environment#print_builder_run_message should support string commands
- #44 - `Environment#print_builder_run_message` should support string commands
### v1.13.0
## v1.13.0
#### New Features
### New Features
- #43 - Add ability to record side-effect file production
### v1.12.0
## v1.12.0
#### New Features
### New Features
- #40 - env.depends should imply env.build_after
- #40 - env.depends should imply `env.build_after`
- #41 - be more colorful
#### Fixes
### Fixes
- #39 - wait for in-progress subcommands to complete on build failure
- #42 - cloned Environments should inherit n_threads
- #42 - cloned Environments should inherit `n_threads`
### v1.11.1
## v1.11.1
#### Fixes
### Fixes
- fix the circular build dependency detection logic
### v1.11.0
## v1.11.0
#### New Features
### 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
- #34 - Allow overriding `n_threads` on a per-Environment level
#### Fixes
### 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
- #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
## v1.10.0
#### New Features
### New Features
- #23 - add parallelization - builds are now parallelized by default
- #31 - add LEXSUFFIX, YACCSUFFIX construction variables
@@ -77,100 +117,100 @@
- Add builder features
- #8 - add SharedObject and SharedLibrary builders
#### Fixes
### Fixes
- expand target and source paths before calling Builder#create_build_target
- #29 - fix PROGSUFFIX handling
- 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
## v1.9.3
- Environment#parse_flags should put -std=XXX flags in CCFLAGS, not CFLAGS
- `Environment#parse_flags` should put -std=XXX flags in CCFLAGS, not CFLAGS
### v1.9.2
## v1.9.2
- allow phony targets in conjunction with build roots
### v1.9.1
## 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
## v1.9.0
#### New Features
### New Features
- #6 - add Install and Copy builders
- #22 - allow overriding Command builder short description with CMD_DESC variable
- #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
### 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
- fix `Rscons.set_suffix` to append the given suffix if the filename has none
- remove ${CFLAGS} from default `CPP_CMD`
### v1.8.1
## v1.8.1
- fix Environment#dump when construction variables are symbols
### v1.8.0
## 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
- 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
## v1.7.0
- allow build hooks to register new build targets
- add post-build hooks (register with Environment#add_post_build_hook)
- 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
- allow trailing slashes in arguments to `Environment#build_dir`
### v1.6.1
## 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
## v1.6.0
- support lambdas as construction variable values
### v1.5.0
## 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
- 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
## v1.4.3
- fix builders properly using construction variable overrides
- expand nil construction variables to empty strings
### v1.4.2
## v1.4.2
- add Environment#expand_path
- add `Environment#expand_path`
- expand construction variable references in builder targets and sources before invoking builder
### v1.4.1
## v1.4.1
- fix invoking a builder with no sources while a build root defined
### v1.4.0
## v1.4.0
- add CFile builder
- add Disassemble builder
@@ -183,21 +223,21 @@
- 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)
- 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
## 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
## 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=
- allow nil to be passed in to `Environment#build_root=`
### v1.1.0
## v1.1.0
- Change Cache#up_to_date?() and #register_build() to accept a single target
- Change `Cache#up_to_date?` and `#register_build` to accept a single target
file or an array of target file names
+8 -2
View File
@@ -1,4 +1,10 @@
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"
gem "redcarpet"
gem "syntax"
+22 -24
View File
@@ -1,48 +1,46 @@
PATH
remote: .
specs:
rscons (1.16.0)
json (>= 1.8, < 3.0)
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)
docile (1.3.2)
json (2.2.0)
rake (12.3.2)
rdoc (6.1.1)
redcarpet (3.4.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-mocks (3.6.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.2)
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)
syntax (1.2.2)
yard (0.9.20)
PLATFORMS
ruby
x86-mingw32
DEPENDENCIES
json
rake
rdoc
rscons!
redcarpet
rspec
simplecov
syntax
yard
BUNDLED WITH
1.16.2
1.17.3
+2 -2
View File
@@ -1,4 +1,4 @@
Copyright (c) 2013 Josh Holtrop
Copyright (c) 2013-2019 Josh Holtrop
MIT License
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+4 -587
View File
@@ -1,591 +1,8 @@
# Rscons
Rscons (https://github.com/holtrop/rscons) is a software construction framework
inspired by SCons and implemented in Ruby.
Rscons (https://github.com/holtrop/rscons) is an open-source build system
for developers.
[![Gem Version](https://badge.fury.io/rb/rscons.png)](http://badge.fury.io/rb/rscons)
Rscons is written in Ruby, and is inspired by [SCons](https://scons.org/) and [waf](https://waf.io/).
## Installation
$ gem install rscons
## Usage
### Standalone
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|
# 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
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
See [https://holtrop.github.io/rscons/index.html](https://holtrop.github.io/rscons/index.html) for User Guide and Installation instructions.
+71 -3
View File
@@ -5,13 +5,17 @@ rescue Bundler::BundlerError => e
raise LoadError.new("Unable to setup Bundler; you might need to `bundle install`: #{e.message}")
end
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "yard"
require "rake/clean"
require "fileutils"
CLEAN.include %w[build_test_run .yardoc doc coverage]
CLOBBER.include %w[pkg]
CLEAN.include %w[build_test_run .yardoc yard 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
@@ -19,9 +23,73 @@ RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
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']
yard.options = ["-ogen/yard"]
end
task :gen_large_project, [:size] => :build_dist do |task, args|
size = (args.size || 10000).to_i
FileUtils.rm_rf("large_project")
FileUtils.mkdir_p("large_project/src")
size.times do |i|
File.open("large_project/src/fn#{i}.c", "w") do |fh|
fh.puts(<<-EOF)
int fn#{i}(void)
{
return #{i};
}
EOF
end
File.open("large_project/src/fn#{i}.h", "w") do |fh|
fh.puts %[int fn#{i}(void);]
end
end
File.open("large_project/src/main.c", "w") do |fh|
size.times do |i|
fh.puts %[#include "fn#{i}.h"]
end
fh.puts <<-EOF
int main(int argc, char * argv[])
{
int result = 0;
EOF
size.times do |i|
fh.puts %[result += fn#{i}();]
end
fh.puts <<-EOF
return result;
}
EOF
end
File.open("large_project/Rsconscript", "w") do |fh|
fh.puts <<EOF
build do
Environment.new do |env|
env.Program("project", glob("src/*.c"))
end
end
EOF
end
FileUtils.cp("dist/rscons", "large_project")
end
task :user_guide do
system("ruby", "-Ilib", "rb/gen_user_guide.rb")
end
task :default => :spec
+3 -1
View File
@@ -2,4 +2,6 @@
require "rscons/cli"
Rscons::Cli.run(ARGV)
if __FILE__ == $0
Rscons::Cli.run(ARGV)
end
-5
View File
@@ -1,5 +0,0 @@
Rscons::Environment.new do |env|
env.append('CPPPATH' => Rscons.glob('src/**'))
env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/')
env.Program('build_dir.exe', Rscons.glob('src/**/*.c'))
end
@@ -1,22 +0,0 @@
class MyObject < Rscons::Builder
def run(target, sources, cache, env, vars)
env.run_builder(env.builders["Object"], target, sources, cache, vars)
end
end
Rscons::Environment.new(echo: :command) do |env|
env.add_builder(MyObject.new)
env.append('CPPPATH' => Rscons.glob('src/**'))
env.add_build_hook do |build_op|
if build_op[:builder].name == "MyObject" && build_op[:sources].first =~ %r{one\.c}
build_op[:vars]["CFLAGS"] << "-O1"
build_op[:sources] = ['src/two/two.c']
elsif build_op[:builder].name == "MyObject" && build_op[:target] =~ %r{two\.o}
new_vars = build_op[:vars].clone
new_vars["CFLAGS"] << "-O2"
build_op[:vars] = new_vars
end
end
env.MyObject('one.o', 'src/one/one.c')
env.MyObject('two.o', 'src/two/two.c')
end
@@ -1,6 +0,0 @@
env = Rscons::Environment.new do |env|
env.append('CPPPATH' => Rscons.glob('src/**/*/'))
env.build_dir("src", "build")
env.build_root = "build_root"
env.Program('build_dir.exe', Rscons.glob('src/**/*.c'))
end
-12
View File
@@ -1,12 +0,0 @@
Rscons::Environment.new(echo: :command) do |env|
env.append('CPPPATH' => Rscons.glob('src/**/*/'))
env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/')
env.add_build_hook do |build_op|
if build_op[:target] =~ %r{build_one/.*\.o}
build_op[:vars]["CFLAGS"] << "-O1"
elsif build_op[:target] =~ %r{build_two/.*\.o}
build_op[:vars]["CFLAGS"] << "-O2"
end
end
env.Program('build_hook.exe', Rscons.glob('src/**/*.c'))
end
-8
View File
@@ -1,8 +0,0 @@
Rscons::Environment.new(echo: :command) do |env|
env.append('CPPPATH' => Rscons.glob('src/**').sort)
env.build_root = "build_root"
FileUtils.mkdir_p(env.build_root)
FileUtils.mv("src/one/one.c", "build_root")
env.Object("^/one.o", "^/one.c")
env.Program("build_dir.exe", Rscons.glob('src/**/*.c') + ["^/one.o"])
end
-3
View File
@@ -1,3 +0,0 @@
Rscons::Environment.new do |env|
env.Copy("inst.exe", "copy.rb")
end
-6
View File
@@ -1,6 +0,0 @@
Rscons::Environment.new do |env|
env["CSUFFIX"] = %w[.yargh .c]
env["CFLAGS"] += %w[-x c]
env["CPPPATH"] += Rscons.glob("src/**")
env.Program("build_dir.exe", Rscons.glob("src/**/*.{c,yargh}"))
end
@@ -1,5 +0,0 @@
Rscons::Environment.new do |env|
env.echo = :command
env.Install("inst.exe", "install.rb")
end
@@ -1,13 +0,0 @@
class MyBuilder < Rscons::Builder
def run(options)
env, target = options.values_at(:env, :target)
env.print_builder_run_message("MyBuilder #{target}", "MyBuilder #{target} command")
target
end
end
Rscons::Environment.new do |env|
env.echo = :command
env.add_builder(MyBuilder.new)
env.MyBuilder("foo")
end
-3
View File
@@ -1,3 +0,0 @@
Rscons::Environment.new do |env|
env.Install("inst.exe", "install.rb")
end
@@ -1,9 +0,0 @@
Rscons::Environment.new do |env|
env.Directory("inst")
env.Install("inst", "install_directory.rb")
env.Install("noexist/src", "src")
env.Directory("exist/src")
env.Install("exist/src", "src")
end
@@ -1,5 +0,0 @@
Rscons::Environment.new do |env|
env["CPPPATH"] << "src/two"
env.Object("one.o", "src/one/one.c")
env.Object("one.o", "src/two/two.c")
end
@@ -1,6 +0,0 @@
Rscons::Environment.new do |env|
env.append('CPPPATH' => Rscons.glob('src/**'))
env.build_dir("src2", "build")
env.build_root = "build_root"
env.Program('build_dir.exe', Rscons.glob('src/**/*.c'))
end
@@ -1,10 +0,0 @@
Rscons::Environment.new do |env|
env["CPPPATH"] << "src/two"
env.Object("one.o", "src/one/one.c")
env.add_post_build_hook do |build_op|
if build_op[:target] == "one.o"
env["MODULE"] = "two"
env.Object("${MODULE}.o", "src/${MODULE}/${MODULE}.c")
end
end
end
-6
View File
@@ -1,6 +0,0 @@
Rscons::Environment.new do |env|
env.append("CPPPATH" => Rscons.glob("src/**"))
env.build_dir("src/one/", "build_one/")
env.build_dir("src/two", "build_two")
env.Program("build_dir.exe", Rscons.glob("src/**/*.c"))
end
+6
View File
@@ -0,0 +1,6 @@
build do
Environment.new do |env|
env.CFile("lexer.c", "lexer.l")
env.CFile("parser.c", "parser.y")
end
end
-4
View File
@@ -1,4 +0,0 @@
Rscons::Environment.new do |env|
env.CFile("lexer.c", "lexer.l")
env.CFile("parser.c", "parser.y")
end
+4 -2
View File
@@ -1,3 +1,5 @@
Rscons::Environment.new do |env|
env.CFile("file.c", "foo.bar")
build do
Environment.new do |env|
env.CFile("file.c", "foo.bar")
end
end
+12
View File
@@ -0,0 +1,12 @@
build do
debug = Environment.new(echo: :command) do |env|
env['CFLAGS'] = '-O2'
env['CPPFLAGS'] = '-DSTRING="Debug Version"'
env.Program('program-debug.exe', Dir['src/*.c'])
end
release = debug.clone do |env|
env["CPPFLAGS"] = '-DSTRING="Release Version"'
env.Program('program-release.exe', Dir['src/*.c'])
end
end
-12
View File
@@ -1,12 +0,0 @@
debug = Rscons::Environment.new(echo: :command) do |env|
env.build_dir('src', 'debug')
env['CFLAGS'] = '-O2'
env['CPPFLAGS'] = '-DSTRING="Debug Version"'
env.Program('program-debug.exe', Dir['src/*.c'])
end
release = debug.clone do |env|
env["CPPFLAGS"] = '-DSTRING="Release Version"'
env.build_dir('src', 'release')
env.Program('program-release.exe', Dir['src/*.c'])
end
+13 -12
View File
@@ -1,15 +1,16 @@
env1 = Rscons::Environment.new(echo: :command) do |env|
env.build_dir('src', 'build')
env['CFLAGS'] = '-O2'
env.add_build_hook do |build_op|
build_op[:vars]['CPPFLAGS'] = '-DSTRING="Hello"'
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
env.add_post_build_hook do |build_op|
$stdout.puts "post #{build_op[:target]}"
end
env.Program('program.exe', Dir['src/*.c'])
end
env2 = env1.clone do |env|
env.Program('program2.exe', Dir['src/*.c'])
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,10 @@
configure do
check_c_header "string.h", check_cpppath: ["./usr1"]
check_c_header "frobulous.h", check_cpppath: ["./usr2"]
end
build do
Environment.new do |env|
env.Object("test.o", "test.c")
end
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", 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,10 @@
configure do
check_cxx_header "string.h", check_cpppath: ["./usr1"]
check_cxx_header "frobulous.h", check_cpppath: ["./usr2"]
end
build do
Environment.new do |env|
env.Object("test.o", "test.cc")
end
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,10 @@
configure do
check_d_import "std.stdio", check_d_import_path: ["./usr1"]
check_d_import "frobulous", check_d_import_path: ["./usr2"]
end
build do
Environment.new do |env|
env.Object("test.o", "test.d")
end
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,5 @@
build do
Environment.new(echo: :command) do |env|
env.Library("usr2/libfrobulous.a", "two.c")
end
end
@@ -0,0 +1,10 @@
configure do
check_lib "m", check_libpath: ["./usr1"]
check_lib "frobulous", check_libpath: ["./usr2"]
end
build do
Environment.new(echo: :command) do |env|
env.Program("simple.exe", "simple.c")
end
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,26 @@
configure do
custom_check("Checking 'grep' version") do |op|
stdout, stderr, status = op.log_and_test_command(%w[grep --version])
should_fail = true
if status != 0
fail_message = "error executing grep"
elsif stdout =~ /^grep \(GNU grep\) 1\./
fail_message = "too old!"
status = 1
elsif stdout =~ /^grep \(GNU grep\) 2\./
fail_message = "we'll work with it but you should upgrade"
status = 1
should_fail = false
op.store_merge("CPPDEFINES" => "GREP_WORKAROUND")
else
op.store_append("CPPDEFINES" => "GREP_FULL")
end
op.complete(status, success_message: "good!", fail_message: fail_message, fail: should_fail)
end
end
build do
Environment.new do |env|
puts env["CPPDEFINES"]
end
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");
}
+4
View File
@@ -0,0 +1,4 @@
int two(void)
{
return 42;
}
+18
View File
@@ -0,0 +1,18 @@
class MySource < Rscons::Builder
def run(options)
File.open(@target, 'w') do |fh|
fh.puts <<EOF
#define THE_VALUE 5678
EOF
end
true
end
end
build do
Environment.new do |env|
env.add_builder(MySource)
env.MySource('inc.h', [])
env.Program('program.exe', Dir['*.c'])
end
end
-16
View File
@@ -1,16 +0,0 @@
class MySource < Rscons::Builder
def run(target, sources, cache, env, vars)
File.open(target, 'w') do |fh|
fh.puts <<EOF
#define THE_VALUE 5678
EOF
end
target
end
end
Rscons::Environment.new do |env|
env.add_builder(MySource.new)
env.MySource('inc.h', [])
env.Program('program.exe', Dir['*.c'])
end
+11 -9
View File
@@ -1,10 +1,12 @@
Rscons::Environment.new do |env|
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"])
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
+11 -9
View File
@@ -1,18 +1,20 @@
class MySource < Rscons::Builder
def run(target, sources, cache, env, vars)
File.open(target, 'w') do |fh|
def run(options)
File.open(@target, 'w') do |fh|
fh.puts <<EOF
#define THE_VALUE 678
EOF
end
target
true
end
end
env = Rscons::Environment.new do |env|
env["hdr"] = "inc.h"
env["src"] = "program.c"
env.add_builder(MySource.new)
env.MySource('${hdr}')
env.Program('program.exe', "${src}")
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
+20 -18
View File
@@ -1,28 +1,30 @@
class MySource < Rscons::Builder
def run(target, sources, cache, env, vars)
File.open(target, 'w') do |fh|
def run(options)
File.open(@target, 'w') do |fh|
fh.puts <<EOF
#define THE_VALUE #{env.expand_varref("${the_value}")}
#define THE_VALUE #{@env.expand_varref("${the_value}")}
EOF
end
target
true
end
end
e1 = Rscons::Environment.new do |env|
env.add_builder(MySource.new)
env["one"] = "5"
env[:cfg] = {val: "9"}
env["two"] = lambda do |args|
args[:env][:cfg][:val]
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
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'])
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
+12 -10
View File
@@ -1,19 +1,21 @@
class CHGen < Rscons::Builder
def run(target, sources, cache, env, vars)
c_fname = target
h_fname = target.sub(/\.c$/, ".h")
unless cache.up_to_date?([c_fname, h_fname], "", sources, env)
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)
@cache.register_build([c_fname, h_fname], "", @sources, @env)
end
target
true
end
end
Rscons::Environment.new do |env|
env.add_builder(CHGen.new)
env.CHGen("inc.c", ["program.c"])
env.Program("program.exe", %w[program.c inc.c])
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
+13 -11
View File
@@ -1,14 +1,16 @@
Rscons::Environment.new do |env|
env["build_root"] = env.build_root
env["inc_h"] = "inc.h"
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.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")
inc_c = env.Command("inc.c",
[],
"CMD" => %w[ruby gen.rb ${_TARGET}],
"CMD_DESC" => "Generating")
inc_c.produces("inc.h")
end
end
@@ -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
+9
View File
@@ -0,0 +1,9 @@
configure do
check_d_compiler "gdc"
end
build do
Environment.new(echo: :command) do |env|
env.Program("hello-d.exe", glob("*.d"))
end
end
-3
View File
@@ -1,3 +0,0 @@
Rscons::Environment.new(echo: :command) do |env|
env.Program("hello-d.exe", Rscons.glob("*.d"))
end
+9
View File
@@ -0,0 +1,9 @@
configure do
check_d_compiler "ldc2"
end
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
+5
View File
@@ -0,0 +1,5 @@
build do
Environment.new do |env|
env.Program("test.exe", glob("*.c"), direct: true)
end
end
+7
View File
@@ -0,0 +1,7 @@
build do
Environment.new do |env|
lib = env.SharedLibrary("mylib", ["two.c", "three.c"], direct: true)
program = env.Program("test.exe", "main.c", "LIBS" => ["mylib"], "LIBPATH" => ["."])
env.depends(program, lib)
end
end
+7
View File
@@ -0,0 +1,7 @@
#include "two.h"
int main(int argc, char * argv[])
{
two();
return 0;
}
+7
View File
@@ -0,0 +1,7 @@
#include "three.h"
#include <stdio.h>
void three(void)
{
printf("three\n");
}
+1
View File
@@ -0,0 +1 @@
void three(void);
+7
View File
@@ -0,0 +1,7 @@
#include "two.h"
#include "three.h"
void two(void)
{
three();
}
+1
View File
@@ -0,0 +1 @@
void two(void);
+5
View File
@@ -0,0 +1,5 @@
build do
Environment.new do |env|
env.Program('header.exe', Dir['*.c'])
end
end
-3
View File
@@ -1,3 +0,0 @@
Rscons::Environment.new do |env|
env.Program('header.exe', Dir['*.c'])
end
+17
View File
@@ -0,0 +1,17 @@
build do
Environment.new do |env|
require 'json'
require 'yaml'
env.add_builder(:JsonToYaml) do |params|
unless @cache.up_to_date?(@target, :JsonToYaml, @sources, @env)
@cache.mkdir_p(File.dirname(@target))
File.open(@target, 'w') do |f|
f.write(YAML.dump(JSON.load(IO.read(@sources.first))))
end
@cache.register_build(@target, :JsonToYaml, @sources, @env)
end
true
end
env.JsonToYaml('foo.yml', 'foo.json')
end
end
Loaded 100 of 245 files, more files were not shown because too many files have changed in this diff. Show more