Hi all,
My problem at hand is to create a process that watches over a build with a Makefile, and sends a message with build break information if something goes wrong.
In essence, my solution is to log any relevant information and utility output in a file (message.log) that I use for sending the email. That way, when I receive an email, I should know what's wrong before going to the build machine.
This goes more or less like this:
%.o: %.cpp
echo "Compiling $<" >> message.log
$(CC) $< -o $@ >> message.log
The problem is that in parallel build, the message.log file is unreadable if multiple processes write to it (Unix), or breaks the build when processes lock the file for writing (Windows).
To work around this problem, the build would write to the log file only when the build is sequential. So my process is to build in parallel, and if the build break, the process runs the build sequentially, logging messages to the file, and when the sequential build breaks, the process sends the log file as information.
So, I'm thinking of a Makefile being like:
if (<<< Parallel build >>>)
LOGGING:=
else
LOGGING:= >> message.log
endif
%.o: %.cpp
echo "Compiling $<" $(LOGGING)
$(CC) $< -o $@ $(LOGGING)
This could work if I could detect when the build runs in parallel. How can I do that?
Fred