rscons 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Yzg0NDA4ZjBmYzA5MGQ5MmFiM2QxZDIyNmI1Yzg5YWM4Y2Q2ZDViOQ==
4
+ NTA0YjY5YjRkMGY4Y2QxOGFjNzhlOTJjMmRjMzA5MjZiZjI2MTUzOQ==
5
5
  data.tar.gz: !binary |-
6
- Y2ZmMGVkZTEyYjY1NWY2YzNhYWI4ZmUyYmNhZGM1ZDVhMzdmNzRiZA==
6
+ MmJjM2ZmZjRkMGUwMTdjNjE3ZmFmNTI5NTVlYjFhNTg0YzNhMmNmNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2EzODEzMDZkYTUzMzkzNzIwZTcyOTMzNjk4NmVhMjM2MTc2MGZhYTZkNWIx
10
- ZjU2YzA3NWMzYzJiM2Q3OWRhMDYyMmEzZjRhMTkxYzM3YzAyZjUyY2Y5NGNk
11
- NjIzOGJkODlhOTVhZDVhZjkxOWI2OGU1ODk2NTVhY2VhNGI2Njg=
9
+ N2M3YjM1ZGI4ODEyNjI4M2E5YzhkNTU5NTI2MDFiMjE2MDY0ODRhNDI2YzM1
10
+ MTg1YmFlMTRkNWYyMjdjMzBiZTU2M2QzY2NjMDA2NzZlMDEwYmVhMGIxZjYy
11
+ NWY2YzAxNDQxMmFiZWNhNzk0MjZkODA4ZWEzMzMyZGNhMjFkMWU=
12
12
  data.tar.gz: !binary |-
13
- MDE5YzhkY2FjNmU3NGEzZWVkZDNjZDBiOGFiYTVmMDI0MmU1MjhhOTRhYTdm
14
- N2JhNGJlNzkxMjIzMzc4MDQwYTkzMDk3MzU1MjlmYzBhZTQyOTM3ZTlkMDAw
15
- Njg0MTU0YTUxOGFlNzJjZWNjMTIyZGJhZWY4MDcwZTA2ODQ3OWQ=
13
+ MmEwNDAzZTc1ZDgyMjEzODJhOGQ4Njk2ZDlkY2ZkZDc2ZGU1ZDk0ZGU3MDgw
14
+ NjdmZjNkMmZmNmQzZjI5NmFlN2NmMDg0ZWU1ZjczYzQyNjZmYWMzN2ZhMTcz
15
+ NWRlYjcxZDc3NWY5ODYyYmFjMmFmMGMwNTE2MDNmNmNiNjMxYTA=
data/README.md CHANGED
@@ -329,6 +329,15 @@ http://rubydoc.info/github/holtrop/rscons/frames.
329
329
 
330
330
  ## Release Notes
331
331
 
332
+ ### v1.4.2
333
+
334
+ - add Environment#expand_path
335
+ - expand construction variable references in builder targets and sources before invoking builder
336
+
337
+ ### v1.4.1
338
+
339
+ - fix invoking a builder with no sources while a build root defined
340
+
332
341
  ### v1.4.0
333
342
 
334
343
  - add CFile builder
@@ -172,7 +172,7 @@ module Rscons
172
172
  # called after the block returns.
173
173
  def process
174
174
  unless @targets.empty?
175
- clean_target_paths!
175
+ expand_paths!
176
176
  cache = Cache.instance
177
177
  cache.clear_checksum_cache!
178
178
  targets_processed = {}
@@ -337,24 +337,35 @@ module Rscons
337
337
  builder.run(target, sources, cache, self, vars)
338
338
  end
339
339
 
340
- private
340
+ # Expand a path to be relative to the Environment's build root.
341
+ #
342
+ # Paths beginning with "^/" are expanded by replacing "^" with the
343
+ # Environment's build root.
344
+ #
345
+ # @param path [String] The path to expand.
346
+ #
347
+ # @return [String] The expanded path.
348
+ def expand_path(path)
349
+ path.sub(%r{^\^(?=[\\/])}, @build_root)
350
+ end
341
351
 
342
- # Expand all target paths that begin with ^/ to be relative to the
343
- # Environment's build root, if present
344
- def clean_target_paths!
345
- if @build_root
346
- expand = lambda do |path|
347
- path.sub(%r{^\^(?=[\\/])}, @build_root)
348
- end
352
+ private
349
353
 
350
- new_targets = {}
351
- @targets.each_pair do |target, target_params|
352
- target_params[:sources].map! do |source|
353
- expand[source]
354
- end
355
- new_targets[expand[target]] = target_params
354
+ # Expand target and source paths before invoking builders.
355
+ #
356
+ # This method expand construction variable references in the target and
357
+ # source file names before passing them to the builder. It also expands
358
+ # "^/" prefixes to the Environment's build root if a build root is defined.
359
+ def expand_paths!
360
+ @targets = @targets.reduce({}) do |result, (target, target_params)|
361
+ sources = target_params[:sources].map do |source|
362
+ source = expand_path(source) if @build_root
363
+ expand_varref(source)
356
364
  end
357
- @targets = new_targets
365
+ target = expand_path(target) if @build_root
366
+ target = expand_varref(target)
367
+ result[target] = target_params.merge(sources: sources)
368
+ result
358
369
  end
359
370
  end
360
371
 
@@ -1,4 +1,4 @@
1
1
  module Rscons
2
2
  # gem version
3
- VERSION = "1.4.1"
3
+ VERSION = "1.4.2"
4
4
  end
@@ -498,4 +498,30 @@ EOF
498
498
  env.TestBuilder("file")
499
499
  end
500
500
  end
501
+
502
+ it "expands construction variables in builder target and sources before invoking the builder" do
503
+ test_dir('custom_builder')
504
+ class MySource < Rscons::Builder
505
+ def run(target, sources, cache, env, vars)
506
+ File.open(target, 'w') do |fh|
507
+ fh.puts <<EOF
508
+ #define THE_VALUE 678
509
+ EOF
510
+ end
511
+ target
512
+ end
513
+ end
514
+
515
+ Rscons::Environment.new do |env|
516
+ env["hdr"] = "inc.h"
517
+ env["src"] = "program.c"
518
+ env.add_builder(MySource.new)
519
+ env.MySource('${hdr}')
520
+ env.Program('program', "${src}")
521
+ end
522
+
523
+ lines.should == ['CC program.o', 'LD program']
524
+ File.exists?('inc.h').should be_true
525
+ `./program`.should == "The value is 678\n"
526
+ end
501
527
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rscons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Holtrop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core