automated
compiling
and
running
(Also a pun because Auto is German for car.)
All starts with a project directory in which lies an autocar config. Simply run
autocar and it will start by searching all sources, then build them and (run
them). It does not run everything as that would be annoying for interactive
programs, that is why the cli includes a run
command to run any executable
that was built. However test files are all run if either a corresponding .data
or .input file exists for them.
Variable name | Purpose | Default |
---|---|---|
CC | The compiler to use | gcc |
DIFF | The diff program to use | diff |
C_FLAGS | flags to send the compiler | -g -fsanitize=address -Wall -Wextra -Werror |
C_LIBS | flags to send the linker | |
BUILD | output directory for all building | build |
EXT_SOURCE | file extensions of source files, multiple can be specified separated by | | .c |
EXT_HEADER | file extensions of header files | .h |
EXT_BUILD | file extensions of build files | .o |
IGNORE_HEADER_CHANGE | if header files should be checked for changes | false |
ERR_FILE | where errors of the compiler should go | stderr |
PROMPT | customize the prompt of the cli | >>> |
Flag | Purpose |
---|---|
--allow-parent-paths|-a | allows paths to be in a parent directory |
--config|-c <name> | specify a config (default: autocar.conf ) |
--help|-h | shows all arguments |
--interval|-i <number> | repeat interval, if this is 0, there is just a single iteration |
--no-config|-n | start without any config; load default options |
--verbose|-v [arg] | enable verbose output (-vdebug for maximum verbosity) |
Tests are all ran if they have a main object, autocar simply checks if an object
file has a function called main
and then declares that object as main object.
All main objects result in an executable that is stored in build and has no file
extension. If a .data file is present, this data is used to compare against the
output of the test. If a .input file is present, it is sent as stdin
into the
test. If neither .input nor .data are present, the test is ignored.
The cli allows adding of (test) files/folders and running.
add [files] [-t files] [-r files]
adds given files to the file list, (-t
for tests and-r
for recursive directories)config
show all config optionsbuild [--collect|-c]
build all files and optionally collect them beforehanddelete [files]
deletes given files from the file listecho [args]
prints the expanded arguments to stdoutgenerate <shell|make|c>
generate a shell, make or c build filehelp [args]
show helplist
list all filespause
un-/pause the builderrun <name> <args>
run file with given name. Userun
without any arguments to list all main programs. Userun $<index> <args>
for convenience.source [files]
runs all given files as autocar scriptquit
quit all
It is only checked if the prefix of the typed command matches, so q
is the
same as quit
or co
is the same as config
etc.
See below on how to set a variable.
Variables are stored internally as upper case values in a sorted list, every
variable has an array of strings as value. Case is ignored for variables:
a
and A
are the same variables. Variables have no limit on their name, one
could set a variable with name: {holy* this/ is a weirdname(*
. But when
setting a variable with this name, all special characters have to be escaped.
A command line may be of these forms:
<command> <args> [> output]
<name> = <args>
<name> += <args>
<name> -= <args>
<name> := <shell>
:<shell>
Any argument, command or name can be quoted and quotation marks as well as spaces can be escaped. To write multiple commands on a single line, use ';', the semicolon can also be escaped.
The first one executes the command with given arguments and optionally redirects
the output to a file, note that this only works when using config
; use this to
write the configuration variables to a file. The second one sets the config
value called <name>
to given arguments. +=
and -=
also modify a variable
but +=
appends and -=
subtracts to/from the values. :=
runs given shell
command and sets the variable to that; it is read as space separated array.
:<shell>
simply runs given shell command.
Note on <shell>
:
Sequences like $1
are not sent to the shell but are still interpreted by the
command parser.
There are two interpretations the command parser does:
$[0-9]+
$[^ \t]+
The first expands to the the file path of the file at given index starting from 1.
The second expands to the variable value like this:
A=1 2 3
echo $A
1 2 3
echo a$A
a1
B=$A $A
echo $B
1 2 3 1 2 3
If any file should be rebuild, the best way is to remove the object file/executable from the file system.
- cleanup