rscons 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Njg4YWQzOTg0NTU4OTRiYjBmZWJhYzY3ZjE0MDI4MWE1NGViZDc4Yg==
5
+ data.tar.gz: !binary |-
6
+ YzUyYWZiZjM5MjdmMDhkOTU2MjUzMTAwZmQ3NzY1ODkyOTljNmZjMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDNiNTlmZDU5YTNmM2M3OWJmYThhNGIyNjg2NjE4NzljMTRlZTlhMWNhMzVl
10
+ MjQ5YWZmMjViYzZmNWVmZWQyNjM3YmNkZjBjMDJmMzhlMzMzYjcwMDlhOTdj
11
+ OWVjYTg4NDA1Zjg4Y2U2ODgwNjNlZjA5MzA4ZTkyOWQ2OTBhMWQ=
12
+ data.tar.gz: !binary |-
13
+ ODQ2MjEwOTYwMjQ3YTA5Y2U0MjA1MGZlMzM3Zjg2ODE2ZWRkM2ZlMWVhYTg4
14
+ NTE0Mzg3YzgwM2Y0YjNlZjcwZDliYzVjNTE5ZTI1NGQzYTRhMWFkYjZkODgx
15
+ YzM4ZTZiYzZjYmI5NTQ1OTVlY2ExOTg5ZTRiYWIyODkxZTNiZGY=
@@ -7,7 +7,7 @@ module Rscons
7
7
  # contains a collection of construction variables, options, builders, and
8
8
  # rules for building targets.
9
9
  class Environment
10
- # @return [Hash] Set of \{"builder_name" => builder_object} pairs.
10
+ # @return [Hash] Set of !{"builder_name" => builder_object} pairs.
11
11
  attr_reader :builders
12
12
 
13
13
  # :command, :short, or :off
@@ -42,7 +42,7 @@ module Rscons
42
42
  @user_deps = {}
43
43
  @builders = {}
44
44
  @build_dirs = []
45
- @build_hooks = []
45
+ @build_hooks = {pre: [], post: []}
46
46
  unless options[:exclude_builders]
47
47
  DEFAULT_BUILDERS.each do |builder_class_name|
48
48
  builder_class = Builders.const_get(builder_class_name)
@@ -103,9 +103,12 @@ module Rscons
103
103
  end
104
104
  end
105
105
  if clone.include?(:build_hooks)
106
- @build_hooks.each do |build_hook_block|
106
+ @build_hooks[:pre].each do |build_hook_block|
107
107
  env.add_build_hook(&build_hook_block)
108
108
  end
109
+ @build_hooks[:post].each do |build_hook_block|
110
+ env.add_post_build_hook(&build_hook_block)
111
+ end
109
112
  end
110
113
 
111
114
  if block_given?
@@ -132,6 +135,12 @@ module Rscons
132
135
 
133
136
  # Add a build hook to the Environment.
134
137
  #
138
+ # Build hooks are Ruby blocks which are invoked immediately before a
139
+ # build operation takes place. Build hooks have an opportunity to modify
140
+ # the construction variables in use for the build operation based on the
141
+ # builder in use, target file name, or sources. Build hooks can also
142
+ # register new build targets.
143
+ #
135
144
  # @yield [build_op]
136
145
  # Invoke the given block with the current build operation.
137
146
  # @yieldparam build_op [Hash]
@@ -144,19 +153,45 @@ module Rscons
144
153
  #
145
154
  # @return [void]
146
155
  def add_build_hook(&block)
147
- @build_hooks << block
156
+ @build_hooks[:pre] << block
157
+ end
158
+
159
+ # Add a post build hook to the Environment.
160
+ #
161
+ # Post-build hooks are Ruby blocks which are invoked immediately after a
162
+ # build operation takes place. Post-build hooks are only invoked if the
163
+ # build operation succeeded. Post-build hooks can register new build
164
+ # targets.
165
+ #
166
+ # @since 1.7.0
167
+ #
168
+ # @yield [build_op]
169
+ # Invoke the given block with the current build operation.
170
+ # @yieldparam build_op [Hash]
171
+ # Hash with keys:
172
+ # - :builder - The builder object in use.
173
+ # - :target - Target file name.
174
+ # - :sources - List of source file(s).
175
+ # - :vars - Set of construction variable values in use.
176
+ # - :env - The Environment invoking the builder.
177
+ #
178
+ # @return [void]
179
+ def add_post_build_hook(&block)
180
+ @build_hooks[:post] << block
148
181
  end
149
182
 
150
183
  # Specify a build directory for this Environment.
151
184
  #
152
185
  # Source files from src_dir will produce object files under obj_dir.
153
186
  #
154
- # @param src_dir [String] Path to the source directory.
187
+ # @param src_dir [String, Regexp] Path to the source directory.
155
188
  # @param obj_dir [String] Path to the object directory.
156
189
  #
157
190
  # @return [void]
158
191
  def build_dir(src_dir, obj_dir)
159
- src_dir = src_dir.gsub('\\', '/') if src_dir.is_a?(String)
192
+ if src_dir.is_a?(String)
193
+ src_dir = src_dir.gsub("\\", "/").sub(%r{/*$}, "")
194
+ end
160
195
  @build_dirs << [src_dir, obj_dir]
161
196
  end
162
197
 
@@ -216,23 +251,25 @@ module Rscons
216
251
  #
217
252
  # @return [void]
218
253
  def process
219
- unless @targets.empty?
220
- expand_paths!
254
+ expand_paths!
255
+ while @targets.size > 0
256
+ targets = @targets
257
+ @targets = {}
221
258
  cache = Cache.instance
222
259
  cache.clear_checksum_cache!
223
260
  targets_processed = {}
224
261
  process_target = proc do |target|
225
262
  targets_processed[target] ||= begin
226
- @targets[target][:sources].each do |src|
227
- if @targets.include?(src) and not targets_processed.include?(src)
263
+ targets[target][:sources].each do |src|
264
+ if targets.include?(src) and not targets_processed.include?(src)
228
265
  process_target.call(src)
229
266
  end
230
267
  end
231
- result = run_builder(@targets[target][:builder],
268
+ result = run_builder(targets[target][:builder],
232
269
  target,
233
- @targets[target][:sources],
270
+ targets[target][:sources],
234
271
  cache,
235
- @targets[target][:vars] || {})
272
+ targets[target][:vars] || {})
236
273
  unless result
237
274
  raise BuildError.new("Failed to build #{target}")
238
275
  end
@@ -240,7 +277,7 @@ module Rscons
240
277
  end
241
278
  end
242
279
  begin
243
- @targets.each do |target, target_params|
280
+ targets.each do |target, target_params|
244
281
  process_target.call(target)
245
282
  end
246
283
  ensure
@@ -410,17 +447,22 @@ module Rscons
410
447
  # @return [String,false] Return value from the {Builder}'s +run+ method.
411
448
  def run_builder(builder, target, sources, cache, vars)
412
449
  vars = @varset.merge(vars)
413
- @build_hooks.each do |build_hook_block|
414
- build_operation = {
415
- builder: builder,
416
- target: target,
417
- sources: sources,
418
- vars: vars,
419
- env: self,
420
- }
421
- build_hook_block.call(build_operation)
450
+ call_build_hooks = lambda do |sec|
451
+ @build_hooks[sec].each do |build_hook_block|
452
+ build_operation = {
453
+ builder: builder,
454
+ target: target,
455
+ sources: sources,
456
+ vars: vars,
457
+ env: self,
458
+ }
459
+ build_hook_block.call(build_operation)
460
+ end
422
461
  end
423
- builder.run(target, sources, cache, self, vars)
462
+ call_build_hooks[:pre]
463
+ rv = builder.run(target, sources, cache, self, vars)
464
+ call_build_hooks[:post] if rv
465
+ rv
424
466
  end
425
467
 
426
468
  # Expand a path to be relative to the Environment's build root.
@@ -83,7 +83,7 @@ module Rscons
83
83
  end
84
84
  alias_method :clone, :merge
85
85
 
86
- # Replace "$\{var}" variable references in varref with the expanded
86
+ # Replace "$!{var}" variable references in varref with the expanded
87
87
  # variables' values, recursively.
88
88
  #
89
89
  # @param varref [nil, String, Array, Proc]
@@ -92,7 +92,7 @@ module Rscons
92
92
  # Arguments to pass to any lambda variable values to be expanded.
93
93
  #
94
94
  # @return [nil, String, Array]
95
- # Expanded value with "$\{var}" variable references replaced.
95
+ # Expanded value with "$!{var}" variable references replaced.
96
96
  def expand_varref(varref, lambda_args)
97
97
  if varref.is_a?(String)
98
98
  if varref =~ /^(.*)\$\{([^}]+)\}(.*)$/
@@ -1,4 +1,4 @@
1
1
  module Rscons
2
2
  # gem version
3
- VERSION = "1.6.1"
3
+ VERSION = "1.7.0"
4
4
  end
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: 1.6.1
5
- prerelease:
4
+ version: 1.7.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-08-19 00:00:00.000000000 Z
11
+ date: 2014-09-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
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: :runtime
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
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: rake
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: simplecov
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: yard
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: redcarpet
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
@@ -114,6 +101,9 @@ executables: []
114
101
  extensions: []
115
102
  extra_rdoc_files: []
116
103
  files:
104
+ - LICENSE.txt
105
+ - lib/rscons.rb
106
+ - lib/rscons/build_target.rb
117
107
  - lib/rscons/builder.rb
118
108
  - lib/rscons/builders/cfile.rb
119
109
  - lib/rscons/builders/disassemble.rb
@@ -121,44 +111,34 @@ files:
121
111
  - lib/rscons/builders/object.rb
122
112
  - lib/rscons/builders/preprocess.rb
123
113
  - lib/rscons/builders/program.rb
124
- - lib/rscons/build_target.rb
125
114
  - lib/rscons/cache.rb
126
115
  - lib/rscons/environment.rb
127
116
  - lib/rscons/varset.rb
128
117
  - lib/rscons/version.rb
129
- - lib/rscons.rb
130
118
  - rscons.gemspec
131
- - LICENSE.txt
132
119
  homepage: https://github.com/holtrop/rscons
133
120
  licenses:
134
121
  - MIT
122
+ metadata: {}
135
123
  post_install_message:
136
124
  rdoc_options: []
137
125
  require_paths:
138
126
  - lib
139
127
  required_ruby_version: !ruby/object:Gem::Requirement
140
- none: false
141
128
  requirements:
142
129
  - - ! '>='
143
130
  - !ruby/object:Gem::Version
144
131
  version: '0'
145
- segments:
146
- - 0
147
- hash: 580700051
148
132
  required_rubygems_version: !ruby/object:Gem::Requirement
149
- none: false
150
133
  requirements:
151
134
  - - ! '>='
152
135
  - !ruby/object:Gem::Version
153
136
  version: '0'
154
- segments:
155
- - 0
156
- hash: 580700051
157
137
  requirements: []
158
138
  rubyforge_project:
159
- rubygems_version: 1.8.23.2
139
+ rubygems_version: 2.3.0
160
140
  signing_key:
161
- specification_version: 3
141
+ specification_version: 4
162
142
  summary: Software construction library inspired by SCons and implemented in Ruby
163
143
  test_files: []
164
144
  has_rdoc: