Skip to content
davidmoreno edited this page May 9, 2011 · 2 revisions

Compile-Run Loop is a simple helper that tracks the modification of source code files, and according to them, automatically stops the running program, recompiles and runs it again.

With this simple mechanism you are not tied to slow iterations of development, compile, try. You skip the compile part and just development and try.

This works on GNU/Linux on ELF files. It should work on any programming language that outputs proper debug info: C programming language, C++, D, Go, Fortran, Pascal, Java... But it has only been tested with C. Programs to be used this way need to be compiled for debugging, as that's the only way to know which are the source files of the executable.

For many projects it might not be interesting or useful, but for some others its a real time saver.

It is similar to Django automatic autoreload on source modification, and on some Java frameworks.

How it works

crl first lists the source file parts of an executable, using readelf. Next step is compiling the program. Then sets an inotify for all them and executes the program. When inotify realizes there has been a change, it kills the program (first with a gentle SIGTERM, after some seconds with SIGKILL), and start the compile-run loop again.

Compilation is performed executing make at current directory.

Usage

You can use directly the shell script at tools/clr/compilerunloop.sh or when onion is installed its installed as crl. It just needs the executable name, and its arguments. For example crl examples/hello/hello will work, as will crl ./hello at the right directory.

Clone this wiki locally