Client/Server-mode for makepp
Makepp takes quite a bit of time to start up, read all the makefiles and check what to build. When developing you will do this frequently, but most often nothing or very little has changed in the makefiles and the dependencies. So, if makepp were still running, it could remember what it found out and start compiling almost right away. Inspired by ant server, that is what this attempts to do.
The normal makepp will be running as a server (just slightly differently than usually). It will be waiting for commands issued by a small Shell script, makeppclient. Any output that comes from performing the commands will be forwarded to makeppclient, as will the return code. Thus, it will seem as though the client is performing the build.
Before you can use it, you must start makepp as a server. Every user starts his personal server for his build directory.
makeppclient server-start-option [makepp-options] [VAR=value] [targets]
There are three modes for doing this, each controlled by a different option:
This will start the server as a batch job. Your system may assign it a rather low priority. Maybe it and again each of its subprocesses will not start until there are no competing processes in the run queue. This is sure to make you friends on a loaded multi-user machine.
This will start the server in the background while blocking the HUP and INT signals. That way, it will continue to run when you log out or close the terminal window you started it from. The Shell will probably assign it a somewhat lower priority.
This will simply start the server. You must put it in the background yourself, if you wish.
In each case you can give any of the -options or VAR-assignments you would give to makepp. These will stay in effect for all builds you subsequently perform with this server. The server will keep the current directory of the time you started it. This is important if you didn't give the -F option.
Specifiying targets is only a hint, they will not get built because of this. This can help the server to preload the most often used makefiles.
You can repeatedly tell the server to perform builds. This is equivalent to calling makepp every time, but you save the startup time. The command is:
makeppclient [client-option] [makepp-options] [targets]
There is one client-option possible:
This option has the same effect as redirecting the output of makeppclient from the Shell. But it is more efficient since the output will not first be forwarded to makeppclient.
The following makepp-options are possible and are passed to the server. Unlike those passed at server startup time, these are effective only for one invocation:
Not specifying a target is equivalent to building the default target as with makepp.
A server started with the --start-server option should simply terminate when you interrupt it, log out or close the terminal window you started it from. Otherwise you can explicitly tell the server to exit with:
makeppclient -e|--exit|--exit-server
There are some environment variables which influence the way in which this works:
This is the makepp that gets started as a server. By setting this, you can
use a different version, prepend a modifier like nice
or append some
options you will always want to pass it.
This is the directory where all the files for client/server functionality reside. You will need to set it to a different directory if you want to have an additional client/server pair. Both need the same value of this variable to be able to communicate.
This Shell command is used by the client, when called without the --output
option. It reads the server output on its standard input. You can set this
to a pager, tee
, a filter like sed
, grep -v
or even a pipeline of
these.
This is the variable by which makepp knows to run in server mode. Do not export this yourself, or makepp will be confused.
Three named pipes (fifos) over which client and server speak with one another.
If the server is started with the option --batch-server or --nohup-server, it will write any output, like messages about loading makefiles, to this file.
The presence of this file means that a server is running.
Already loaded makefiles will not be reloaded if they or their includes have changed, or again need to be regenerated. This should not normally be a problem, as makefiles should rarely change, because makepp offers powerful pattern rules and inference techniques.
Makefiles will also not be reloaded, even if they depend on
$(MAKECMDGOALS)
. This may lead to wrong builds! If you depend on this,
you must either always use the same targets, including at server start, or not
use client/server mode...
A server started with the --batch-server option may not have started by the
time you issue client commands. In that case you will get a "makeppclient:
server is not running." error message. This is not a bug -- just try again
later, as long as atq
or at -l
still list your batch job.
Daniel Pfeiffer <occitan@esperanto.org>