rscons 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/lib/rscons/environment.rb +14 -6
- data/lib/rscons/version.rb +1 -1
- data/spec/build_tests_spec.rb +22 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -127,9 +127,9 @@ An Rscons::Environment consists of:
|
|
127
127
|
* a collection of targets to build
|
128
128
|
* a collection of build hooks
|
129
129
|
|
130
|
-
When cloning an environment, the construction variables
|
131
|
-
|
132
|
-
|
130
|
+
When cloning an environment, the construction variables and builders are
|
131
|
+
cloned, but the new environment does not inherit any of the targets, build
|
132
|
+
hooks, build directories, or the build root from the source environment.
|
133
133
|
|
134
134
|
Cloned environments contain "deep copies" of construction variables.
|
135
135
|
For example, in:
|
data/lib/rscons/environment.rb
CHANGED
@@ -9,6 +9,9 @@ module Rscons
|
|
9
9
|
# Hash of +{"builder_name" => builder_object}+ pairs.
|
10
10
|
attr_reader :builders
|
11
11
|
|
12
|
+
# String or +nil+
|
13
|
+
attr_accessor :build_root
|
14
|
+
|
12
15
|
# Create an Environment object.
|
13
16
|
# @param variables [Hash]
|
14
17
|
# The variables hash can contain construction variables, which are
|
@@ -42,10 +45,10 @@ module Rscons
|
|
42
45
|
|
43
46
|
# Make a copy of the Environment object.
|
44
47
|
# The cloned environment will contain a copy of all environment options,
|
45
|
-
# construction variables,
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
48
|
+
# construction variables, and builders. It will not contain a copy of the
|
49
|
+
# targets, build hooks, build directories, or the build root. If a block
|
50
|
+
# is given, the Environment object is yielded to the block and when the
|
51
|
+
# block returns, the {#process} method is automatically called.
|
49
52
|
def clone(variables = {})
|
50
53
|
env = Environment.new()
|
51
54
|
@builders.each do |builder_name, builder|
|
@@ -88,14 +91,19 @@ module Rscons
|
|
88
91
|
# This method takes into account the Environment's build directories.
|
89
92
|
def get_build_fname(source_fname, suffix)
|
90
93
|
build_fname = source_fname.set_suffix(suffix).gsub('\\', '/')
|
91
|
-
@build_dirs.
|
94
|
+
found_match = @build_dirs.find do |src_dir, obj_dir|
|
92
95
|
if src_dir.is_a?(Regexp)
|
93
96
|
build_fname.sub!(src_dir, obj_dir)
|
94
97
|
else
|
95
98
|
build_fname.sub!(%r{^#{src_dir}/}, "#{obj_dir}/")
|
96
99
|
end
|
97
|
-
build_fname.gsub!('\\', '/')
|
98
100
|
end
|
101
|
+
if @build_root and not found_match
|
102
|
+
unless source_fname.start_with?('/') or source_fname =~ %r{^\w:[\\/]}
|
103
|
+
build_fname = "#{@build_root}/#{build_fname}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
build_fname.gsub!('\\', '/')
|
99
107
|
build_fname
|
100
108
|
end
|
101
109
|
|
data/lib/rscons/version.rb
CHANGED
data/spec/build_tests_spec.rb
CHANGED
@@ -158,6 +158,28 @@ describe Rscons do
|
|
158
158
|
File.exists?('build_two/two.o').should be_true
|
159
159
|
end
|
160
160
|
|
161
|
+
it 'uses build directories before build root' do
|
162
|
+
test_dir('build_dir')
|
163
|
+
Rscons::Environment.new do |env|
|
164
|
+
env.append('CPPPATH' => Dir['src/**/*/'])
|
165
|
+
env.build_dir("src", "build")
|
166
|
+
env.build_root = "build_root"
|
167
|
+
env.Program('build_dir', Dir['src/**/*.c'])
|
168
|
+
end
|
169
|
+
lines.should == ["CC build/one/one.o", "CC build/two/two.o", "LD build_dir"]
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'uses build_root if no build directories match' do
|
173
|
+
test_dir('build_dir')
|
174
|
+
Rscons::Environment.new do |env|
|
175
|
+
env.append('CPPPATH' => Dir['src/**/*/'])
|
176
|
+
env.build_dir("src2", "build")
|
177
|
+
env.build_root = "build_root"
|
178
|
+
env.Program('build_dir', Dir['src/**/*.c'])
|
179
|
+
end
|
180
|
+
lines.should == ["CC build_root/src/one/one.o", "CC build_root/src/two/two.o", "LD build_dir"]
|
181
|
+
end
|
182
|
+
|
161
183
|
it 'cleans built files' do
|
162
184
|
test_dir('build_dir')
|
163
185
|
Rscons::Environment.new do |env|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rscons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-core
|
@@ -217,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
217
|
version: '0'
|
218
218
|
segments:
|
219
219
|
- 0
|
220
|
-
hash:
|
220
|
+
hash: -353770733
|
221
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
222
|
none: false
|
223
223
|
requirements:
|
@@ -226,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
226
|
version: '0'
|
227
227
|
segments:
|
228
228
|
- 0
|
229
|
-
hash:
|
229
|
+
hash: -353770733
|
230
230
|
requirements: []
|
231
231
|
rubyforge_project:
|
232
232
|
rubygems_version: 1.8.23
|