rscons 1.15.0 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2bb3ac572e885e3bd9a0e44c261c2208cc79b315
4
- data.tar.gz: c857eec695f9b829f773adff9f814e86e625cd04
2
+ SHA256:
3
+ metadata.gz: e6ab9f61dc793cbbd24e94de699b62fad0c5f7d7da1d09e4ed117d6660b8ed77
4
+ data.tar.gz: 8bb4e4698a8cc54941c9e2757857de1ccc8914b95596a2f6fc308f7b717e7db8
5
5
  SHA512:
6
- metadata.gz: c15ed61445c6f8fda20b6750c081e217a04054389e70b24a854d98c04da0e8c83dfeb843dedcd59109fd06f0cd489b633e7539d4131b8f4586752bc6e49f735b
7
- data.tar.gz: b2af19434c5baa99f800e176527641ae747744d35507eaa61eac5ffc1cf62a17a8c5225efed3533356c39f79d4fc154c4ce0c39dc70c62d1a8bb16564fa4d72f
6
+ metadata.gz: 18d50b38e720459b289e51b0fd3a101294ff9bb5ac168c5923145ff39bd38eacefe9fef9d140bd252bf0f4eb1342ba9dc1e7e9569c9a5d641447b0d79b02d64f
7
+ data.tar.gz: 82d2339ac692f1338da75d2d1def8e817f13cfba1373f98be9e785016d03c55a183cc8775dc827b2174d70a1ca8883026202264c9d94f5c225dcfb2d2a44c1c0
data/bin/rscons CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
1
3
  require "rscons/cli"
2
4
 
3
5
  Rscons::Cli.run(ARGV)
@@ -55,6 +55,11 @@ module Rscons
55
55
  # Whether to output ANSI color escape sequences.
56
56
  attr_accessor :do_ansi_color
57
57
 
58
+ # @since 1.16.0
59
+ # @return [VarSet]
60
+ # Access any variables set on the rscons command-line.
61
+ attr_reader :vars
62
+
58
63
  # Remove all generated files.
59
64
  #
60
65
  # @return [void]
@@ -165,6 +170,35 @@ module Rscons
165
170
  @command_executer = val
166
171
  end
167
172
 
173
+ # Return a list of paths matching the specified pattern(s).
174
+ #
175
+ # @since 1.16.0
176
+ #
177
+ # A pattern can contain a "/**" component to recurse through directories.
178
+ # If the pattern ends with "/**" then only the recursive list of
179
+ # directories will be returned.
180
+ #
181
+ # Examples:
182
+ # - "src/**": return all directories under "src", recursively (including
183
+ # "src" itself).
184
+ # - "src/**/*": return all files and directories recursively under the src
185
+ # directory.
186
+ # - "src/**/*.c": return all .c files recursively under the src directory.
187
+ # - "dir/*/": return all directories in dir, but no files.
188
+ #
189
+ # @return [Array<String>] Paths matching the specified pattern(s).
190
+ def glob(*patterns)
191
+ require "pathname"
192
+ patterns.reduce([]) do |result, pattern|
193
+ if pattern.end_with?("/**")
194
+ pattern += "/"
195
+ end
196
+ result += Dir.glob(pattern).map do |path|
197
+ Pathname.new(path.gsub("\\", "/")).cleanpath.to_s
198
+ end
199
+ end.sort
200
+ end
201
+
168
202
  private
169
203
 
170
204
  # Determine the number of threads to use by default.
@@ -203,6 +237,7 @@ module Rscons
203
237
  end
204
238
 
205
239
  @n_threads = determine_n_threads
240
+ @vars = VarSet.new
206
241
 
207
242
  end
208
243
 
@@ -30,7 +30,7 @@ module Rscons
30
30
  'ASSUFFIX' => ['.S'],
31
31
  'ASPPPATH' => '${CPPPATH}',
32
32
  'ASPPFLAGS' => '${CPPFLAGS}',
33
- 'ASDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}'],
33
+ 'ASDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}', '-MT', 'TARGET'],
34
34
  'ASCMD' => ['${AS}', '-c', '-o', '${_TARGET}', '${ASDEPGEN}', '${INCPREFIX}${ASPPPATH}', '${ASPPFLAGS}', '${ASFLAGS}', '${_SOURCES}'],
35
35
 
36
36
  'CPPFLAGS' => ['${CPPDEFPREFIX}${CPPDEFINES}'],
@@ -42,20 +42,21 @@ module Rscons
42
42
  'CC' => 'gcc',
43
43
  'CFLAGS' => [],
44
44
  'CSUFFIX' => ['.c'],
45
- 'CCDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}'],
45
+ 'CCDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}', '-MT', 'TARGET'],
46
46
  'CCCMD' => ['${CC}', '-c', '-o', '${_TARGET}', '${CCDEPGEN}', '${INCPREFIX}${CPPPATH}', '${CPPFLAGS}', '${CFLAGS}', '${CCFLAGS}', '${_SOURCES}'],
47
47
 
48
48
  'CXX' => 'g++',
49
49
  'CXXFLAGS' => [],
50
50
  'CXXSUFFIX' => ['.cc', '.cpp', '.cxx', '.C'],
51
- 'CXXDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}'],
51
+ 'CXXDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}', '-MT', 'TARGET'],
52
52
  'CXXCMD' =>['${CXX}', '-c', '-o', '${_TARGET}', '${CXXDEPGEN}', '${INCPREFIX}${CPPPATH}', '${CPPFLAGS}', '${CXXFLAGS}', '${CCFLAGS}', '${_SOURCES}'],
53
53
 
54
54
  'DC' => 'gdc',
55
55
  'DFLAGS' => [],
56
56
  'DSUFFIX' => ['.d'],
57
+ 'DDEPGEN' => ['-MMD', '-MF', '${_DEPFILE}', '-MT', 'TARGET'],
57
58
  'D_IMPORT_PATH' => [],
58
- 'DCCMD' => ['${DC}', '-c', '-o', '${_TARGET}', '${INCPREFIX}${D_IMPORT_PATH}', '${DFLAGS}', '${_SOURCES}'],
59
+ 'DCCMD' => ['${DC}', '-c', '-o', '${_TARGET}', '${DDEPGEN}', '${INCPREFIX}${D_IMPORT_PATH}', '${DFLAGS}', '${_SOURCES}'],
59
60
  }
60
61
  end
61
62
 
@@ -114,7 +115,7 @@ module Rscons
114
115
  if options[:command_status]
115
116
  target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
116
117
  if File.exists?(vars['_DEPFILE'])
117
- deps += Environment.parse_makefile_deps(vars['_DEPFILE'], target)
118
+ deps += Environment.parse_makefile_deps(vars['_DEPFILE'], 'TARGET')
118
119
  FileUtils.rm_f(vars['_DEPFILE'])
119
120
  end
120
121
  cache.register_build(target, options[:tc].command, deps.uniq, env)
@@ -100,7 +100,7 @@ module Rscons
100
100
  if options[:command_status]
101
101
  target, deps, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
102
102
  if File.exists?(vars['_DEPFILE'])
103
- deps += Environment.parse_makefile_deps(vars['_DEPFILE'], target)
103
+ deps += Environment.parse_makefile_deps(vars['_DEPFILE'], 'TARGET')
104
104
  FileUtils.rm_f(vars['_DEPFILE'])
105
105
  end
106
106
  cache.register_build(target, options[:tc].command, deps.uniq, env)
@@ -111,6 +111,10 @@ module Rscons
111
111
  # @param deps [Array<String>] List of the target's dependency files.
112
112
  # @param env [Environment] The Rscons::Environment.
113
113
  # @param options [Hash] Optional options.
114
+ # @option options [Boolean] :debug
115
+ # If turned on, this causes the Cache to print messages explaining why
116
+ # a build target is out of date. This could aid a builder author in
117
+ # debugging the operation of their builder.
114
118
  # @option options [Boolean] :strict_deps
115
119
  # Only consider a target up to date if its list of dependencies is
116
120
  # exactly equal (including order) to the cached list of dependencies
@@ -133,39 +137,79 @@ module Rscons
133
137
 
134
138
  unless Rscons.phony_target?(target)
135
139
  # target file must exist on disk
136
- return false unless File.exists?(target)
140
+ unless File.exists?(target)
141
+ if options[:debug]
142
+ puts "Target #{target} needs rebuilding because it does not exist on disk"
143
+ end
144
+ return false
145
+ end
137
146
  end
138
147
 
139
148
  # target must be registered in the cache
140
- return false unless @cache["targets"].has_key?(cache_key)
149
+ unless @cache["targets"].has_key?(cache_key)
150
+ if options[:debug]
151
+ puts "Target #{target} needs rebuilding because there is no cached build information for it"
152
+ end
153
+ return false
154
+ end
141
155
 
142
156
  unless Rscons.phony_target?(target)
143
157
  # target must have the same checksum as when it was built last
144
- return false unless @cache["targets"][cache_key]["checksum"] == lookup_checksum(target)
158
+ unless @cache["targets"][cache_key]["checksum"] == lookup_checksum(target)
159
+ if options[:debug]
160
+ puts "Target #{target} needs rebuilding because it has been changed on disk since being built last"
161
+ end
162
+ return false
163
+ end
145
164
  end
146
165
 
147
166
  # command used to build target must be identical
148
- return false unless @cache["targets"][cache_key]["command"] == Digest::MD5.hexdigest(command.inspect)
167
+ unless @cache["targets"][cache_key]["command"] == Digest::MD5.hexdigest(command.inspect)
168
+ if options[:debug]
169
+ puts "Target #{target} needs rebuilding because the command used to build it has changed"
170
+ end
171
+ return false
172
+ end
149
173
 
150
174
  cached_deps = @cache["targets"][cache_key]["deps"] || []
151
175
  cached_deps_fnames = cached_deps.map { |dc| dc["fname"] }
152
176
  if options[:strict_deps]
153
177
  # depedencies passed in must exactly equal those in the cache
154
- return false unless deps == cached_deps_fnames
178
+ unless deps == cached_deps_fnames
179
+ if options[:debug]
180
+ puts "Target #{target} needs rebuilding because the :strict_deps option is given and the set of dependencies does not match the previous set of dependencies"
181
+ end
182
+ return false
183
+ end
155
184
  else
156
185
  # all dependencies passed in must exist in cache (but cache may have more)
157
- return false unless (Set.new(deps) - Set.new(cached_deps_fnames)).empty?
186
+ unless (Set.new(deps) - Set.new(cached_deps_fnames)).empty?
187
+ if options[:debug]
188
+ puts "Target #{target} needs rebuilding because there are new dependencies"
189
+ end
190
+ return false
191
+ end
158
192
  end
159
193
 
160
194
  # set of user dependencies must match
161
195
  user_deps = env.get_user_deps(target) || []
162
196
  cached_user_deps = @cache["targets"][cache_key]["user_deps"] || []
163
197
  cached_user_deps_fnames = cached_user_deps.map { |dc| dc["fname"] }
164
- return false unless user_deps == cached_user_deps_fnames
198
+ unless user_deps == cached_user_deps_fnames
199
+ if options[:debug]
200
+ puts "Target #{target} needs rebuilding because the set of user-specified dependency files has changed"
201
+ end
202
+ return false
203
+ end
165
204
 
166
205
  # all cached dependencies must have their checksums match
167
206
  (cached_deps + cached_user_deps).each do |dep_cache|
168
- return false unless dep_cache["checksum"] == lookup_checksum(dep_cache["fname"])
207
+ unless dep_cache["checksum"] == lookup_checksum(dep_cache["fname"])
208
+ if options[:debug]
209
+ puts "Target #{target} needs rebuilding because dependency file #{dep_cache["fname"]} has changed"
210
+ end
211
+ return false
212
+ end
169
213
  end
170
214
  end
171
215
 
@@ -60,6 +60,12 @@ module Rscons
60
60
 
61
61
  end.parse!(argv)
62
62
 
63
+ argv.each do |arg|
64
+ if arg =~ /^([^=]+)=(.*)$/
65
+ Rscons.vars[$1] = $2
66
+ end
67
+ end
68
+
63
69
  if rsconsfile
64
70
  unless File.exists?(rsconsfile)
65
71
  $stderr.puts "Cannot read #{rsconsfile}"
@@ -143,6 +143,13 @@ module Rscons
143
143
  end
144
144
  end
145
145
 
146
+ # Return a String representing the VarSet.
147
+ #
148
+ # @return [String] Representation of the VarSet.
149
+ def inspect
150
+ to_h.inspect
151
+ end
152
+
146
153
  # Return an array containing the values associated with the given keys.
147
154
  #
148
155
  # @param keys [Array<String, Symbol>]
@@ -1,4 +1,4 @@
1
1
  module Rscons
2
2
  # gem version
3
- VERSION = "1.15.0"
3
+ VERSION = "1.16.0"
4
4
  end
@@ -25,5 +25,4 @@ Gem::Specification.new do |gem|
25
25
  gem.add_development_dependency "simplecov"
26
26
  gem.add_development_dependency "yard"
27
27
  gem.add_development_dependency "rdoc"
28
- gem.add_development_dependency "redcarpet"
29
28
  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.15.0
4
+ version: 1.16.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: 2017-09-08 00:00:00.000000000 Z
11
+ date: 2018-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -100,20 +100,6 @@ dependencies:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
- - !ruby/object:Gem::Dependency
104
- name: redcarpet
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: '0'
117
103
  description: Software construction library inspired by SCons and implemented in Ruby.
118
104
  email:
119
105
  - jholtrop@gmail.com
@@ -168,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
154
  version: '0'
169
155
  requirements: []
170
156
  rubyforge_project:
171
- rubygems_version: 2.6.13
157
+ rubygems_version: 2.7.7
172
158
  signing_key:
173
159
  specification_version: 4
174
160
  summary: Software construction library inspired by SCons and implemented in Ruby