rscons 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1c35c3bc6732619150b8db82fef940d7b52158928e840d1476b50e67ac1bc12
4
- data.tar.gz: 8a7824b24ddc5b8f0f0a137f90614e1f07c34aaba6a155b7ff3aad4025481cea
3
+ metadata.gz: 72aa6f2561702f7e37fa19cb19e7db7bf68b88e54767107b98f22b4e2afc452e
4
+ data.tar.gz: e2a52a29f3f98ed8135611de9014b126d1c3ef8bc5dc406999789a20f647c972
5
5
  SHA512:
6
- metadata.gz: 49f2d855f39126acd3a1776211971b7605f8a391dad8aa85cce9f6951b12ee02abe94564ac2332d1fdbe1f25a2beae0b79d8035fb0af46f2b79543b7105d69a5
7
- data.tar.gz: 549b3b08fee0046a7f210fa42b3a0a51cb3eb61e79ad172c720007ee187ebe781ac69dca2693dde8646b8b7d49739cdf277465b44f1305eaf803ed57d444ce64
6
+ metadata.gz: b2d618e135d05c30020c34512b932e952fdb38fc824f424e355923c0cd5f588a8a4d4ce92b377a53929c5df500223cebd1b149242bb576cccd975b4e4b7b7271
7
+ data.tar.gz: 31ce3d2252e998bee8ca980116c8d6f2c14ad865bc5254a6588fbefcadc9ba44e9c99e16d73d76879f27a154a5b214e772f63c8c6ae7be0d78333d7e21a0e555
data/lib/rscons/cache.rb CHANGED
@@ -85,17 +85,14 @@ module Rscons
85
85
  @lookup_checksums = {}
86
86
  end
87
87
 
88
- # Write the cache to disk to be loaded next time.
88
+ # Write the cache to disk.
89
89
  #
90
90
  # @return [void]
91
91
  def write
92
- if @dirty || (@cache["version"] != VERSION)
93
- @cache["version"] = VERSION
94
- File.open(CACHE_FILE, "w") do |fh|
95
- fh.puts(JSON.dump(@cache))
96
- end
92
+ @cache["version"] = VERSION
93
+ File.open(CACHE_FILE, "w") do |fh|
94
+ fh.puts(JSON.dump(@cache))
97
95
  end
98
- @dirty = false
99
96
  end
100
97
 
101
98
  # Check if target(s) are up to date.
@@ -249,7 +246,6 @@ module Rscons
249
246
  }
250
247
  end,
251
248
  }
252
- @dirty = true
253
249
  end
254
250
  end
255
251
 
@@ -272,9 +268,8 @@ module Rscons
272
268
  next if parts[i] == ""
273
269
  subpath = File.join(*parts[0, i + 1])
274
270
  unless File.exists?(subpath)
275
- FileUtils.mkdir(subpath)
271
+ FileUtils.mkdir_p(subpath)
276
272
  @cache["directories"][subpath] = true
277
- @dirty = true
278
273
  end
279
274
  end
280
275
  end
@@ -315,7 +310,6 @@ module Rscons
315
310
  @cache["targets"] ||= {}
316
311
  @cache["directories"] ||= {}
317
312
  @lookup_checksums = {}
318
- @dirty = false
319
313
  end
320
314
 
321
315
  # Return a file's checksum, or the previously calculated checksum for
@@ -280,6 +280,24 @@ module Rscons
280
280
  @varset.send(:[], *args)
281
281
  end
282
282
 
283
+ # Access the value of a construction variable.
284
+ #
285
+ # @since 1.18.0
286
+ #
287
+ # This method is similar to #[] but does not make a copy-on-access copy of
288
+ # the variable accessed. This means that the returned value is NOT safe to
289
+ # be modified by the caller. Thus the caller must guarantee that it does
290
+ # not modify the returned value.
291
+ #
292
+ # @param key [String, Symbol]
293
+ # The construction variable name.
294
+ #
295
+ # @return [Object]
296
+ # The construction variable's value.
297
+ def get_var(key)
298
+ @varset.get_var(key)
299
+ end
300
+
283
301
  # Set a construction variable's value.
284
302
  #
285
303
  # @see VarSet#[]=
@@ -782,7 +800,7 @@ module Rscons
782
800
  append["LDFLAGS", ["-arch", val]]
783
801
  end
784
802
  skip = true
785
- elsif word =~ /^#{self["CPPDEFPREFIX"]}(.*)$/
803
+ elsif word =~ /^#{get_var("CPPDEFPREFIX")}(.*)$/
786
804
  handle["CPPDEFINES", $1]
787
805
  elsif word == "-include"
788
806
  if val = words[i + 1]
@@ -795,11 +813,11 @@ module Rscons
795
813
  append["LDFLAGS", ["-isysroot", val]]
796
814
  end
797
815
  skip = true
798
- elsif word =~ /^#{self["INCPREFIX"]}(.*)$/
816
+ elsif word =~ /^#{get_var("INCPREFIX")}(.*)$/
799
817
  handle["CPPPATH", $1]
800
- elsif word =~ /^#{self["LIBLINKPREFIX"]}(.*)$/
818
+ elsif word =~ /^#{get_var("LIBLINKPREFIX")}(.*)$/
801
819
  handle["LIBS", $1]
802
- elsif word =~ /^#{self["LIBDIRPREFIX"]}(.*)$/
820
+ elsif word =~ /^#{get_var("LIBDIRPREFIX")}(.*)$/
803
821
  handle["LIBPATH", $1]
804
822
  elsif word == "-mno-cygwin"
805
823
  append["CCFLAGS", [word]]
@@ -848,7 +866,7 @@ module Rscons
848
866
  # @return [void]
849
867
  def merge_flags(flags)
850
868
  flags.each_pair do |key, val|
851
- if self[key].is_a?(Array) and val.is_a?(Array)
869
+ if self.get_var(key).is_a?(Array) and val.is_a?(Array)
852
870
  self[key] += val
853
871
  else
854
872
  self[key] = val
data/lib/rscons/varset.rb CHANGED
@@ -11,11 +11,13 @@ module Rscons
11
11
  append(vars)
12
12
  end
13
13
 
14
- # Access the value of variable.
14
+ # Access the value of a variable.
15
15
  #
16
- # @param key [String, Symbol] The variable name.
16
+ # @param key [String, Symbol]
17
+ # The variable name.
17
18
  #
18
- # @return [Object] The variable's value.
19
+ # @return [Object]
20
+ # The variable's value.
19
21
  def [](key)
20
22
  if @my_vars.include?(key)
21
23
  @my_vars[key]
@@ -30,11 +32,38 @@ module Rscons
30
32
  end
31
33
  end
32
34
 
35
+ # Access the value of a variable.
36
+ #
37
+ # This method is similar to #[] but does not make a copy-on-access copy of
38
+ # the variable accessed. This means that the returned value is NOT safe to
39
+ # be modified by the caller. Thus the caller must guarantee that it does
40
+ # not modify the returned value.
41
+ #
42
+ # @param key [String, Symbol]
43
+ # The variable name.
44
+ #
45
+ # @return [Object]
46
+ # The variable's value.
47
+ def get_var(key)
48
+ if @my_vars.include?(key)
49
+ @my_vars[key]
50
+ else
51
+ @coa_vars.each do |coa_vars|
52
+ if coa_vars.include?(key)
53
+ return coa_vars[key]
54
+ end
55
+ end
56
+ nil
57
+ end
58
+ end
59
+
33
60
  # Assign a value to a variable.
34
61
  #
35
- # @param key [String, Symbol] The variable name.
62
+ # @param key [String, Symbol]
63
+ # The variable name.
36
64
  #
37
- # @param val [Object] The value to set.
65
+ # @param val [Object]
66
+ # The value to set.
38
67
  def []=(key, val)
39
68
  @my_vars[key] = val
40
69
  end
@@ -94,36 +123,42 @@ module Rscons
94
123
  # @return [nil, String, Array, Symbol, TrueClass, FalseClass]
95
124
  # Expanded value with "$!{var}" variable references replaced.
96
125
  def expand_varref(varref, lambda_args)
97
- if varref.is_a?(String)
126
+ case varref
127
+ when String
98
128
  if varref =~ /^(.*)\$\{([^}]+)\}(.*)$/
99
129
  prefix, varname, suffix = $1, $2, $3
100
- varval = expand_varref(self[varname], lambda_args)
101
- if varval.is_a?(String) or varval.nil?
102
- expand_varref("#{prefix}#{varval}#{suffix}", lambda_args)
103
- elsif varval.is_a?(Array)
104
- varval.map {|vv| expand_varref("#{prefix}#{vv}#{suffix}", lambda_args)}.flatten
130
+ prefix = expand_varref(prefix, lambda_args) unless prefix.empty?
131
+ varval = expand_varref(get_var(varname), lambda_args)
132
+ # suffix needs no expansion since the regex matches the last occurence
133
+ case varval
134
+ when Array
135
+ if prefix.is_a?(Array)
136
+ varval.map {|vv| prefix.map {|p| "#{p}#{vv}#{suffix}"}}.flatten
137
+ else
138
+ varval.map {|vv| "#{prefix}#{vv}#{suffix}"}
139
+ end
140
+ when String, Symbol, true, false, nil
141
+ if prefix.is_a?(Array)
142
+ prefix.map {|p| "#{p}#{varval}#{suffix}"}
143
+ else
144
+ "#{prefix}#{varval}#{suffix}"
145
+ end
105
146
  else
106
- raise "I do not know how to expand a variable reference to a #{varval.class.name} (from #{varname.inspect} => #{self[varname].inspect})"
147
+ raise "Unknown construction variable type: #{varval.class} (from #{varname.inspect} => #{get_var(varname).inspect})"
107
148
  end
108
149
  else
109
150
  varref
110
151
  end
111
- elsif varref.is_a?(Array)
152
+ when Array
112
153
  varref.map do |ent|
113
154
  expand_varref(ent, lambda_args)
114
155
  end.flatten
115
- elsif varref.is_a?(Proc)
116
- expand_varref(varref[*lambda_args], lambda_args)
117
- elsif varref.nil?
118
- nil
119
- elsif varref.is_a?(Symbol)
120
- varref
121
- elsif varref.is_a?(TrueClass)
122
- varref
123
- elsif varref.is_a?(FalseClass)
156
+ when Symbol, true, false, nil
124
157
  varref
158
+ when Proc
159
+ expand_varref(varref[*lambda_args], lambda_args)
125
160
  else
126
- raise "Unknown varref type: #{varref.class} (#{varref.inspect})"
161
+ raise "Unknown construction variable type: #{varref.class} (#{varref.inspect})"
127
162
  end
128
163
  end
129
164
 
@@ -188,16 +223,16 @@ module Rscons
188
223
  #
189
224
  # @return [Object] Deep copied value.
190
225
  def deep_dup(obj)
191
- obj_class = obj.class
192
- if obj_class == Hash
226
+ case obj
227
+ when String
228
+ obj.dup
229
+ when Array
230
+ obj.map { |v| deep_dup(v) }
231
+ when Hash
193
232
  obj.reduce({}) do |result, (k, v)|
194
233
  result[k] = deep_dup(v)
195
234
  result
196
235
  end
197
- elsif obj_class == Array
198
- obj.map { |v| deep_dup(v) }
199
- elsif obj_class == String
200
- obj.dup
201
236
  else
202
237
  obj
203
238
  end
@@ -1,4 +1,4 @@
1
1
  module Rscons
2
2
  # gem version
3
- VERSION = "1.17.0"
3
+ VERSION = "1.18.0"
4
4
  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.17.0
4
+ version: 1.18.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: 2018-11-02 00:00:00.000000000 Z
11
+ date: 2019-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -153,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.7.7
156
+ rubygems_version: 3.0.3
158
157
  signing_key:
159
158
  specification_version: 4
160
159
  summary: Software construction library inspired by SCons and implemented in Ruby