rscons 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.md +44 -11
- data/lib/rscons.rb +21 -10
- data/lib/rscons/builders/object.rb +4 -4
- data/lib/rscons/builders/program.rb +2 -2
- data/lib/rscons/environment.rb +3 -3
- data/lib/rscons/version.rb +1 -1
- metadata +5 -32
- data/lib/rscons/monkey/string.rb +0 -25
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTdiYzZmYzkzY2U5MTI1MGMwZjlmNDFmZGFkY2NmY2Y5NDQxZTllOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MTVlMzQxYTUwMzY2OWViZGI1ZDAwYzQ4OTgyMjYyY2FjYmU5MzdhYg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTNhNGM4MzRhZDcwODdlM2Q0NmQ2Y2UzOWQ2ZDk5ZmY5M2IwMGY5NzBmMzdh
|
10
|
+
YTYxYTA0NTgzMzk3NzA4MDMzN2U5NWQ0ZjEyMmVkZWE5ZWRlZjNiZGNmZTQ4
|
11
|
+
NTgwY2QxYTFmZmY3NzE2MmU1NWJiZmQyMjg0OGUxMWY0MWZlMDI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MzJjYzUwNmRjNDQyMGUxNjM3OTIzMzVlNWFlZDllNmI3YWUzYWIwMWI4MTc5
|
14
|
+
OWQ0NmExNjk3NWZmN2NhNDExMDgxZjA2NjZmZGYzMzZmZTRlZTRmYWUzMGIz
|
15
|
+
ZjA2YjM3NTBlYjY2MzgyNTczOTBiYTA0Y2UzYWYyMDc3ODNlMzc=
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ called from your Rakefile.
|
|
27
27
|
### Example: Building a C Program
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
|
30
|
+
Rscons::Environment.new do |env|
|
31
31
|
env["CFLAGS"] << "-Wall"
|
32
32
|
env.Program("program", Dir["**/*.c"])
|
33
33
|
end
|
@@ -36,7 +36,7 @@ end
|
|
36
36
|
### Example: Building a D Program
|
37
37
|
|
38
38
|
```ruby
|
39
|
-
|
39
|
+
Rscons::Environment.new do |env|
|
40
40
|
env["DFLAGS"] << "-Wall"
|
41
41
|
env.Program("program", Dir["**/*.d"])
|
42
42
|
end
|
@@ -45,7 +45,7 @@ end
|
|
45
45
|
### Example: Cloning an Environment
|
46
46
|
|
47
47
|
```ruby
|
48
|
-
main_env =
|
48
|
+
main_env = Rscons::Environment.new do |env|
|
49
49
|
# Store object files from sources under "src" in "build/main"
|
50
50
|
env.build_dir("src", "build/main")
|
51
51
|
env["CFLAGS"] = ["-DSOME_DEFINE", "-O3"]
|
@@ -64,6 +64,11 @@ end
|
|
64
64
|
|
65
65
|
### Example: Custom Builder
|
66
66
|
|
67
|
+
Custom builders are implemented as classes which extend from `Rscons::Builder`.
|
68
|
+
The builder must have a `run` method which is called to invoke the builder.
|
69
|
+
The `run` method should return the name of the target built on success, and
|
70
|
+
`false` on failure.
|
71
|
+
|
67
72
|
```ruby
|
68
73
|
class GenerateFoo < Rscons::Builder
|
69
74
|
def run(target, sources, cache, env, vars)
|
@@ -73,10 +78,12 @@ class GenerateFoo < Rscons::Builder
|
|
73
78
|
#define GENERATED 42
|
74
79
|
EOF
|
75
80
|
end
|
81
|
+
target
|
76
82
|
end
|
77
83
|
end
|
78
84
|
|
79
85
|
Rscons::Environment.new do |env|
|
86
|
+
env.add_builder(GenerateFoo.new)
|
80
87
|
env.GenerateFoo("foo.h", [])
|
81
88
|
env.Program("a.out", Dir["*.c"])
|
82
89
|
end
|
@@ -93,16 +100,23 @@ class CmdBuilder < Rscons::Builder
|
|
93
100
|
system(cmd)
|
94
101
|
cache.register_build(target, cmd, sources, env)
|
95
102
|
end
|
103
|
+
target
|
96
104
|
end
|
97
105
|
end
|
98
106
|
|
99
107
|
Rscons::Environment.new do |env|
|
108
|
+
env.add_builder(CmdBuilder.new)
|
100
109
|
env.CmdBuilder("foo.gen", "foo_gen.cfg")
|
101
110
|
end
|
102
111
|
```
|
103
112
|
|
104
113
|
### Example: Custom Builder Using Builder#standard_build()
|
105
114
|
|
115
|
+
The `standard_build` method from the `Rscons::Builder` base class can be used
|
116
|
+
when the builder needs to execute a system command to produce the target file.
|
117
|
+
The `standard_build` method will return the correct value so its return value
|
118
|
+
can be used as the return value from the `run` method.
|
119
|
+
|
106
120
|
```ruby
|
107
121
|
class CmdBuilder < Rscons::Builder
|
108
122
|
def run(target, sources, cache, env, vars)
|
@@ -112,6 +126,7 @@ class CmdBuilder < Rscons::Builder
|
|
112
126
|
end
|
113
127
|
|
114
128
|
Rscons::Environment.new do |env|
|
129
|
+
env.add_builder(CmdBuilder.new)
|
115
130
|
env.CmdBuilder("foo.gen", "foo_gen.cfg")
|
116
131
|
end
|
117
132
|
```
|
@@ -131,6 +146,19 @@ Rscons::Environment.new do |env|
|
|
131
146
|
end
|
132
147
|
```
|
133
148
|
|
149
|
+
Each build hook block will be invoked for every build operation, so the block
|
150
|
+
should test the target or sources if its action should only apply to some
|
151
|
+
subset of build targets or source files.
|
152
|
+
|
153
|
+
The `build_op` parameter to the build hook block is a Hash describing the
|
154
|
+
build operation with the following keys:
|
155
|
+
* `:builder` - `Builder` instance in use
|
156
|
+
* `:target` - `String` name of the target file
|
157
|
+
* `:sources` - `Array` of the source files
|
158
|
+
* `:vars` - `Rscons::VarSet` containing the construction variables to use
|
159
|
+
The build hook can overwrite entries in `build_op[:vars]` to alter the
|
160
|
+
construction variables in use for this specific build operation.
|
161
|
+
|
134
162
|
### Example: Creating a static library
|
135
163
|
|
136
164
|
```ruby
|
@@ -149,8 +177,8 @@ Rscons ships with a number of default builders:
|
|
149
177
|
* Object, which compiles source files to produce an object file
|
150
178
|
* Program, which links object files to produce an executable
|
151
179
|
|
152
|
-
If you want to create an Environment that does not contain any
|
153
|
-
|
180
|
+
If you want to create an Environment that does not contain any builders,
|
181
|
+
you can use the `exclude_builders` key to the Environment constructor.
|
154
182
|
|
155
183
|
### Managing Environments
|
156
184
|
|
@@ -158,7 +186,8 @@ An Rscons::Environment consists of:
|
|
158
186
|
|
159
187
|
* a collection of construction variables
|
160
188
|
* a collection of builders
|
161
|
-
* a mapping of build directories
|
189
|
+
* a mapping of build directories from source directories
|
190
|
+
* a default build root to apply if no build directories are matched
|
162
191
|
* a collection of targets to build
|
163
192
|
* a collection of build hooks
|
164
193
|
|
@@ -178,12 +207,16 @@ cloned_env["CPPPATH"] << "three"
|
|
178
207
|
|
179
208
|
`base_env["CPPPATH"]` will not include "three".
|
180
209
|
|
181
|
-
### Construction
|
210
|
+
### Construction Variable Naming
|
211
|
+
|
212
|
+
* uppercase strings - the default construction variables that Rscons uses
|
213
|
+
* lowercase symbols - Rscons options
|
214
|
+
* lowercase strings - reserved as user-defined construction variables
|
215
|
+
|
216
|
+
### API documentation
|
182
217
|
|
183
|
-
|
184
|
-
|
185
|
-
Rscons options are lowercase symbols.
|
186
|
-
Lowercase strings are reserved as user-defined construction variables.
|
218
|
+
Documentation for the complete Rscons API can be found at
|
219
|
+
http://rubydoc.info/github/holtrop/rscons/frames.
|
187
220
|
|
188
221
|
## Contributing
|
189
222
|
|
data/lib/rscons.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
require "rscons/monkey/string"
|
1
|
+
require_relative "rscons/builder"
|
2
|
+
require_relative "rscons/cache"
|
3
|
+
require_relative "rscons/environment"
|
4
|
+
require_relative "rscons/varset"
|
5
|
+
require_relative "rscons/version"
|
8
6
|
|
9
7
|
# default builders
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
require_relative "rscons/builders/library"
|
9
|
+
require_relative "rscons/builders/object"
|
10
|
+
require_relative "rscons/builders/program"
|
13
11
|
|
14
12
|
# Namespace module for rscons classes
|
15
13
|
module Rscons
|
@@ -37,4 +35,17 @@ module Rscons
|
|
37
35
|
end
|
38
36
|
Cache.clear
|
39
37
|
end
|
38
|
+
|
39
|
+
# Return whether the given path is an absolute filesystem path or not
|
40
|
+
# @param path [String] the path to examine
|
41
|
+
def self.absolute_path?(path)
|
42
|
+
path =~ %r{^(/|\w:[\\/])}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Return a new path by changing the suffix in path to suffix.
|
46
|
+
# @param path [String] the path to alter
|
47
|
+
# @param suffix [String] the new filename suffix
|
48
|
+
def self.set_suffix(path, suffix)
|
49
|
+
path.sub(/\.[^.]*$/, suffix)
|
50
|
+
end
|
40
51
|
end
|
@@ -46,8 +46,8 @@ module Rscons
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def produces?(target, source, env)
|
49
|
-
target.
|
50
|
-
source.
|
49
|
+
target.end_with?(*env['OBJSUFFIX']) and KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
50
|
+
source.end_with?(*env[suffix_var])
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -55,10 +55,10 @@ module Rscons
|
|
55
55
|
vars = vars.merge({
|
56
56
|
'_TARGET' => target,
|
57
57
|
'_SOURCES' => sources,
|
58
|
-
'_DEPFILE' =>
|
58
|
+
'_DEPFILE' => Rscons.set_suffix(target, '.mf'),
|
59
59
|
})
|
60
60
|
com_prefix = KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
61
|
-
sources.first.
|
61
|
+
sources.first.end_with?(*env[suffix_var])
|
62
62
|
end.tap do |v|
|
63
63
|
v.nil? and raise "Error: unknown input file type: #{sources.first.inspect}"
|
64
64
|
end.first
|
@@ -21,9 +21,9 @@ module Rscons
|
|
21
21
|
return false unless objects
|
22
22
|
ld = if env["LD"]
|
23
23
|
env["LD"]
|
24
|
-
elsif sources.find {|s| s.
|
24
|
+
elsif sources.find {|s| s.end_with?(*env["DSUFFIX"])}
|
25
25
|
env["DC"]
|
26
|
-
elsif sources.find {|s| s.
|
26
|
+
elsif sources.find {|s| s.end_with?(*env["CXXSUFFIX"])}
|
27
27
|
env["CXX"]
|
28
28
|
else
|
29
29
|
env["CC"]
|
data/lib/rscons/environment.rb
CHANGED
@@ -102,7 +102,7 @@ module Rscons
|
|
102
102
|
# Return the file name to be built from source_fname with suffix suffix.
|
103
103
|
# This method takes into account the Environment's build directories.
|
104
104
|
def get_build_fname(source_fname, suffix)
|
105
|
-
build_fname =
|
105
|
+
build_fname = Rscons.set_suffix(source_fname, suffix).gsub('\\', '/')
|
106
106
|
found_match = @build_dirs.find do |src_dir, obj_dir|
|
107
107
|
if src_dir.is_a?(Regexp)
|
108
108
|
build_fname.sub!(src_dir, obj_dir)
|
@@ -111,7 +111,7 @@ module Rscons
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
if @build_root and not found_match
|
114
|
-
unless
|
114
|
+
unless Rscons.absolute_path?(source_fname) or build_fname.start_with?("#{@build_root}/")
|
115
115
|
build_fname = "#{@build_root}/#{build_fname}"
|
116
116
|
end
|
117
117
|
end
|
@@ -254,7 +254,7 @@ module Rscons
|
|
254
254
|
# Return a list of the converted file names.
|
255
255
|
def build_sources(sources, suffixes, cache, vars)
|
256
256
|
sources.map do |source|
|
257
|
-
if source.
|
257
|
+
if source.end_with?(*suffixes)
|
258
258
|
source
|
259
259
|
else
|
260
260
|
converted = nil
|
data/lib/rscons/version.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rscons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Josh Holtrop
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-02-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec-core
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec-mocks
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec-expectations
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ! '>='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rake
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ! '>='
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ! '>='
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: simplecov
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ! '>='
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ! '>='
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -110,7 +97,6 @@ dependencies:
|
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: json
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - ! '>='
|
116
102
|
- !ruby/object:Gem::Version
|
@@ -118,7 +104,6 @@ dependencies:
|
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - ! '>='
|
124
109
|
- !ruby/object:Gem::Version
|
@@ -126,7 +111,6 @@ dependencies:
|
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: rdoc
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
115
|
- - ! '>='
|
132
116
|
- !ruby/object:Gem::Version
|
@@ -134,7 +118,6 @@ dependencies:
|
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
122
|
- - ! '>='
|
140
123
|
- !ruby/object:Gem::Version
|
@@ -142,7 +125,6 @@ dependencies:
|
|
142
125
|
- !ruby/object:Gem::Dependency
|
143
126
|
name: yard
|
144
127
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
128
|
requirements:
|
147
129
|
- - ! '>='
|
148
130
|
- !ruby/object:Gem::Version
|
@@ -150,7 +132,6 @@ dependencies:
|
|
150
132
|
type: :development
|
151
133
|
prerelease: false
|
152
134
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
135
|
requirements:
|
155
136
|
- - ! '>='
|
156
137
|
- !ruby/object:Gem::Version
|
@@ -190,7 +171,6 @@ files:
|
|
190
171
|
- lib/rscons/builders/program.rb
|
191
172
|
- lib/rscons/cache.rb
|
192
173
|
- lib/rscons/environment.rb
|
193
|
-
- lib/rscons/monkey/string.rb
|
194
174
|
- lib/rscons/varset.rb
|
195
175
|
- lib/rscons/version.rb
|
196
176
|
- rscons.gemspec
|
@@ -203,33 +183,26 @@ files:
|
|
203
183
|
homepage: https://github.com/holtrop/rscons
|
204
184
|
licenses:
|
205
185
|
- MIT
|
186
|
+
metadata: {}
|
206
187
|
post_install_message:
|
207
188
|
rdoc_options: []
|
208
189
|
require_paths:
|
209
190
|
- lib
|
210
191
|
required_ruby_version: !ruby/object:Gem::Requirement
|
211
|
-
none: false
|
212
192
|
requirements:
|
213
193
|
- - ! '>='
|
214
194
|
- !ruby/object:Gem::Version
|
215
195
|
version: '0'
|
216
|
-
segments:
|
217
|
-
- 0
|
218
|
-
hash: -725097361
|
219
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
|
-
none: false
|
221
197
|
requirements:
|
222
198
|
- - ! '>='
|
223
199
|
- !ruby/object:Gem::Version
|
224
200
|
version: '0'
|
225
|
-
segments:
|
226
|
-
- 0
|
227
|
-
hash: -725097361
|
228
201
|
requirements: []
|
229
202
|
rubyforge_project:
|
230
|
-
rubygems_version:
|
203
|
+
rubygems_version: 2.2.1
|
231
204
|
signing_key:
|
232
|
-
specification_version:
|
205
|
+
specification_version: 4
|
233
206
|
summary: Software construction library inspired by SCons and implemented in Ruby
|
234
207
|
test_files:
|
235
208
|
- spec/build_tests_spec.rb
|
data/lib/rscons/monkey/string.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# Standard Ruby String class.
|
2
|
-
class String
|
3
|
-
# Check if the given string ends with any of the supplied suffixes
|
4
|
-
# @param suffix [String, Array] The suffix to look for.
|
5
|
-
# @return a true value if the string ends with one of the suffixes given.
|
6
|
-
def has_suffix?(suffix)
|
7
|
-
if suffix
|
8
|
-
suffix = [suffix] if suffix.is_a?(String)
|
9
|
-
suffix = suffix.flatten
|
10
|
-
suffix.find {|s| self.end_with?(s)}
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Return a new string with the suffix (dot character and extension) changed
|
15
|
-
# to the given suffix.
|
16
|
-
# @param suffix [String] The new suffix.
|
17
|
-
def set_suffix(suffix = '')
|
18
|
-
sub(/\.[^.]*$/, suffix)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Return whether the string represents an absolute filesystem path
|
22
|
-
def absolute_path?
|
23
|
-
self =~ %r{^(/|\w:[\\/])}
|
24
|
-
end
|
25
|
-
end
|