Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5beddd63ac | ||
|
|
4967f89a76 | ||
|
|
7cc68b2ce1 | ||
|
|
be058dd18b | ||
|
|
ad703a5c84 | ||
|
|
fb5d107581 | ||
|
|
d5c1a4b41a | ||
|
|
3f63bf5d13 | ||
|
|
ce47bd3599 | ||
|
|
68cab5e24d | ||
|
|
f92dd62ebd | ||
|
|
5cf77f1f58 | ||
|
|
b4cc45c381 | ||
|
|
750506201f | ||
|
|
284312a21c | ||
|
|
d081a4695f | ||
|
|
c7f66694ab | ||
|
|
57de94a3fb | ||
|
|
53ba7dad41 | ||
|
|
8cb02a7e34 | ||
|
|
dbbce9e476 | ||
|
|
0dc3a90660 | ||
|
|
d48c7587d6 | ||
|
|
70d4740a69 | ||
|
|
aaae845d60 | ||
|
|
e900e74342 | ||
|
|
62ae3f162d | ||
|
|
099d26f33c | ||
|
|
89562c584a | ||
|
|
a9aeaf2356 | ||
|
|
5409b3cb34 | ||
|
|
6d04500c13 | ||
|
|
45e30662d2 | ||
|
|
8f7e044bfd | ||
|
|
dbea6f0a26 | ||
|
|
c923eb5c7c | ||
|
|
529d9aacaa | ||
|
|
65c1bac4f9 | ||
|
|
775363ddbd | ||
|
|
2a96495e83 | ||
|
|
15e52e488c | ||
|
|
c0b12132f0 | ||
|
|
9141cf91e7 | ||
|
|
7f7e6ef3da | ||
|
|
60b3fdbcac | ||
|
|
5263ea03c6 | ||
|
|
6c91823ce2 | ||
|
|
8deb1eb6f8 | ||
|
|
6d6319799a | ||
|
|
694642dfbd | ||
|
|
6dd70ff65e | ||
|
|
eca01c38df | ||
|
|
4ad6ce1d9c | ||
|
|
a49ebc486e | ||
|
|
74d19ea235 | ||
|
|
d7a6d69a92 | ||
|
|
11864eb55b | ||
|
|
387c40176b | ||
|
|
f1b24ee8ba | ||
|
|
ef3150db0f | ||
|
|
ed4fb8b681 | ||
|
|
3a3f6d6d27 | ||
|
|
20affc0e1d | ||
|
|
010607d3b0 | ||
|
|
b7f609b7e8 | ||
|
|
10d4c647b9 | ||
|
|
db2ec82a25 | ||
|
|
aa192d7567 | ||
|
|
ed5d6e9e49 | ||
|
|
3436dc3a64 | ||
|
|
df52a7e0e1 | ||
|
|
6bd7e6f852 | ||
|
|
19a23c2aa9 | ||
|
|
c7e4e1ad9b | ||
|
|
43df46018c | ||
|
|
8cbb9fa30e | ||
|
|
1880e6650e | ||
|
|
d31b4725d2 | ||
|
|
6f242a1c64 | ||
|
|
c7943bc2cc | ||
|
|
b5826bd7f4 | ||
|
|
05bbea6fa1 | ||
|
|
68468b6422 | ||
|
|
80a80a7cb0 | ||
|
|
178940cd5d | ||
|
|
145d51c825 | ||
|
|
a11fab43cb | ||
|
|
83226e894d | ||
|
|
b454208117 | ||
|
|
df420fdf5c | ||
|
|
f3bf325c88 | ||
|
|
f815952ab3 | ||
|
|
1af3c5c9a4 | ||
|
|
dce88ece14 | ||
|
|
2655c119e4 | ||
|
|
221cde7e5f | ||
|
|
adcee373df | ||
|
|
e58b8bd109 | ||
|
|
8a1dfb0785 | ||
|
|
d315f86a36 | ||
|
|
0d46d616dd | ||
|
|
032e6d5d0a | ||
|
|
c9946da193 | ||
|
|
599d10b50f | ||
|
|
18c6c69871 | ||
|
|
2ffdf82d9a | ||
|
|
15e5d15424 | ||
|
|
a99e6e81b2 | ||
|
|
1509c95176 | ||
|
|
c7bba77581 | ||
|
|
957fd8c86d | ||
|
|
7e707e7e3b | ||
|
|
2be738be4f | ||
|
|
7b3bffd329 | ||
|
|
06cb4b7a55 | ||
|
|
bfbbc19728 | ||
|
|
28e56251dd | ||
|
|
2d8e08b493 | ||
|
|
5cef9896ac | ||
|
|
6344692087 | ||
|
|
267fc7124d | ||
|
|
e694199f33 | ||
|
|
4ed584701a | ||
|
|
5de52620e4 | ||
|
|
9cc59a35f0 | ||
|
|
ca445f5733 | ||
|
|
7534b29e26 | ||
|
|
800e7a51a4 | ||
|
|
5d36aa74a0 | ||
|
|
01851c2872 | ||
|
|
5fe55a584e | ||
|
|
9c13634eaf | ||
|
|
e4adaab003 | ||
|
|
6b8fda706d | ||
|
|
ef4f9882cd | ||
|
|
7a31039e35 | ||
|
|
3e4897c04b | ||
|
|
d46dc2014c | ||
|
|
9cfc0c20b7 | ||
|
|
19a00a7b84 | ||
|
|
9b6d2c5111 | ||
|
|
6a0ccad804 | ||
|
|
dab870854a | ||
|
|
695bf84092 | ||
|
|
7cba8c8424 | ||
|
|
551b8fa365 | ||
|
|
3601359c08 | ||
|
|
e1d8dfbab6 | ||
|
|
c69da1044d | ||
|
|
f33be07a15 | ||
|
|
c4c2d5c128 | ||
|
|
3065dc48ec | ||
|
|
9ca2934695 | ||
|
|
3af6b6be1b | ||
|
|
0442b876a5 | ||
|
|
bab4641b6e | ||
|
|
4698fc41b9 | ||
|
|
952f423860 | ||
|
|
d2da5f7b0d | ||
|
|
ab14dc16ed | ||
|
|
aa795eea85 | ||
|
|
7dffef6bd0 | ||
|
|
dce2114733 | ||
|
|
0bbdda2d41 | ||
|
|
3b8910075a | ||
|
|
34beda844e | ||
|
|
7a04bec2ff | ||
|
|
7698fbf618 | ||
|
|
4eedea2563 | ||
|
|
f678803a5d | ||
|
|
9c49a09f69 | ||
|
|
859f87ddee | ||
|
|
73bc71a656 | ||
|
|
29a8684f90 | ||
|
|
02aff35222 | ||
|
|
897d31ebe0 | ||
|
|
76610a07a9 | ||
|
|
cb3cc9a0de | ||
|
|
0ea842fffe | ||
|
|
d28722a4bb | ||
|
|
8142d0bbc8 | ||
|
|
a8023ae03c | ||
|
|
99ba015630 | ||
|
|
dcf90cc12b | ||
|
|
f93ca62c07 | ||
|
|
d9e3129ad5 | ||
|
|
d5e0475e6c | ||
|
|
b05eed36eb | ||
|
|
7ea0721cc2 | ||
|
|
e654df008d | ||
|
|
92d4dd8396 | ||
|
|
e279959d79 | ||
|
|
469f575564 | ||
|
|
07725581e9 | ||
|
|
ebb69cedc2 | ||
|
|
c98b377ce8 | ||
|
|
a0874e7cf1 | ||
|
|
0b04229e3d | ||
|
|
20f3da3b04 | ||
|
|
a6a79b8ef1 | ||
|
|
6d4f27602e | ||
|
|
453295a49b | ||
|
|
dee2b98f6e | ||
|
|
b186b3102c | ||
|
|
23c94f7841 | ||
|
|
6acb209ef4 | ||
|
|
43e12819d7 | ||
|
|
1bfb7dd100 | ||
|
|
df1e3be829 | ||
|
|
851adae66f | ||
|
|
eb28e09d8c | ||
|
|
01a84e8819 | ||
|
|
28bedfce11 | ||
|
|
e792fd473b | ||
|
|
9f738ee175 | ||
|
|
912615535a | ||
|
|
d87c4990b1 | ||
|
|
6a17cbcd54 | ||
|
|
8fc95b5d69 | ||
|
|
d9eea10363 | ||
|
|
5045e2e336 | ||
|
|
31968e7e32 | ||
|
|
5783ed993a | ||
|
|
0778f043ee | ||
|
|
42597b2dac | ||
|
|
7b13d51d23 | ||
|
|
c2d4ece957 | ||
|
|
3ab9c8723b | ||
|
|
1b50a9dd3c | ||
|
|
87b25d7bfd | ||
|
|
da457b9138 | ||
|
|
0cbf05da49 | ||
|
|
08b8a2e6be | ||
|
|
9f75ea9d21 | ||
|
|
ef18c9da35 | ||
|
|
7c9e7e833a | ||
|
|
eb9aa476b7 | ||
|
|
7f2b685bfb | ||
|
|
ae9021a505 | ||
|
|
a1a4cc18cd | ||
|
|
f5a3b448d3 | ||
|
|
9abb47ffe7 | ||
|
|
f78d13b648 | ||
|
|
ab1ea34941 | ||
|
|
08f2248ed7 | ||
|
|
9d61fa0276 | ||
|
|
c0adb64c5d | ||
|
|
95da14e029 | ||
|
|
58b41df426 | ||
|
|
bd525e2742 | ||
|
|
c08a2243b9 | ||
|
|
0de1e8e970 | ||
|
|
6f20a1da3f | ||
|
|
03ffb39956 | ||
|
|
0a10af3f5e | ||
|
|
ddf00d08a7 | ||
|
|
8be1842cf8 | ||
|
|
d424facf7f | ||
|
|
ee5aca275d | ||
|
|
ea30b0b5ee | ||
|
|
5a0d80b781 | ||
|
|
a2653a77d1 | ||
|
|
160434b903 | ||
|
|
5ce8940d54 | ||
|
|
1a5e9ddaa6 | ||
|
|
5924154229 | ||
|
|
5beda54374 | ||
|
|
ae0ad98075 | ||
|
|
f5be3a3571 | ||
|
|
fdc5c8773c | ||
|
|
c61380b354 | ||
|
|
d8dda291a5 | ||
|
|
1fe2c6401d | ||
|
|
4818fd10fe | ||
|
|
5989e24ee6 | ||
|
|
1875a2ea66 | ||
|
|
cbd5816b4b | ||
|
|
b2c970c9ca | ||
|
|
92a9982988 | ||
|
|
533ee9c16c | ||
|
|
831b9bf2c7 | ||
|
|
031395bb57 | ||
|
|
e3aeb7f4d7 | ||
|
|
6aa5037234 | ||
|
|
0d8f661fd4 | ||
|
|
e5ca8776a9 | ||
|
|
2dde39a0ec | ||
|
|
af0679708c | ||
|
|
4b0d0c3957 | ||
|
|
202f10b86f | ||
|
|
1d47db3144 | ||
|
|
f7b7a4fefa | ||
|
|
00b038ef50 | ||
|
|
98f8f38715 | ||
|
|
2ffb5d525a | ||
|
|
fa7d17675b | ||
|
|
b43c473762 | ||
|
|
f278b211f7 | ||
|
|
c897bcf06e | ||
|
|
7c89dddbd6 | ||
|
|
c07d9f86a6 | ||
|
|
ff26da8865 | ||
|
|
5ff555cf6a | ||
|
|
e3aadc562f | ||
|
|
7ff2ec1f1a | ||
|
|
5362f761e6 | ||
|
|
cdb3352b4e | ||
|
|
08bc390d40 | ||
|
|
f8af0630b0 | ||
|
|
1868193b54 | ||
|
|
8976d7dea2 | ||
|
|
295324eafd | ||
|
|
7330e74ab8 | ||
|
|
a28cef9eb7 | ||
|
|
e667046da8 | ||
|
|
539a49fe90 | ||
|
|
7681c7584f | ||
|
|
8fcbd39057 | ||
|
|
d0bbc78751 | ||
|
|
7249e57951 | ||
|
|
d01913641f | ||
|
|
d5be569cd5 | ||
|
|
4d7ed373e7 | ||
|
|
72558391a2 | ||
|
|
d01767981c | ||
|
|
01c847fa32 | ||
|
|
20f509ec27 | ||
|
|
243eb9a4ab | ||
|
|
49be46199f | ||
|
|
c9b670ae5c | ||
|
|
6bcb984e8e | ||
|
|
b377940252 | ||
|
|
2e0c2688aa | ||
|
|
66f53a23f6 | ||
|
|
545b893ef4 | ||
|
|
30564af558 | ||
|
|
cc2c2733fc | ||
|
|
ddb5357b02 | ||
|
|
b805e5379f | ||
|
|
71344b4782 | ||
|
|
b1cdd3d1db | ||
|
|
ed11b05b97 | ||
|
|
a418d31000 | ||
|
|
797580e937 | ||
|
|
8b852bd2fd | ||
|
|
e863c9a564 | ||
|
|
7ce5a8f9d9 | ||
|
|
1280cfb465 | ||
|
|
0cd9dbd1bd | ||
|
|
b38c56d446 | ||
|
|
d2b7c93f53 | ||
|
|
67922b887d | ||
|
|
8100830c16 | ||
|
|
cb629bf7ec | ||
|
|
65a5838605 | ||
|
|
338a49ba9c | ||
|
|
c23bb8c5e0 | ||
|
|
31abeed3d5 | ||
|
|
446fef931f | ||
|
|
4a2997feec | ||
|
|
013995bbc0 | ||
|
|
cd266c511e | ||
|
|
0f5fee359d | ||
|
|
dc6bac2895 | ||
|
|
e50aac31c9 | ||
|
|
e788f6ec25 | ||
|
|
8d893d7b72 | ||
|
|
c258dc379f | ||
|
|
0facfb274d | ||
|
|
3339cf5280 | ||
|
|
e041ea6612 | ||
|
|
ab51ddcc1b | ||
|
|
3e4e9cce1c | ||
|
|
32d19489cb | ||
|
|
45a0d56c54 |
No files matched your search
+7
-18
@@ -1,18 +1,7 @@
|
||||
*.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/
|
||||
/doc/
|
||||
/pkg/
|
||||
+210
@@ -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
|
||||
@@ -0,0 +1,48 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
rscons (1.17.0)
|
||||
json (>= 1.8, < 3.0)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
diff-lcs (1.3)
|
||||
docile (1.3.2)
|
||||
json (2.2.0)
|
||||
rake (12.3.2)
|
||||
rdoc (6.1.1)
|
||||
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.8.0)
|
||||
rspec-mocks (3.8.1)
|
||||
diff-lcs (>= 1.2.0, < 2.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.20)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86-mingw32
|
||||
|
||||
DEPENDENCIES
|
||||
rake
|
||||
rdoc
|
||||
rscons!
|
||||
rspec
|
||||
simplecov
|
||||
yard
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
@@ -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 implemented in Ruby.
|
||||
|
||||
[](http://badge.fury.io/rb/rscons)
|
||||
|
||||
## Installation
|
||||
|
||||
Add this line to your application's Gemfile:
|
||||
|
||||
gem 'rscons'
|
||||
|
||||
And then execute:
|
||||
|
||||
$ bundle
|
||||
|
||||
Or install it yourself as:
|
||||
|
||||
$ gem install rscons
|
||||
|
||||
## 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'])
|
||||
end
|
||||
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.
|
||||
|
||||
debug_env = main_env.clone do |env|
|
||||
env.build_dir('src', 'build/debug')
|
||||
env['CFLAGS'] = ['-g', '-O0']
|
||||
env.Program('program-debug', Dir['src/**/*.cc'])
|
||||
### 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
|
||||
|
||||
|
||||
@@ -7,12 +7,18 @@ end
|
||||
|
||||
require "bundler/gem_tasks"
|
||||
require "rspec/core/rake_task"
|
||||
require "rake/clean"
|
||||
require "yard"
|
||||
require "rake/clean"
|
||||
|
||||
CLEAN.include 'build_tests_run'
|
||||
CLEAN.include %w[build_test_run .yardoc doc coverage]
|
||||
CLOBBER.include %w[pkg]
|
||||
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
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
|
||||
|
||||
YARD::Rake::YardocTask.new do |yard|
|
||||
yard.files = ['lib/**/*.rb']
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "rscons/cli"
|
||||
|
||||
Rscons::Cli.run(ARGV)
|
||||
@@ -0,0 +1,5 @@
|
||||
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
|
||||
@@ -0,0 +1,22 @@
|
||||
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,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
|
||||
@@ -0,0 +1,6 @@
|
||||
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
|
||||
@@ -0,0 +1,12 @@
|
||||
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
|
||||
@@ -0,0 +1,8 @@
|
||||
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
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Copy("inst.exe", "copy.rb")
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
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
|
||||
@@ -0,0 +1,5 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.echo = :command
|
||||
env.Install("inst.exe", "install.rb")
|
||||
end
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
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
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Install("inst.exe", "install.rb")
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
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
|
||||
@@ -0,0 +1,5 @@
|
||||
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
|
||||
@@ -0,0 +1,6 @@
|
||||
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
|
||||
@@ -0,0 +1,10 @@
|
||||
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
|
||||
@@ -0,0 +1,6 @@
|
||||
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
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.CFile("lexer.c", "lexer.l")
|
||||
env.CFile("parser.c", "parser.y")
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.CFile("file.c", "foo.bar")
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
%{
|
||||
%}
|
||||
|
||||
%%
|
||||
@@ -0,0 +1,9 @@
|
||||
%{
|
||||
%}
|
||||
|
||||
%token ONE
|
||||
|
||||
%%
|
||||
|
||||
one: ONE
|
||||
;
|
||||
@@ -0,0 +1,12 @@
|
||||
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
|
||||
@@ -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
|
||||
@@ -0,0 +1,15 @@
|
||||
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"'
|
||||
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'])
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
class MySource < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars = {})
|
||||
def run(target, sources, cache, env, vars)
|
||||
File.open(target, 'w') do |fh|
|
||||
fh.puts <<EOF
|
||||
#define THE_VALUE 5678
|
||||
@@ -9,8 +9,8 @@ EOF
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new(echo: :short) do |env|
|
||||
Rscons::Environment.new do |env|
|
||||
env.add_builder(MySource.new)
|
||||
env.MySource('inc.h', [])
|
||||
env.Program('program', Dir['*.c'])
|
||||
env.Program('program.exe', Dir['*.c'])
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
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"])
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
class MySource < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
File.open(target, 'w') do |fh|
|
||||
fh.puts <<EOF
|
||||
#define THE_VALUE 678
|
||||
EOF
|
||||
end
|
||||
target
|
||||
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}")
|
||||
end
|
||||
@@ -0,0 +1,28 @@
|
||||
class MySource < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
File.open(target, 'w') do |fh|
|
||||
fh.puts <<EOF
|
||||
#define THE_VALUE #{env.expand_varref("${the_value}")}
|
||||
EOF
|
||||
end
|
||||
target
|
||||
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]
|
||||
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
|
||||
@@ -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,19 @@
|
||||
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)
|
||||
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
|
||||
target
|
||||
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])
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
Rscons::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
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.Program("hello-d.exe", Rscons.glob("*.d"))
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
import std.stdio;
|
||||
import mod;
|
||||
|
||||
void main()
|
||||
{
|
||||
writeln("Hello from D, value is ", Klass.VAL, "!");
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class Klass
|
||||
{
|
||||
enum VAL = 42;
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program('header.exe', Dir['*.c'])
|
||||
end
|
||||
@@ -1,3 +0,0 @@
|
||||
Rscons::Environment.new(echo: :short) do |env|
|
||||
env.Program('header', Dir['*.c'])
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
Rscons::Environment.new do |env|
|
||||
require 'json'
|
||||
require 'yaml'
|
||||
env.add_builder(:JsonToYaml) do |target, sources, cache, env, vars|
|
||||
unless cache.up_to_date?(target, :JsonToYaml, sources, env)
|
||||
cache.mkdir_p(File.dirname(target))
|
||||
File.open(target, 'w') do |f|
|
||||
f.write(YAML.dump(JSON.load(IO.read(sources.first))))
|
||||
end
|
||||
cache.register_build(target, :JsonToYaml, sources, env)
|
||||
end
|
||||
target
|
||||
end
|
||||
env.JsonToYaml('foo.yml', 'foo.json')
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
{ "key": "value" }
|
||||
@@ -1,4 +1,4 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.Program('library', ['lib.a', 'three.c'])
|
||||
env.Program('library.exe', ['lib.a', 'three.c'])
|
||||
env.Library("lib.a", ['one.c', 'two.c'], 'CPPFLAGS' => ['-Dmake_lib'])
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env["ARCMD"] = %w[ar rcf ${_TARGET} ${_SOURCES}]
|
||||
env.Library("lib.a", Rscons.glob("*.c"))
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Preprocess("pp", "foo.h")
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
#define BAR xyz42abc
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "bar.h"
|
||||
BAR
|
||||
@@ -0,0 +1,11 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["CPPPATH"] << "src/lib"
|
||||
libmine = env.SharedLibrary("mine", Rscons.glob("src/lib/*.c"))
|
||||
env.Program("test-shared.exe",
|
||||
Rscons.glob("src/*.c"),
|
||||
"LIBPATH" => %w[.],
|
||||
"LIBS" => %w[mine])
|
||||
env.build_after("test-shared.exe", libmine.to_s)
|
||||
env.Program("test-static.exe",
|
||||
Rscons.glob("src/**/*.c"))
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
Rscons::Environment.new do |env|
|
||||
File.open("foo.xyz", "wb") do |fh|
|
||||
fh.puts("hi")
|
||||
end
|
||||
env.SharedObject("foo.o", "foo.xyz")
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["CPPPATH"] << "src/lib"
|
||||
libmine = env.SharedLibrary("mine", Rscons.glob("src/lib/*.cc"))
|
||||
env.Program("test-shared.exe",
|
||||
Rscons.glob("src/*.cc"),
|
||||
"LIBPATH" => %w[.],
|
||||
"LIBS" => %w[mine])
|
||||
env.build_after("test-shared.exe", libmine.to_s)
|
||||
env.Program("test-static.exe",
|
||||
Rscons.glob("src/**/*.cc"))
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["CPPPATH"] << "src/lib"
|
||||
libmine = env.SharedLibrary("mine", Rscons.glob("src/lib/*.d"))
|
||||
env.Program("test-shared.exe",
|
||||
Rscons.glob("src/*.c"),
|
||||
"LIBPATH" => %w[.],
|
||||
"LIBS" => %w[mine])
|
||||
env.build_after("test-shared.exe", libmine.to_s)
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["CPPPATH"] << "src/lib"
|
||||
env["SHLD"] = "gcc"
|
||||
libmine = env.SharedLibrary("mine", Rscons.glob("src/lib/*.c"))
|
||||
env.Program("test-shared.exe",
|
||||
Rscons.glob("src/*.c"),
|
||||
"LIBPATH" => %w[.],
|
||||
"LIBS" => %w[mine])
|
||||
env.build_after("test-shared.exe", libmine.to_s)
|
||||
env.Program("test-static.exe",
|
||||
Rscons.glob("src/**/*.c"))
|
||||
end
|
||||
@@ -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");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import core.stdc.stdio;
|
||||
|
||||
extern (C) void one()
|
||||
{
|
||||
printf("Hi from one()\n");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifndef ONE_H
|
||||
|
||||
void one(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void two(void)
|
||||
{
|
||||
printf("Hi from two()\n");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void two(void)
|
||||
{
|
||||
printf("Hi from two()\n");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import core.stdc.stdio;
|
||||
|
||||
extern (C) void two()
|
||||
{
|
||||
printf("Hi from two()\n");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifndef TWO_H
|
||||
|
||||
void two(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "one.h"
|
||||
#include "two.h"
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
one();
|
||||
two();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "one.h"
|
||||
#include "two.h"
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
one();
|
||||
two();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program('simple.exe', Dir['*.c'])
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.build_root = "build"
|
||||
tempdir = ENV["TEMP"] || ENV["TMP"] || "/tmp"
|
||||
source_file = File.join(tempdir, "abs.c")
|
||||
File.open(source_file, "w") do |fh|
|
||||
fh.puts(<<-EOF)
|
||||
int main()
|
||||
{
|
||||
return 29;
|
||||
}
|
||||
EOF
|
||||
end
|
||||
env.Program("abs.exe", source_file)
|
||||
end
|
||||
@@ -0,0 +1,28 @@
|
||||
class MyObject < Rscons::Builder
|
||||
def produces?(target, source, env)
|
||||
target.end_with?(".o") and source.end_with?(".xyz")
|
||||
end
|
||||
|
||||
def run(target, sources, cache, env, vars)
|
||||
cflags = env.expand_varref("${CFLAGS}", vars)
|
||||
vars = vars.merge(
|
||||
"CFLAGS" => cflags + %w[-x c],
|
||||
"CSUFFIX" => ".xyz")
|
||||
env.run_builder(env.builders["Object"], target, sources, cache, vars)
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new do |env|
|
||||
env.add_builder(MyObject.new)
|
||||
File.open("test.xyz", "w") do |fh|
|
||||
fh.puts <<EOF
|
||||
#include <stdio.h>
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
printf("XYZ!\\n");
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
env.Program("test", "test.xyz")
|
||||
end
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
Rscons::Environment.new do |env|
|
||||
# CHANGE FLAGS
|
||||
env.Program('simple', Dir['*.c'])
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
class TestBuilder < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
target
|
||||
end
|
||||
end
|
||||
Rscons::Environment.new do |env|
|
||||
env.build_root = "build"
|
||||
env.add_builder(TestBuilder.new)
|
||||
env.TestBuilder("file")
|
||||
end
|
||||
@@ -0,0 +1,22 @@
|
||||
class MyProgram < Rscons::Builder
|
||||
def run(options)
|
||||
target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
|
||||
objects = env.build_sources(sources, [".o"], cache, vars)
|
||||
command = %W[gcc -o #{target}] + objects
|
||||
return false unless env.execute("#{name} #{target}", command)
|
||||
target
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new do |env|
|
||||
env.add_builder(MyProgram.new)
|
||||
env.Object("simple.o", "simple.c")
|
||||
File.open("two.c", "wb") do |fh|
|
||||
fh.puts <<-EOF
|
||||
void two(void)
|
||||
{
|
||||
}
|
||||
EOF
|
||||
end
|
||||
env.MyProgram("simple.exe", ["simple.o", "two.c"])
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["LIBS"] += ["c"]
|
||||
env.Program('simple.exe', Dir['*.c'])
|
||||
end
|
||||
@@ -0,0 +1,34 @@
|
||||
class DebugBuilder < Rscons::Builder
|
||||
def run(options)
|
||||
target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
|
||||
command = %W[gcc -c -o #{target} #{sources.first}]
|
||||
if Rscons.vars["command_change"]
|
||||
command += %w[-Wall]
|
||||
end
|
||||
if Rscons.vars["new_dep"]
|
||||
sources += ["extra"]
|
||||
end
|
||||
if Rscons.vars["strict_deps1"]
|
||||
sources += ["extra"]
|
||||
strict_deps = true
|
||||
end
|
||||
if Rscons.vars["strict_deps2"]
|
||||
sources = ["extra"] + sources
|
||||
strict_deps = true
|
||||
end
|
||||
unless cache.up_to_date?(target, command, sources, env, debug: true, strict_deps: strict_deps)
|
||||
desc = "#{self.class.name} #{target}"
|
||||
return false unless env.execute(desc, command)
|
||||
cache.register_build(target, command, sources, env)
|
||||
end
|
||||
target
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new do |env|
|
||||
env.add_builder(DebugBuilder.new)
|
||||
if Rscons.vars["new_user_dep"]
|
||||
env.depends("foo.o", "new_dep")
|
||||
end
|
||||
env.DebugBuilder("foo.o", "simple.c")
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Copy("simple.copy", "simple.c")
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Object("simple.o", "simple.c")
|
||||
env.process
|
||||
env["LDCMD"] = %w[gcc -o ${_TARGET} simple.o]
|
||||
env.Program('simple.exe', [])
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Object("simple.o", "simple.c")
|
||||
env["LDCMD"] = %w[gcc -o ${_TARGET} simple.o]
|
||||
env.Program('simple.exe', ["simple.o"])
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Object("simple.o", "simple.c")
|
||||
env.Object("two.o", "two.c")
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
Rscons::Environment.new do |env|
|
||||
target = env.Program("simple.exe", "simple.c")
|
||||
user_deps = File.read("user_deps", mode: "rb").split(" ")
|
||||
target.depends(*user_deps)
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
class TestBuilder < Rscons::Builder
|
||||
def run(options)
|
||||
target, sources, cache, env = options.values_at(:target, :sources, :cache, :env)
|
||||
command = Rscons::VarSet.new("A" => "a", "B" => "b")
|
||||
unless cache.up_to_date?(target, command, sources, env)
|
||||
File.open(target, "w") do |fh|
|
||||
fh.puts("hi")
|
||||
end
|
||||
msg = "#{self.class.name} #{target}"
|
||||
env.print_builder_run_message(msg, msg)
|
||||
cache.register_build(target, command, sources, env)
|
||||
end
|
||||
target
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new do |env|
|
||||
env.add_builder(TestBuilder.new)
|
||||
env.TestBuilder("foo")
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program("simple.exe", "simple.c")
|
||||
env.clear_targets
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
base_env = Rscons::Environment.new do |env|
|
||||
env.n_threads = 165
|
||||
end
|
||||
|
||||
my_env = base_env.clone
|
||||
|
||||
puts my_env.n_threads
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env["LD"] = "gcc"
|
||||
env.Program('simple.exe', Dir['*.c'])
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Rscons::Environment.new do |env|
|
||||
command = %W[gcc -o ${_TARGET} ${_SOURCES}]
|
||||
env.Command("simple.exe",
|
||||
"simple.c",
|
||||
"CMD" => command,
|
||||
"CMD_DESC" => "BuildIt")
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Object("simple.o", "simple.c")
|
||||
env.Command("simple.txt",
|
||||
"simple.o",
|
||||
"CMD" => %w[objdump --disassemble --source ${_SOURCES}],
|
||||
"CMD_STDOUT" => "${_TARGET}",
|
||||
"CMD_DESC" => "My Disassemble")
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["sources"] = Rscons.glob("*.c")
|
||||
env.Program("simple.exe", "${sources}")
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Directory("teh_dir")
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Object("simple.o", "simple.c")
|
||||
env.Disassemble("simple.txt", "simple.o")
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
env = Rscons::Environment.new do |env|
|
||||
env["CFLAGS"] += %w[-O2 -fomit-frame-pointer]
|
||||
env[:foo] = :bar
|
||||
end
|
||||
env.dump
|
||||
@@ -0,0 +1,5 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Command("foo", "bar")
|
||||
env.Command("bar", "baz")
|
||||
env.Command("baz", "foo")
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Command("foo", "foo")
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
Rscons::Environment.new do |env|
|
||||
File.open("foo.xyz", "wb") do |fh|
|
||||
fh.puts("hi")
|
||||
end
|
||||
env.Object("foo.o", "foo.xyz")
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env["LD"] = "gcc"
|
||||
env["LIBPATH"] += ["libdir"]
|
||||
env.Program('simple.exe', Dir['*.c'])
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.Object("simple.o", "simple.c",
|
||||
"CCCMD" => %w[${CC} -c -o ${_TARGET} -Dfoobar ${_SOURCES}])
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env["DEPFILESUFFIX"] = ".deppy"
|
||||
env.Object("simple.o", "simple.c")
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.add_builder(:Checker) do |target, sources, cache, env, vars|
|
||||
unless cache.up_to_date?(target, :Checker, sources, env)
|
||||
puts "Checker #{sources.first}" if env.echo != :off
|
||||
cache.register_build(target, :Checker, sources, env)
|
||||
end
|
||||
target
|
||||
end
|
||||
env.Program("simple.exe", "simple.c")
|
||||
env.Checker(:checker, "simple.exe")
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Preprocess("simplepp.c", "simple.c")
|
||||
env.Program("simple.exe", "simplepp.c")
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["PROGSUFFIX"] = ".out"
|
||||
env.Program("simple", Dir["*.c"])
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["MYSUFFIX"] = ".out"
|
||||
env.Program("simple${MYSUFFIX}", Dir["*.c"])
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program("simple", Dir["*.c"], "PROGSUFFIX" => ".xyz")
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program("simple.exe", Dir["*.c"])
|
||||
env.add_build_hook do |build_op|
|
||||
if build_op[:target].end_with?(".o")
|
||||
env.Disassemble("#{build_op[:target]}.txt", build_op[:target])
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
class MyObject < Rscons::Builder
|
||||
def run(options)
|
||||
target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
|
||||
env.run_builder(env.builders["Object"], target, sources, cache, vars)
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new do |env|
|
||||
env.add_builder(MyObject.new)
|
||||
env.MyObject("simple.o", "simple.c")
|
||||
env.Program("simple.exe", "simple.o")
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
class MyCommand < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
vars = vars.merge({
|
||||
"_TARGET" => target,
|
||||
"_SOURCES" => sources,
|
||||
})
|
||||
command = env.build_command("${CMD}", vars)
|
||||
cmd_desc = vars["CMD_DESC"] || "MyCommand"
|
||||
standard_build("#{cmd_desc} #{target}", target, command, sources, env, cache)
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new do |env|
|
||||
env.add_builder(MyCommand.new)
|
||||
command = %w[gcc -c -o ${_TARGET} ${_SOURCES}]
|
||||
env.MyCommand("simple.o", "simple.c", "CMD" => command)
|
||||
end
|
||||
Loaded 100 of 148 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user