bug-make
[Top][All Lists]
Advanced

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

Re: Patch to allow make to load plugins that add new functions.


From: Paul Smith
Subject: Re: Patch to allow make to load plugins that add new functions.
Date: Fri, 11 May 2012 16:33:24 -0400

On Sat, 2012-05-12 at 00:04 +0530, Samkit Jain wrote:
> I have been breaking my head over a simple thing of measuring the
> progress of build

It's simple to say, but it's not simple to know.  The structure of make
and how it performs builds means that it's not possible to know this.

make simply starts work, and keeps going building out of date things one
at a time until there's nothing left to build.  Only once make discovers
that there's nothing left, does it know that it's done.

It's NOT the case that make figures out everything that has to be built,
then walks through that list building it all.

> Would the plugin approach be able to help in with this kind of
> requests?

No, I don't see how.  Only a massive change to the way make works will
allow this information to be available.

> With my above proposal:
> 
> 1. A hook in makefile/plugin for "file added as prerequisite" will be
> invoked during first phase of make.
> 2. A hook in makefile/plugin for "prerequisite is newer than target"
> will be invoked during the second phase of make.
> 3. A hook in makefile/plugin for "prerequisite is not newer than
> target" will be invoked during the second phase of make.
> 
> Now inside the hook, a simple linear equation can be written to
> provide the measure of progress. In the example above, it can be "1 -
> 2 - 3" files are remaining to be built.

That is not good enough.  Consider this makefile:

        all: a b c
        debug: x y z
        a: e f g
        b: h i j
        c: k l m n o
        x: s
        y: t
        z: u v w

The total number of targets known in the makefile is 24.  Given "make"
or "make all", the maximum number of targets that we *might* want to
build is 15.

However, make doesn't know that until it's checked the last target: when
make starts to build "all" it sees the prerequisites a b c.  Here make
thinks there are 4 total targets to build.  Now make looks at "a", and
now it sees there are 7 total targets.  Once it checks all those and
starts on "b" make will see there are really 10 total targets.  And once
it's done all those and looks at "c" it will realize there are 15 total
targets.  Once it's done with 'c' it will realize there's nothing left
to do and NOW make knows there were a total of 15 total targets to
build.  But, it's done at that point anyway.





reply via email to

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