hsk-libs-scripts
270
High Speed Karlsruhe XC878 build scripts
|
Creates a list of dependencies for compiling or linking. More...
Functions | |
var | testf (var file) |
Tests whether a file can be opened. More... | |
var | rescape (var str) |
Escape the given string for literal use in a regular expression. More... | |
var | sescape (var str) |
Escape the given string for command line use. More... | |
var | extract (var a) |
Returns an arbitrary index from an array and deletes it. More... | |
var | any (var a) |
Returns whether any of the entries in a given array evalutate to true. More... | |
var | compact (var path) |
Returns a compacted version of the path. More... | |
void | filter184 () |
Perform recursive include and output C/C++ file names. More... | |
Creates a list of dependencies for compiling or linking.
The command line arguments are used to produce a CPP command. The given files need to be processed by CPP in order to make sure macros and conditionals are (correctly) expanded.
The output is filtered to only print files in the same directory or subdirectories of the given file. Paths can be added explicitly by using the -I argument.
The following arguments receive special treatment:
Argument | Description |
---|---|
-compile | Choose to produce a dependency list for compiling |
-link | Choose to produce a dependency list for linking |
-I<path> | Paths are added to the output filter |
The script can either create a dependency list for compiling or linking.
In any mode the given file (multiple files can be chosen as well, but there is no useful use case) is passed to the CPP. The CPP resolves all includes.
The includes are filtered from the CPP output by this script.
In compile mode all files and includes are output once. In link mode includes are instead checked for heaving a corresponding C/C++ file that ends with the suffix SUFX. Only in that case is the file name printed and also recursively passed to the CPP.
Modes can be combined.
If the following arguments are not set using AWK's -v argument, they can be set as environment variables.
Variable | Description |
---|---|
DEBUG | If set output debugging information on stderr |
CPP | The C/C++ preprocessor command, defaults to cpp |
SUFX | The file name suffix for c/c++ files |
The SUFX variable defaults to the file ending of the first file name given in the arguments.
Non-existing files are ignored during list-creation, this can be used to set the file ending by providing the desired file ending as the first argument:
awk -f depends.awk .c -link <file>
var testf | ( | var | file | ) |
Tests whether a file can be opened.
file | The name of the file to test |
1 | The file exists and can be read |
0 | The file cannot be opened |
var rescape | ( | var | str | ) |
Escape the given string for literal use in a regular expression.
str | The string to escape |
var sescape | ( | var | str | ) |
Escape the given string for command line use.
str | The string to escape |
var extract | ( | var | a | ) |
Returns an arbitrary index from an array and deletes it.
a | The array to fetch an arbitrary index from |
var any | ( | var | a | ) |
Returns whether any of the entries in a given array evalutate to true.
a | The array to check for true entries |
0 | No true entries |
1 | At least one entry evaluates to true |
var compact | ( | var | path | ) |
Returns a compacted version of the path.
This gets rid of ../ by removing the previous path.
path | The path to compact |
void filter184 | ( | ) |
Perform recursive include and output C/C++ file names.
BEGIN