From: Brock Rycenga Date: 2008-09-26T22:42:04+09:00 Subject: Problem with rake and dependencies 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/.