File | Date | Author | Commit |
---|---|---|---|
examples | 2025-03-14 |
![]() |
[5af96c] Fix some compile flag issues |
.hgignore | 2024-02-28 |
![]() |
[66d758] Initial load |
.hgtags | 2025-03-14 |
![]() |
[c62484] Added tag V0-18 for changeset 5af96c95d988 |
README.md | 2024-11-25 |
![]() |
[703ab2] Build leg files |
crune.pl | 2025-03-14 |
![]() |
[5af96c] Fix some compile flag issues |
gcc_check_ver.pl | 2025-03-14 |
![]() |
[5af96c] Fix some compile flag issues |
The command crune.pl
is a Perl script that is intended to allow the execution of short C programs. This is primarily intended to allow the experimental testing of small segments of C code without having to create a makefiles, executables, etc; but can also be used to build
complete micro-projects, again without the need for makefiles.
The following linux commands are dependencies of this command:
perl
g++
gcc
leg
pkg-config
fltk-config
Command line is: crune.pl
[ options ] source_file_name [ sub_options ]
Options are not case sensitive, and may yse '--' prefix in place of '-' prefix.
Options may be shortened to single characters (i.e.-h
is the same as -H
is the same as --help
).
source_file_name may not start with a hyphen.
These are passed verbatim to the executing program (i.e. they have no impact upon the processing by the crune.pl
script but when the -run option is used then after the source file has been compiled then when the compiled file is being executed then these sub-options will be added to the command line of the executing program).
crune.pl examples/colours.c
The above will attempt to compile a temporary executable from the source file examples/colours.c
, then if the compile succeeds it will execute the compiled program and finally delete the temporary executable that was created.
This command can be executed against C files (with .c
or .h
file extensions) or C++ files (with .cpp
or .hpp
file extensions).
Within the source code the script will look for special C comment lines of the form:
//% options <flags>
or
//% library <library-list>
or
//% pack <flags>
or
//% show <text>
or
//% use <file-list>
or
//% fltk <flag>
or
//% version <version-list>
These special comments must be on a line of their own, but do not have to be left aligned in the file (i.e. they may have preceding spaces).
The options
flags will insert the flags directly into the gcc
command line.
You may also use option
or opt
as an alias for options
.
If you have a file called colours.c
that contains the following line:
//% option -lncurses
and you execute the command: crune.pl colours.c -s -b
The it will execute the following gcc command: gcc "colours.c" -o "./colours" -lncurses
This is merely a convenient alternative to the option
copmmant for libraries.
You may also use libas an alias for
library`.
You may include a list of space separated libraries in the same line.
//% library ncurses
is exactly equivalent to
//% opt -lncurses
The pack
flags will generate compiler flags using the pkg-config
command.
You may also use pack
as an alias for package
.
If you have a file called gtk_test.cpp
that contains the following line:
//% pack --cflags --libs gtkmm-3.0
and you execute the line: crune.pl -s -b gtk_test.cpp
This will case the following compilation command to be executed:
g++ -x c++ "/home/ggb/Dev/crune/examples/gtk_test.cpp" -o "./gtk_test" -g -O0 -Wall -fstack-check -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/atkmm-1.6 -I/usr/lib/x86_64-linux-gnu/atkmm-1.6/include -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -pthread -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lgtk-3 -lgdk-3 -lz -latk-1.0 -lcairo-gobject -lgio-2.0 -lpangomm-1.4 -lglibmm-2.4 -lcairomm-1.0 -lsigc-2.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lcairo -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0
This invokes fltk-config
to add appropriate library and include paths for includinf fltk
in the compiled object.
The additional option on the command is either static
or dynamic
to indicate whether the target compile should include a static or dynamic library.
//% fltk static
Will cause another file to be read for further special comment lines. The other file may be another source file (e.g. another header file) or just a plain text file that contains no source code but only comment lines.
A semicolon delimited list of files may be included within the command.
Every file mentioned in any use
command will be parsed exactly once, even if it is mentioned multiple times in multiple files.
//% use my-comments.txt ; my-header-file.h
Will cause the text specified on the line to be printed to STDOUT while the file is being parsed.
The command is primarily intended to aid in determining which files are being processed.
You may also use sho
as an alias for show
.
//% show Display this text when file is being parsed.
Will check that the compiler supports the specified language version.
version-list can be a space separated list of lanuage versions. This is primarily intended to allow the same file to be used for both C and C++
programs, and that it might check that the language version is applicable for the language being used.
You may also use ver
or vers
as aliases for version
.
//% version c11 c++14
If this is being compiled in a C++ content then the c11
check will be ignored, and if this is being compiled in a C content then the c++14
check will be ignored.