Remake is a very simple tool for running Make commands automatically.
remake [target] instead of the usual
make [target] and it will
automatically run the command each time changes are made.
Gone are the days where you have to switch to a terminal and then press Ctrl+C, Up, Enter after making changes!
What does Remake do?
In basically runs
make [target] and then watches for changes.
There are 2 scenarios:
The make command exits quickly
Next time you make changes, Remake will run the command again.
The make command is a long-running process
Next time you make changes, Remake will kill the process and then run the command again.
- Tested with:
- GNU Make 4.1 (Ubuntu 18.04)
- GNU Make 4.2.1 (Debian 10 WSL2)
- Tested with:
Download the relevant version from the releases page, add it to your
$PATH, and make it executable.
wget https://github.com/raymondbutcher/remake/releases/download/v0.1.0/remake-linux-amd64 sudo mv remake-linux-amd64 /usr/local/bin/remake chmod u+x /usr/local/bin/remake
Using Remake is like using Make, except that it keeps building the target
whenever something has changed. If you would normally run
make then you
remake. Instead of
make dist it would be
Remake has been designed to require no configuration and no command line arguments. Still though, there are some options if the default behavior does not suit.
remake -h or
Displays the available command line options.
remake -check=2s [target]
This controls how often Remake checks for changes. The default interval is
remake -grace=10s [target]
Scenario: a make command builds a HTTP development server and then runs it in the foreground. When it starts up, it can take a second or two to build the binary, minify CSS and JS files, etc, to satisfy its dependencies. It then runs the HTTP server and serves requests.
It would not be good to restart the command while it is starting up and
building everything as instructed. So there is a grace period of 10 seconds,
configurable with the
-grace command line option.
During the grace period, Remake will regularly check to see if everything is up to date yet. As soon as it is, normal monitoring begins. If the grace period is exceeded, and the command is still running, then it will be restarted.
To be more precise during the grace period,
remake -ready can be run
from within a make command to let it know that the build phase of the
command has finished. Remake will immediately leave the grace period
and start monitoring for changes as usual.
This is not particularly useful, nor very noticeable; it just allows Remake to be slightly more responsive to changes.
Because Remake won't necessarily be installed everywhere, it makes sense to
remake -ready command fail silently when used in a Makefile.
# Shortcut for running "remake -ready" if available. READY=remake -ready 2>/dev/null || true http: bin/myapp @$(READY) @echo Starting HTTP server... bin/myapp -http bin/myapp: $(wildcard src/myapp/*.go) @echo Building my app... go install myapp
Note: The ready signal has no effect when Remake is running multiple targets, because it cannot tell which command sent the signal. The grace period will work as normal.