help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to modify algorithm that determines weather a target needs rebu


From: Todd Showalter
Subject: Re: How to modify algorithm that determines weather a target needs rebuild
Date: Mon, 9 Aug 2010 08:46:42 -0400

On Mon, Aug 9, 2010 at 1:18 AM, mirage1987 <address@hidden> wrote:

> This means at runtime it compares timestamp of each and every file with the
> corresponding object file's timestamp.
> What i just want is to change this condition from being "greater than" to
> "equal to".
> Instead of storing timestamps in the database i intend to modify the
> timestamps on the filesystem using
> "touch".

    That's almost certainly going to lead you to madness and woe, even
without make in the equation; file timestamps are strange beasts and
don't always represent quite what you think they ought to.  In
particular, on some operating systems, the relationship between "now"
and the timestamp on a file can be very fuzzy.  As can the
relationship between the timestamps of two files "touched" at the same
time.

    I think you'll find if you try this that it mostly works but
breaks in strange ways every once in a while, and will be completely
unportable if you try to take it to another platform.  Think about
what happens, for instance, if you touch a couple of files and the
clock "ticks" in the middle of the operation.

    If you feel you must do something like this where the metadata for
the build is contained in the filesystem rather than an external
database, the easiest way to do it is by modifying the file *name*
rather than the timestamp.  Add an additional extension (or a prefix),
or use subdirectories.
make plays very nicely with that kind of thing.

    Personally, though, I'd say database is the way to go.  Anything
else is going to be unportable and fragile at best.  Saying "database"
doesn't mean you need to need to drag in MySQL or even BerkeleyDB; it
can just be a flat text file that lives alongside the build, one
filename per line.  We use something like that in our system; it's
easy to read that into a variable in make and use it to drive the
build process.

    The system we use is a little more robust than that; we have a
preprocessing tool that actually assembles the makefile depending on
platform and so forth, but the easy version of what we did is just a
text file that gets sucked into $(SRCS) in make.

                                                  Todd.

-- 
 Todd Showalter, President,
 Electron Jump Games, Inc.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]