Patrick Doyle
9/26/2008 5:51:00 PM
Hi Brock,
I think I may have just found the source of your problem:
If you look at rake/loaders/makefile.rb (which, on my Windoze system
is somewhere near
ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/loaders/makefile.rb),
you will see something that looks like:
# Process one logical line of makefile data.
def process_line(line)
file_task, args = line.split(':')
return if args.nil?
dependents = args.split
file file_task => dependents
end
This will not handle C:\blah filenames correctly -- it split's them at
the first colon (":").
You could use that file as a source of inspiration to write your own
Rake::MakefileLoader#load method that correctly parses CCS generated
dependency files (perhaps splitting the file task from its dependents
after the first ".obj:", perhaps recognizing/depending on the hope
that/ CCS only places one dependency per line, etc...).
I'm not yet proficient enough in Ruby, and especially regular
expression matching to just rattle this off (but I know resources are
online to fill in all the bits I'm missing, or have gotten just plain
wrong), but you could probably replace the line of code that reads
require 'rake/loaders/makefile'
with something like (freely inspired by rake/loaders/makefile.rb)
module Rake
# Makefile loader to be used with the import file loader.
class MakefileLoader
# Load the makefile dependencies in +fn+.
def load(fn)
buffer = ''
open(fn) do |mf|
mf.each do |line|
# (I'm certain I've got the regular expression thing wrong here)
matches = line.match("(.*\.obj):\w*(.*)$")
file_task = matches[0]
dependency = matches[1]
file file_task => dependents
end
end
end
process_line(buffer) if buffer != ''
end
# Install the handler
Rake.application.add_loader('mf', MakefileLoader.new)
end
Does that make sense? (Once you figure out the right way to do
pattern matching in Ruby)
--wpd