[Rake-devel] FileTask#needed? and FileTask#timestamp "bug"

philipp.neubeck at gmx.de philipp.neubeck at gmx.de
Mon Sep 5 06:37:51 EDT 2005

On Mon, 05 Sep 2005 00:00:40 -0500
Patrick Bennett <patrick.bennett at inin.com> wrote:

> I simply patched my local rake's timestamp method to return Time.at(0) 
> for files that didn't exist as it fit the existing model better as far 
> as I was concerned.
> Since I created a dependency generator for C++ source, it was possible 
> to generate dependencies for files (based on #include's) that might not 
> exist on a particular platform, so prerequisites that didn't exist had 
> to effectively be ignored.

> Once you change the timestamp method to check for the existance of its 
> file and return a timestamp as appropriate, a rescue class in needed? is 
> no longer necessary.
(in the current implementation: ) but if no timestamp as appropiate is returned but a exception thrown instead then the rescue in needed? does NOT catch the exception. it only catches missing tasks.

> However, IMO, in your example 'bar' should *not* be invoked.  A missing 
> prerequisite should not be counted as a newer prerequisite.
> Should a rule that specifies main.obj with a prereq of main.cpp cause an 
> attempted invokation of the main.obj rule when main.cpp is missing?  
> That's what you're stating here.

so if you do the opposite ( main.cpp is missing => no creation of main.obj ) the problem is that main.obj is simply in a _wrong_ state. the programmer should be able to recognize that there is something missing/wrong and so it should be tried to rebuild the main.obj or (if you say the prerequisites are a must) Rake should through an error.
ok i think the second would be better: no invokation of main.obj but Rake throwing an error. missing prerequisites should be counted as missing.

so let me repeat the example with main.cpp and main.obj as i think it should be:

file main.cpp
file main.obj => main.cpp

(let out timestamp) main.obj get's invoked (not yet excecuted), so rake first tries to create the prerequisites. the file task main.cpp sees that the file is missing and says it is "needed" (see the FileTask#needed? code). file main.cpp gets invoked and excecuted but since there's no attached action rake throughs an error, that it can't create a needed file.

the timestamp stuff should reflect this, so timestamp of a missing file must return "now" as it is always needed to be invoked.

i see the point you state with the platform dependend prerequisites. and therefore you would need something like optional dependencies. but i don't see a way how to distinguish optional and needed prerequisites on c++ site, because (i think you did that too) the dependencies are autogenerated by gcc.
hmm... or does gcc -MM -MG utilize the precompiler and then read the dependencies? (#include keyword is for the precompiler too) then you should be able to solve this problem with common #defines for your platforms (i think you did this anyway, or you would get compile errors, because of missing includes)

anyway, i think all we said is better than the current implementation. because the current throws exceptions and you don't know where they come from.


(i hope i don't write too crappish, cause im normally talking german)

More information about the Rake-devel mailing list