help-make
[Top][All Lists]
Advanced

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

Re: stop when error happen during parallel build


From: Todd Showalter
Subject: Re: stop when error happen during parallel build
Date: Thu, 9 Sep 2010 08:44:54 -0400

On Thu, Sep 9, 2010 at 4:48 AM, Lynn Lin <address@hidden> wrote:

>   I run make with parallel build,if error happen,it doesn't stop(this
> is reasonable,correct?),the error seem hidden as we have many module
> to compile
>   is there any good solution to resolve this? I use recursive make,is
> this one reason ?

    I find that (in general) it's a good idea to suppress any
unimportant output from make.  In practice, this means prefixing all
commands everything with @, and recursing with -s in the flags.  If
you don't do this, errors and warnings get lost in the build noise in
larger builds.

    We've built a banner printing routine for our system, so commands look like:

%.o: %.c
    $(BANNER) build "Compiler" "$(notdir $<)"
    @$(CC) $(CFLAGS) -c $< -o $@

    Our banner program does a few things; depending on the first
argument ("build", "intro", "outro" or a few other commands) it prints
subsequent arguments in different ways.  For "build", it does
something that looks like this:

        Arg1 -- Arg2

    So what you see when compiling is:

        Compiler -- Foo.c
        Compiler -- Bar.c
Engine/Sound/Bar.c:201: warning: unused variable 'q'
        Compiler -- Baz.c

    The warnings and errors stand out because they *aren't* indented;
they break the flow.  We use the intro and outro (which throw an hrule
across the terminal as well) to delimit sections of the project.  We
also went for extra points and colorized the output.  The result is
output that is both easy to scan visually, and easy to process
mechanically; it's easy to grep the build log for all errors and
warnings simply by filtering out any lines that start with whitespace.

    Parallel build will potentially screw the ordering up a bit, due
to the interleaved printing, but you'll still get obvious warnings and
errors.  You can even do it trivially within make if all you want is
the equivalent of the "build" banner, above; we have a standalone
program to do the job because it actually attempts to do some text
formatting and such.  $(call) and echo will do the job:

BANNER = @echo "$(1) -- $(notdir $(2))"

%.x: %.y
    $(call BANNER,Frobnicate,$<)
    @gfrob $< $@

    If you build a system like this, you could fairly easily log the
output of all your make processes, and (at completion), grep the logs
and dump all warnings and errors to the console.

                                               Todd.

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



reply via email to

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