Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.4.7, 1.4.8
Description
Buildr cc's timestamp logic only handles source directories, not source files. This means that `buildr cc` neglects to recompile when explicitly declared source files are touched. The relevant logic in cc.rb:
timestamps = lambda do
times = {}
dirs.each { |d| Dir.glob("#
times
end
When d is a file, Dir.glob("#{d}
/*/") returns [], meaning the timestamp is never recorded. The patch seems simple: Add a check to see what 'd' is. I've coded a patch to do just that. I've tested that it works for both dirs and files, but can't get rake spec to work on an up-to-date trunk. That problem, however, doesn't appear to be my patch. I've pushed the patch to my github buildr clone at https://github.com/ctiwald/buildr/commit/e9530fa554e9d64c720567aa00bfb6dbbea1fea0 and the raw git diff output is below. I'd be happy to submit this via another method. I wasn't quite clear on how to submit a patch in JIRA.
Raw git patch:
CompileTask's 'from' method accepts both directories and files, but
the cc task polls files incorrectly. Test whether or not the source
is a file or a directory and apply File.mtime accordingly. Directories
use the original logic, running File.mtime on a map of <directory>/*/.
Skip the mapping if the source is a file.
—
lib/buildr/core/cc.rb | 22 ++++++++++++++--------
1 file changed, 14 insertions, 8 deletions
diff --git a/lib/buildr/core/cc.rb b/lib/buildr/core/cc.rb
index 8638072..74e3677 100644
— a/lib/buildr/core/cc.rb
+++ b/lib/buildr/core/cc.rb
@@ -53,21 +53,27 @@ module Buildr
build_failed(project, ex)
end
- dirs = []
+ srcs = []
each_project do |p| - dirs += p.compile.sources.map(&:to_s)
- dirs += p.test.compile.sources.map(&:to_s)
- dirs += p.resources.sources.map(&:to_s)
+ srcs += p.compile.sources.map(&:to_s)
+ srcs += p.test.compile.sources.map(&:to_s)
+ srcs += p.resources.sources.map(&:to_s)
end - if dirs.length == 1
- info "Monitoring directory: #
{dirs.first}
"
{srcs.first}
+ if srcs.length == 1
+ info "Monitoring directory: #"
else - info "Monitoring directories: [#
{dirs.join ', '}
]"
{srcs.join ', '}
+ info "Monitoring directories: [#]"
end
timestamps = lambda do
times = {}
- dirs.each
Unknown macro: { |d| Dir.glob("#{d}/**/*").map { |f| times[f] = File.mtime f } }
+ srcs.each { |a|
+ if File.directory? a
+ Dir.glob("#{a}/*/").map { |f| times[f] = File.mtime f }+ else+ times[a] = File.mtime a+ end+ }times
end