rscons 1.1.0 → 1.2.0

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
- MTQxY2I3MDZhNDdhOGNmMDZkM2ZmZjQ1OWRmZjNkZTgwNDlkYzQ5MA==
4
+ MWUxZmFhZjYxM2JhN2QzNTE0OWVkODEwMGQxMGFlZjQ4OTRkMmExMg==
5
5
  data.tar.gz: !binary |-
6
- MzYwNjZmODZlMzllZjM5Yjg5YTEzZDZkYWRkMmIwYWY3YjkzN2RmOA==
6
+ ZWQzNjAxMzBmZDI3ZDVjMzlkMTBiZGQ0YjU1YjllZTcyY2NlOTkxOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDQyNzc4MGJmZTY4ZmZhNzU4ZGUwNDdiNDYxNWJjYjMzOTQ4OTAyNzIwM2I2
10
- ZDRiMWNmNjQwYWM2YmY3ZWVlOGYxZGU4YmQ1Y2I3YzUyZjJhMDc4YTRhYjQ5
11
- ZTQ1NDU0NTM3MGI5YTMzZTgwOTk2MTljMDJkMGJmNjkwODI2ZGI=
9
+ ZDI2MGJiMjY1ZGM3YmQ2NjlhNGI5MThhNGM5MWU0MWEyZDI1MmI1NjY4MDAz
10
+ NjViZmYwZTcxNzBlZWM0NmNjODk3MjhjNWQyZWJiZmUxNzc1ZjZmNWUxYjk5
11
+ MDUyNWI1ZWFlYzVmMWZkYmY3YmJmYjlhZGI4MTk3MjU0MmFiYzg=
12
12
  data.tar.gz: !binary |-
13
- ZGIzNjA5MWE0MzU2ODUzOTk1YWE0YzExMjBhNzBlNTllMGFjNjE1YmE1Yzg0
14
- MzEzZjE4MGMyYzg4YmJmNjFiMWFhODU2MjIxMTg4NThmMTNhMjAwYWQ4MTQw
15
- ZTk4ZDY4ZjNiMGVkNmM5MTA5NmRhZWFiOGY3YjdmZDVlODMxOTM=
13
+ ZjQzN2I1MjU5ZjEwNTM3MjliZGUzNzA1ODczYTk5NWNjN2ViMThlOTg0ZjM3
14
+ MjczNmEyZWY4MDQ4M2M1YjUxZDFkM2JhNTI5MDA1NzY3MmE4MDU0ZDQ5Mzlm
15
+ MDkxZjMzMThlODFlNjI0NTBjMjhhOGE2NjliOTc5NmIzOTZjYmQ=
data/README.md CHANGED
@@ -243,6 +243,10 @@ http://rubydoc.info/github/holtrop/rscons/frames.
243
243
 
244
244
  ## Release Notes
245
245
 
246
+ ### v1.2.0
247
+ - add :clone option to Environment#clone to control exactly which Environment attributes are cloned
248
+ - allow nil to be passed in to Environment#build_root=
249
+
246
250
  ### v1.1.0
247
251
 
248
252
  - Change Cache#up_to_date?() and #register_build() to accept a single target
@@ -1,6 +1,6 @@
1
1
  module Rscons
2
2
  module Builders
3
- # A default RScons builder that produces a static library archive.
3
+ # A default Rscons builder that produces a static library archive.
4
4
  class Rscons::Builders::Library < Rscons::Builder
5
5
  def default_variables(env)
6
6
  {
@@ -1,6 +1,6 @@
1
1
  module Rscons
2
2
  module Builders
3
- # A default RScons builder which knows how to produce an object file from
3
+ # A default Rscons builder which knows how to produce an object file from
4
4
  # various types of source files.
5
5
  class Object < Builder
6
6
  KNOWN_SUFFIXES = {
@@ -1,6 +1,6 @@
1
1
  module Rscons
2
2
  module Builders
3
- # A default RScons builder that knows how to link object files into an
3
+ # A default Rscons builder that knows how to link object files into an
4
4
  # executable program.
5
5
  class Rscons::Builders::Program < Rscons::Builder
6
6
  def default_variables(env)
@@ -2,7 +2,7 @@ require 'set'
2
2
  require 'fileutils'
3
3
 
4
4
  module Rscons
5
- # The Environment class is the main programmatic interface to RScons. It
5
+ # The Environment class is the main programmatic interface to Rscons. It
6
6
  # contains a collection of construction variables, options, builders, and
7
7
  # rules for building targets.
8
8
  class Environment
@@ -15,7 +15,8 @@ module Rscons
15
15
  # String or +nil+
16
16
  attr_reader :build_root
17
17
  def build_root=(build_root)
18
- @build_root = build_root.gsub('\\', '/')
18
+ @build_root = build_root
19
+ @build_root.gsub!('\\', '/') if @build_root
19
20
  end
20
21
 
21
22
  # Create an Environment object.
@@ -50,24 +51,53 @@ module Rscons
50
51
  end
51
52
 
52
53
  # Make a copy of the Environment object.
53
- # The cloned environment will contain a copy of all environment options,
54
- # construction variables, and builders (unless :exclude_builders => true is
55
- # passed as an option). It will not contain a copy of the targets, build
56
- # hooks, build directories, or the build root. If a block is given, the
57
- # Environment object is yielded to the block and when the block returns,
58
- # the {#process} method is automatically called. The possible options keys
59
- # match those documented in the #initialize method.
54
+ #
55
+ # By default, a cloned environment will contain a copy of all environment
56
+ # options, construction variables, and builders, but not a copy of the
57
+ # targets, build hooks, build directories, or the build root.
58
+ #
59
+ # Exactly which items are cloned are controllable via the optional :clone
60
+ # parameter, which can be :none, :all, or a set or array of any of the
61
+ # following:
62
+ # - :variables to clone construction variables (on by default)
63
+ # - :builders to clone the builders (on by default)
64
+ # - :build_root to clone the build root (off by default)
65
+ # - :build_dirs to clone the build directories (off by default)
66
+ # - :build_hooks to clone the build hooks (off by default)
67
+ #
68
+ # If a block is given, the Environment object is yielded to the block and
69
+ # when the block returns, the {#process} method is automatically called.
70
+ #
71
+ # Any options that #initialize receives can also be specified here.
72
+ #
73
+ # @return a new {Environment} object.
60
74
  def clone(options = {})
75
+ clone = options[:clone] || Set[:variables, :builders]
76
+ clone = Set[:variables, :builders, :build_root, :build_dirs, :build_hooks] if clone == :all
77
+ clone = Set[] if clone == :none
78
+ clone = Set.new(clone) if clone.is_a?(Array)
79
+ clone.delete(:builders) if options[:exclude_builders]
61
80
  env = self.class.new(
62
81
  echo: options[:echo] || @echo,
63
82
  build_root: options[:build_root],
64
83
  exclude_builders: true)
65
- unless options[:exclude_builders]
84
+ if clone.include?(:builders)
66
85
  @builders.each do |builder_name, builder|
67
86
  env.add_builder(builder)
68
87
  end
69
88
  end
70
- env.append(@varset.clone)
89
+ env.append(@varset.clone) if clone.include?(:variables)
90
+ env.build_root = @build_root if clone.include?(:build_root)
91
+ if clone.include?(:build_dirs)
92
+ @build_dirs.each do |src_dir, obj_dir|
93
+ env.build_dir(src_dir, obj_dir)
94
+ end
95
+ end
96
+ if clone.include?(:build_hooks)
97
+ @build_hooks.each do |build_hook_block|
98
+ env.add_build_hook(&build_hook_block)
99
+ end
100
+ end
71
101
 
72
102
  if block_given?
73
103
  yield env
@@ -246,7 +276,7 @@ module Rscons
246
276
 
247
277
  # Build a list of source files into files containing one of the suffixes
248
278
  # given by suffixes.
249
- # This method is used internally by RScons builders.
279
+ # This method is used internally by Rscons builders.
250
280
  # @param sources [Array] List of source files to build.
251
281
  # @param suffixes [Array] List of suffixes to try to convert source files into.
252
282
  # @param cache [Cache] The Cache.
@@ -294,7 +324,7 @@ module Rscons
294
324
  end
295
325
 
296
326
  # Parse dependencies for a given target from a Makefile.
297
- # This method is used internally by RScons builders.
327
+ # This method is used internally by Rscons builders.
298
328
  # @param mf_fname [String] File name of the Makefile to read.
299
329
  # @param target [String] Name of the target to gather dependencies for.
300
330
  def self.parse_makefile_deps(mf_fname, target)
@@ -1,4 +1,4 @@
1
1
  module Rscons
2
2
  # gem version
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
@@ -298,6 +298,29 @@ EOF
298
298
  ]
299
299
  end
300
300
 
301
+ it 'allows cloning all attributes of an Environment object' do
302
+ test_dir('clone_env')
303
+
304
+ env1 = Rscons::Environment.new(echo: :command) do |env|
305
+ env.build_dir('src', 'build')
306
+ env['CFLAGS'] = '-O2'
307
+ env.add_build_hook do |build_op|
308
+ build_op[:vars]['CPPFLAGS'] = '-DSTRING="Hello"'
309
+ end
310
+ env.Program('program', Dir['src/*.c'])
311
+ end
312
+
313
+ env2 = env1.clone(clone: :all) do |env|
314
+ env.Program('program2', Dir['src/*.c'])
315
+ end
316
+
317
+ lines.should == [
318
+ %q{gcc -c -o build/program.o -MMD -MF build/program.mf -DSTRING="Hello" -O2 src/program.c},
319
+ %q{gcc -o program build/program.o},
320
+ %q{gcc -o program2 build/program.o},
321
+ ]
322
+ end
323
+
301
324
  it 'builds a C++ program with one source file' do
302
325
  test_dir('simple_cc')
303
326
  Rscons::Environment.new do |env|
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.1.0
4
+ version: 1.2.0
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-02-17 00:00:00.000000000 Z
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core