Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
No files matched your search
+7
-18
@@ -1,18 +1,7 @@
|
|||||||
*.gem
|
/.bundle/
|
||||||
*.rbc
|
/.yardoc/
|
||||||
.bundle
|
/_yardoc/
|
||||||
.config
|
/build_test_run/
|
||||||
.yardoc
|
/coverage/
|
||||||
Gemfile.lock
|
/doc/
|
||||||
InstalledFiles
|
/pkg/
|
||||||
_yardoc
|
|
||||||
coverage
|
|
||||||
doc/
|
|
||||||
lib/bundler/man
|
|
||||||
pkg
|
|
||||||
rdoc
|
|
||||||
spec/reports
|
|
||||||
test/tmp
|
|
||||||
test/version_tmp
|
|
||||||
tmp
|
|
||||||
build_test_run
|
|
||||||
+190
@@ -0,0 +1,190 @@
|
|||||||
|
## ChangeLog
|
||||||
|
|
||||||
|
### 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,50 @@
|
|||||||
|
PATH
|
||||||
|
remote: .
|
||||||
|
specs:
|
||||||
|
rscons (1.15.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.0.0)
|
||||||
|
rdoc (5.1.0)
|
||||||
|
redcarpet (3.4.0)
|
||||||
|
rspec (3.6.0)
|
||||||
|
rspec-core (~> 3.6.0)
|
||||||
|
rspec-expectations (~> 3.6.0)
|
||||||
|
rspec-mocks (~> 3.6.0)
|
||||||
|
rspec-core (3.6.0)
|
||||||
|
rspec-support (~> 3.6.0)
|
||||||
|
rspec-expectations (3.6.0)
|
||||||
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
|
rspec-support (~> 3.6.0)
|
||||||
|
rspec-mocks (3.6.0)
|
||||||
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
|
rspec-support (~> 3.6.0)
|
||||||
|
rspec-support (3.6.0)
|
||||||
|
simplecov (0.15.0)
|
||||||
|
docile (~> 1.1.0)
|
||||||
|
json (>= 1.8, < 3)
|
||||||
|
simplecov-html (~> 0.10.0)
|
||||||
|
simplecov-html (0.10.2)
|
||||||
|
yard (0.9.9)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
ruby
|
||||||
|
x86-mingw32
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
rake
|
||||||
|
rdoc
|
||||||
|
redcarpet
|
||||||
|
rscons!
|
||||||
|
rspec
|
||||||
|
simplecov
|
||||||
|
yard
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
1.15.4
|
||||||
@@ -1,35 +1,36 @@
|
|||||||
# Rscons
|
# Rscons
|
||||||
|
|
||||||
Software construction library inspired by SCons and implemented in Ruby
|
Rscons is a software construction framework inspired by SCons and implemented
|
||||||
|
in Ruby.
|
||||||
|
|
||||||
[](http://badge.fury.io/rb/rscons)
|
[](http://badge.fury.io/rb/rscons)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Add this line to your application's Gemfile:
|
|
||||||
|
|
||||||
gem "rscons"
|
|
||||||
|
|
||||||
And then execute:
|
|
||||||
|
|
||||||
$ bundle
|
|
||||||
|
|
||||||
Or install it yourself as:
|
|
||||||
|
|
||||||
$ gem install rscons
|
$ gem install rscons
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Rscons is a Ruby library.
|
### Standalone
|
||||||
It can be called from a standalone Ruby script or it can be used with rake and
|
|
||||||
called from your Rakefile.
|
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
|
### Example: Building a C Program
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
Rscons::Environment.new do |env|
|
Rscons::Environment.new do |env|
|
||||||
env["CFLAGS"] << "-Wall"
|
env["CFLAGS"] << "-Wall"
|
||||||
env.Program("program", Dir["**/*.c"])
|
env.Program("program", Dir["src/**/*.c"])
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ end
|
|||||||
```ruby
|
```ruby
|
||||||
Rscons::Environment.new do |env|
|
Rscons::Environment.new do |env|
|
||||||
env["DFLAGS"] << "-Wall"
|
env["DFLAGS"] << "-Wall"
|
||||||
env.Program("program", Dir["**/*.d"])
|
env.Program("program", Dir["src/**/*.d"])
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -154,6 +155,31 @@ Rscons::Environment.new do |env|
|
|||||||
end
|
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
|
### Example: Using different compilation flags for some sources
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@@ -169,19 +195,6 @@ Rscons::Environment.new do |env|
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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
|
|
||||||
* `: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.
|
|
||||||
|
|
||||||
### Example: Creating a static library
|
### Example: Creating a static library
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@@ -190,33 +203,44 @@ Rscons::Environment.new do |env|
|
|||||||
end
|
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
|
## Details
|
||||||
|
|
||||||
### Default Builders
|
### Environments
|
||||||
|
|
||||||
Rscons ships with a number of default builders:
|
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.
|
||||||
|
|
||||||
* Library, which collects object files into a static library archive file
|
An Environment consists of:
|
||||||
* Object, which compiles source files to produce an object file
|
|
||||||
* Program, which links object files to produce an executable
|
|
||||||
|
|
||||||
If you want to create an Environment that does not contain any builders,
|
|
||||||
you can use the `exclude_builders` key to the Environment constructor.
|
|
||||||
|
|
||||||
### Managing Environments
|
|
||||||
|
|
||||||
An Rscons::Environment consists of:
|
|
||||||
|
|
||||||
* a collection of construction variables
|
|
||||||
* a collection of builders
|
* a collection of builders
|
||||||
|
* a collection of construction variables used by those builders
|
||||||
* a mapping of build directories from source directories
|
* a mapping of build directories from source directories
|
||||||
* a default build root to apply if no build directories are matched
|
* a default build root to apply if no specific build directories are matched
|
||||||
* a collection of targets to build
|
* a collection of user-defined build targets
|
||||||
* a collection of build hooks
|
* a collection of user-defined build hooks
|
||||||
|
|
||||||
When cloning an environment, the construction variables and builders are
|
When cloning an environment, by default the construction variables, builders,
|
||||||
cloned, but the new environment does not inherit any of the targets, build
|
build hooks, build directories, and build root are cloned, but the new
|
||||||
hooks, build directories, or the build root from the source environment.
|
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.
|
Cloned environments contain "deep copies" of construction variables.
|
||||||
For example, in:
|
For example, in:
|
||||||
@@ -230,27 +254,313 @@ cloned_env["CPPPATH"] << "three"
|
|||||||
|
|
||||||
`base_env["CPPPATH"]` will not include "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", Dir["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", Dir["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", Dir["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}"] |
|
||||||
|
| 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}"] |
|
||||||
|
| 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}"] |
|
||||||
|
| 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}", "${INCPREFIX}${D_IMPORT_PATH}", "${DFLAGS}", "${_SOURCES}"] |
|
||||||
|
| 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", *Dir.glob("assets/**/*"))
|
||||||
|
```
|
||||||
|
|
||||||
### Construction Variable Naming
|
### Construction Variable Naming
|
||||||
|
|
||||||
* uppercase strings - the default construction variables that Rscons uses
|
* uppercase strings - the default construction variables that Rscons uses
|
||||||
* lowercase symbols - Rscons options
|
* strings beginning with "_" - set and used internally by builders
|
||||||
* lowercase strings - reserved as user-defined construction variables
|
* symbols, lowercase strings - reserved as user-defined construction variables
|
||||||
|
|
||||||
### API documentation
|
### API documentation
|
||||||
|
|
||||||
Documentation for the complete Rscons API can be found at
|
Documentation for the complete Rscons API can be found at
|
||||||
http://rubydoc.info/github/holtrop/rscons/frames.
|
http://www.rubydoc.info/github/holtrop/rscons/master.
|
||||||
|
|
||||||
## Release Notes
|
|
||||||
|
|
||||||
### 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
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|||||||
+10
-9
@@ -8,19 +8,20 @@ end
|
|||||||
require "bundler/gem_tasks"
|
require "bundler/gem_tasks"
|
||||||
require "rspec/core/rake_task"
|
require "rspec/core/rake_task"
|
||||||
require "yard"
|
require "yard"
|
||||||
|
require "rake/clean"
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new(:spec)
|
CLEAN.include %w[build_test_run .yardoc doc coverage]
|
||||||
|
CLOBBER.include %w[pkg]
|
||||||
|
|
||||||
|
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::Rake::YardocTask.new do |yard|
|
||||||
yard.files = ['lib/**/*.rb']
|
yard.files = ['lib/**/*.rb']
|
||||||
end
|
end
|
||||||
|
|
||||||
task :default => :spec
|
task :default => :spec
|
||||||
|
|
||||||
task :clean do
|
|
||||||
FileUtils.rm_rf(["build_test_run", "doc", "coverage"])
|
|
||||||
end
|
|
||||||
|
|
||||||
task :clobber => :clean do
|
|
||||||
FileUtils.rm_rf(["pkg"])
|
|
||||||
end
|
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
require "rscons/cli"
|
||||||
|
|
||||||
|
Rscons::Cli.run(ARGV)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.append('CPPPATH' => Dir['src/**/*/'].sort)
|
||||||
|
env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/')
|
||||||
|
env.Program('build_dir.exe', Dir['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' => Dir['src/**/*/'].sort)
|
||||||
|
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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
env = Rscons::Environment.new do |env|
|
||||||
|
env.append('CPPPATH' => Dir['src/**/*/'].sort)
|
||||||
|
env.build_dir("src", "build")
|
||||||
|
env.build_root = "build_root"
|
||||||
|
env.Program('build_dir.exe', Dir['src/**/*.c'])
|
||||||
|
end
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
Rscons::Environment.new(echo: :command) do |env|
|
||||||
|
env.append('CPPPATH' => Dir['src/**/*/'].sort)
|
||||||
|
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', Dir['src/**/*.c'].sort)
|
||||||
|
end
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
Rscons::Environment.new(echo: :command) do |env|
|
||||||
|
env.append('CPPPATH' => Dir['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", Dir['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"] += Dir["src/**/"]
|
||||||
|
env.Program("build_dir.exe", Dir["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' => Dir['src/**/*/'].sort)
|
||||||
|
env.build_dir("src2", "build")
|
||||||
|
env.build_root = "build_root"
|
||||||
|
env.Program('build_dir.exe', Dir['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" => Dir["src/**/*/"].sort)
|
||||||
|
env.build_dir("src/one/", "build_one/")
|
||||||
|
env.build_dir("src/two", "build_two")
|
||||||
|
env.Program("build_dir.exe", Dir["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
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
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
|
||||||
@@ -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", Dir["*.d"])
|
||||||
|
end
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.Program('header.exe', 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" }
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
Rscons::Environment.new(echo: :command) do |env|
|
||||||
|
env.Program('library.exe', ['lib.a', 'three.c'])
|
||||||
|
env.Library("lib.a", ['one.c', 'two.c'], 'CPPFLAGS' => ['-Dmake_lib'])
|
||||||
|
end
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
Rscons::Environment.new(echo: :command) do |env|
|
||||||
|
env["ARCMD"] = %w[ar rcf ${_TARGET} ${_SOURCES}]
|
||||||
|
env.Library("lib.a", Dir["*.c"].sort)
|
||||||
|
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", Dir["src/lib/*.c"])
|
||||||
|
env.Program("test-shared.exe",
|
||||||
|
Dir["src/*.c"],
|
||||||
|
"LIBPATH" => %w[.],
|
||||||
|
"LIBS" => %w[mine])
|
||||||
|
env.build_after("test-shared.exe", libmine.to_s)
|
||||||
|
env.Program("test-static.exe",
|
||||||
|
Dir["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", Dir["src/lib/*.cc"])
|
||||||
|
env.Program("test-shared.exe",
|
||||||
|
Dir["src/*.cc"],
|
||||||
|
"LIBPATH" => %w[.],
|
||||||
|
"LIBS" => %w[mine])
|
||||||
|
env.build_after("test-shared.exe", libmine.to_s)
|
||||||
|
env.Program("test-static.exe",
|
||||||
|
Dir["src/**/*.cc"])
|
||||||
|
end
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env["CPPPATH"] << "src/lib"
|
||||||
|
libmine = env.SharedLibrary("mine", Dir["src/lib/*.d"])
|
||||||
|
env.Program("test-shared.exe",
|
||||||
|
Dir["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", Dir["src/lib/*.c"])
|
||||||
|
env.Program("test-shared.exe",
|
||||||
|
Dir["src/*.c"],
|
||||||
|
"LIBPATH" => %w[.],
|
||||||
|
"LIBS" => %w[mine])
|
||||||
|
env.build_after("test-shared.exe", libmine.to_s)
|
||||||
|
env.Program("test-static.exe",
|
||||||
|
Dir["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
|
||||||
@@ -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,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,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"] = Dir["*.c"].sort
|
||||||
|
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
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
class ThreadedTestBuilder < Rscons::Builder
|
||||||
|
def run(options)
|
||||||
|
command = ["ruby", "-e", %[sleep 1]]
|
||||||
|
Rscons::ThreadedCommand.new(
|
||||||
|
command,
|
||||||
|
short_description: "ThreadedTestBuilder #{options[:target]}")
|
||||||
|
end
|
||||||
|
def finalize(options)
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class NonThreadedTestBuilder < Rscons::Builder
|
||||||
|
def run(options)
|
||||||
|
puts "NonThreadedTestBuilder #{options[:target]}"
|
||||||
|
sleep 1
|
||||||
|
options[:target]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.add_builder(ThreadedTestBuilder.new)
|
||||||
|
env.add_builder(NonThreadedTestBuilder.new)
|
||||||
|
env.ThreadedTestBuilder("a")
|
||||||
|
env.ThreadedTestBuilder("b")
|
||||||
|
env.ThreadedTestBuilder("c")
|
||||||
|
env.NonThreadedTestBuilder("d")
|
||||||
|
end
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
class TestBuilder < Rscons::Builder
|
||||||
|
def run(options)
|
||||||
|
target, env, vars, cache = options.values_at(:target, :env, :vars, :cache)
|
||||||
|
if target == "two"
|
||||||
|
return false unless File.exists?("one")
|
||||||
|
end
|
||||||
|
wait_time = env.expand_varref("${wait_time}", vars)
|
||||||
|
command = ["ruby", "-e", "require 'fileutils'; sleep #{wait_time}; FileUtils.touch('#{target}');"]
|
||||||
|
standard_threaded_build("TestBuilder", target, command, [], env, cache)
|
||||||
|
end
|
||||||
|
|
||||||
|
def finalize(options)
|
||||||
|
standard_finalize(options)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.add_builder(TestBuilder.new)
|
||||||
|
env.TestBuilder("one", [], "wait_time" => "3")
|
||||||
|
env.TestBuilder("two", [], "wait_time" => "0")
|
||||||
|
env.depends("two", "one")
|
||||||
|
end
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
Rscons::Environment.new do |env|
|
||||||
|
program = env.Program("simple.exe", Dir["*.c"])
|
||||||
|
env.depends(program, "program.ld")
|
||||||
|
end
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
class Fail < Rscons::Builder
|
||||||
|
def run(options)
|
||||||
|
target, cache, env, vars = options.values_at(:target, :cache, :env, :vars)
|
||||||
|
wait_time = env.expand_varref("${wait_time}", vars)
|
||||||
|
ruby_command = %[sleep #{wait_time}; exit 2]
|
||||||
|
command = %W[ruby -e #{ruby_command}]
|
||||||
|
standard_threaded_build("Fail #{target}", target, command, [], env, cache)
|
||||||
|
end
|
||||||
|
def finalize(options)
|
||||||
|
standard_finalize(options)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.add_builder(Fail.new)
|
||||||
|
4.times do |i|
|
||||||
|
wait_time = i + 1
|
||||||
|
env.Fail("foo_#{wait_time}", [], "wait_time" => wait_time.to_s)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.Program('simple.exe', Dir['*.cc'])
|
||||||
|
end
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env["CXXSUFFIX"] = %w[.cccc .cc]
|
||||||
|
env["CXXFLAGS"] += %w[-x c++]
|
||||||
|
env.Program("simple.exe", Dir["*.cc"] + Dir["*.cccc"])
|
||||||
|
end
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.Preprocess("simplepp.cc", "simple.cc")
|
||||||
|
env.Program("simple.exe", "simplepp.cc")
|
||||||
|
end
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
Rscons::Environment.new(echo: :command) do |env|
|
||||||
|
env.Object("one.o", "one.c", 'CPPFLAGS' => ['-DONE'])
|
||||||
|
env.Program('two_sources.exe', ['one.o', 'two.c'])
|
||||||
|
end
|
||||||
Loaded 100 of 137 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user