From: Patrick Doyle Date: 2008-09-27T00:31:03+09:00 Subject: Re: Problem with rake and dependencies I am not yet a rake enthusiast -- but just this morning I decided, "OK, it's probably time for me to start learning about rake". So, with that disclaimer, I would suggest that #import doesn't do what you think it does. Looking at the rake documentation (http://rake.rubyforge.org/), it describes File#import as a procedure that imports partial rakefiles. Not having played much with rake yet, I'm somewhat surprised that it doesn't bomb when you import the code composer dependency file. But, be that as it may, what you probably want to do is to write a rake task that parses each line of the CCS file and adds a rake dependency based on what it finds there. Of course, that may fly in the face of whatever FAQ/tutorial/book you're using, in which case, I would say follow the other source since (s)he knows infinitely more about rake than I do :-). Good luck! --wpd On Fri, Sep 26, 2008 at 9:42 AM, Brock Rycenga wrote: > Hello: > > I am new to rake, and I am stuck on a problem with incremental building. > My rakefile does what I would like, for the most part. If I touch a .c > file, the rakefile functions properly and only builds the necessary > files. However, if I touch the corresponding .h file, my rakefile > assumes everything is up-to-date. I am pretty certain that I am not > importing/loading my dependency files correctly. Please help. > > I am using a dependency generation feature that is part of the DSP > compiler we are using. The output from the preprocessor creates files > with a .pp extension, formatted like so: > > C:/dir/obj/lcd.obj: C:\dir\lcd.c > C:/dir/obj/lcd.obj: C:\dir\lcd.h > C:/dir/obj/lcd.obj: C:\dir\lcdpanel.h > C:/dir/obj/lcd.obj: C:/CCStudio_v3.3/C6000/cgtools/include/string.h > C:/dir/obj/lcd.obj: C:/CCStudio_v3.3/C6000/cgtools/include/linkage.h > > I decided to copy those files to a file with a .mf extension because I > was hoping that the makefile loader would handle things correctly. > > Below is my rakefile. Notice that I am attempting to import the > dependency files within my :build_depend task. Unfortunately, I have no > idea what import does, and therefore I have no idea if my dependencies > are getting extracted in a way that rake understands. > > ############################################################################### > ############################################################################### > ############################################################################### > ############################################################################### > require 'dsp_build_defs' > > ## The following require's are actually found in my dsp_build_defs.rb > file > require 'rake/clean' > require 'rake/loaders/makefile' > require 'fileutils > > include DspRakeFileConstants > > ############################################################################### > # Create the list of source files, etc. > ############################################################################### > #SRC_FILES = FileList["#{DSP_PROJ_ROOT}/**/*.#{C_EXT}"] > SRC_FILES = FileList["#{DSP_PROJ_ROOT}/**/*.#{C_EXT}"].reject {|f| f =~ > /cropped/} > DEPEND_FILES = SRC_FILES.ext("#{MF_EXT}") > OBJ_FILES = SRC_FILES.pathmap("#{OBJ_DIR}/%n.#{OBJ_EXT}") > > ############################################################################### > # Task definitions > ############################################################################### > desc 'Default task to build debug version of dsp software' > task :default => :debug_build do > OBJ_FILES.each do |srcfile| > #puts "source file: #{srcfile}" > end > DEPEND_FILES.each do |depfile| > #puts "source file: #{depfile}" > end > end > > desc 'Debug_build task that depends on build_depend and build_obj' > task :debug_build => [:build_depend, :build_obj] do > puts "almost ready to link..." > end > > desc 'Release_build task - not currently being called' > task :release_build => RELEASE_BLD > > desc 'Build_obj task that depends on the object directory and the object > files' > task :build_obj => [OBJ_DIR, OBJ_FILES].flatten.uniq > > desc 'Build_depend task that depends on the dependency files' > task :build_depend => DEPEND_FILES do > DEPEND_FILES.each do |dep_file| > puts "Importing #{dep_file}..." > import "#{dep_file}" > end > end > > directory OBJ_DIR > > ############################################################################## > # Rule definitions > ############################################################################## > rule ".#{DEPEND_EXT}" => ".#{C_EXT}" do |t| > puts "Building dependency file for #{t.source}" > sh "#{COMPILER} #{C_OPTS} #{C_DEPEND_OPTS} #{C_OBJ_DIR} > #{C_INC_PATHS} #{C_FLAGS} #{C_TARGET} #{t.source}" > end > > rule ".#{OBJ_EXT}" => lambda{|objfile| find_source(objfile)} do |t| > puts "Building object file for #{t.source}" > sh "#{COMPILER} #{C_OPTS} #{C_OBJ_DIR} #{C_INC_PATHS} #{C_FLAGS} > #{C_TARGET} #{t.source}" > end > > rule ".#{MF_EXT}" => ".#{DEPEND_EXT}" do |t| > puts "Copying #{t.source} to #{t.name}" > sh "cp #{t.source} #{t.name}" > end > > rule ".#{BIN_EXT}" do |t| > puts "Linking..." > end > ############################################################################### > ############################################################################### > ############################################################################### > ############################################################################### > > > Thanks, in advance, for the help! > > > Best Regards, > Brock > -- > Posted via http://www.ruby-forum.com/. > >