[Top][All Lists]

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

"Exception handling" ?

From: Tim Murphy
Subject: "Exception handling" ?
Date: Tue, 5 Jun 2007 10:31:05 +0100

I wonder if anyone has ever wanted the ability to "handle" the failure of a rule?

I needed it so that I could produce various types of log information when a compile/link step failed.

I have used some ugly macros to wrap my rules in a bash subshell so that I can catch the return result, perform my logging and then using exit with the original result. This forces me to make all the lines of the rule end with "&& \" so that I can process all of them in the handler.

It works but it's error-prone and I wondered if anyone else had ever wanted some alternative mechanism?


# Rule Failure handling.
# please excuse use of spaces - can't do tabs in gmail
fred.exe: $(OBJLIST)
       echo "<link target='$@'>"
       echo $(OBJLIST) > objectlistfile
       link -v objectlistfile -o $@
       echo "<error target="$@" type='postlink'>OBJLIST=$(OBJLIST)</error>
      -rm objectlistfile
      echo "</link>"

I am not fixated on what the syntax might be - the example is just for argument's sake.

The features would be:
1) the "finally" rule allows one to guarantee the ability to clean up after some failed rule no matter what kinds of things it may have done - whether creating temporary files or other state changes.
2) The "onfail" rule allows one  to log useful information in the event of some error.  On multi-hour builds with "keepgoing" enabled this is very useful and keeps the logs small and relevant.
3) One can make logs that show the start and end of a rule - which makes it slightly more parsable.

What do you think?




reply via email to

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