RunC is a simple (and somewhat crude) system that helps you use C++ as a scripting language under Unix.
The basic idea is to use Unix's #! script convention to pass control to the runc programme. The runc programme compiles the script as C++ in to an executable, and then runs the executable. The compiled executable is cached, and recompilation only occurs if the script is modified.
Please note that this is the first release of RunC. It has only been used on one operating system (OpenBSD), so things might not work on other systems.
This release of RunC is available as the file runc-1.tar.gz.
The makefile is very simple, but requires GNU make.
Making a C++ source file into a script is simple:
RunC is intended for single-file C++ programmes. If you want to use code from a different source file, the simplest way of doing this is to simply #include the other source file.
Note that RunC's date-stamp detection will not force a recopmilation when the other source is changed.
Probably the best way of implementing RunC would be to install it as a new shell interpreter. But this requires root priviledges, so instead it works in a different way by passing an intermediate shell script to the shell interpreter, using: #!/bin/sh <absolute path to intermediate shell script>. This intermediate shell script is passed the original shell script's filename followed by any parameters.
So, scripts that use the RunC system have a first line like:
#!/bin/sh <absolute path to runc script>
The runc script simply calls runc2, passing all its arguments. runc2 is a compiled C++ programme which implements the main RunC functionality - the datestamp comparisons, calling the compiler and calling the compiled executable.
The command used to compile scripts can be see in runc2.c++; it calls g++, and uses -x c++ to force the input script to be treated as C++ source.
I've only ever used RunC on OpenBSD 3.1 and 3.2; I don't know whether other OS's /bin/sh's behave in exactly the same way.
You can get custom control of the build by having a second line looking liks: #!-build <build command>. For example:
#!/bin/sh <absolute path to runc programme> #!-build g++ -D FOO=bar
When a script is compiled, RunC takes this build command, and appends <input filename> -o <output filename>.
This is RunC release 1, 24 Dec 2002.
RunC is Copyright (C) 2002 Julian Smith.
RunC is released under the GNU Public License. Please see http://www.gnu.org/copyleft/gpl.html, or write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Julian Smith, email: firstname.lastname@example.org.