tsgenmodsrc

Name
tsgenmodsrc - Generate source code for TSLoad module

Synopsis
$ tsgenmodsrc [global options] subcommand path/to/modinfo.json

Description
tsgenmodsrc generates environment using modinfo.json configuration file, called modvars. Then it loads templates from development directory of TSLoad and preprocesses them.

A chosen set of generated files depends on -b and -t global options:

Paths to TSLoad installation directories that is used by tsgenmodsrc to locate templates and added to build files are usually deduced from tsgenmodsrc location, but if they didn't, they could be specified from environment variables:

Variables

To see what variables are generated by tsgenmodsrc, call it with vars subcommand:

$ tsgenmodsrc [global options] vars path/to/modinfo.json

These options may be redefined by vars object inside modinfo.json config. However some of them has [generated] flag that means that they are not settable from config, and generated from other options - for example structure fields.

Workload type variables are contained in namespaces, so different wltype would get different values:

Generating sources

Sources are generated in two modes. In first one, tsgenmodsrc will write appropriate file to stdout, where template used for file is determined by provided subcommand:

In second mode, which is activated by generate command, tsgenmodsrc will automatically create file hierarchy inside the same directory where modinfo.json configuration file is located. If directory has other files than modinfo.json, command will fail, so tsgenmodsrc wouldn't overwrite them.

If sources were generated in second mode, they and object files created during build may be cleaned up with clean command. tsgenmodsrc caches creation times of files in special file .ctime_cache, so if you will change source, it will warn you before cleanup. clean subcommand will ask for confirmation before cleanup that should be answered y (yes) or f (force), if warnings were found.

Preprocessor

To generate sources and build files, tsgenmodsrc uses preprocessor. This preprocessor uses at symbol @ as command character. Note that it doesn't support its escaping (but for Makefiles where $@ has special meaning), it will ignore that character.

Preprocessor supports following features:

Complete BNF for preprocessor is:

<opt-whitespace>     ::= <whitespace> | <whitespace> <opt-whitespace> | ""

<var-char>           ::= <alpha> | "_"
<var-name>           ::= <var-char> | <var-char> <var-name>

<dir-param-var>      ::= <opt-whitespace> <var-name> <opt-whitespace> <EOL>
<dir-param-nothing>  ::= <opt-whitespace> <EOL>

<subst-expr>         ::= "@" <var-name> "@"

<block>              ::= <text> | <ifdef-block> | <subst-expr>
<blocks>             ::= <block> | <block> <blocks>

<else-block>         ::= "@else" <dir-param-nothing>
                         <blocks> <EOL>
<opt-else-block>     ::= <else-block> | ""
<ifdef-block>        ::= "@ifdef" <dir-param-var>
                         <blocks> <EOL>
                         <opt-else-block>
                        "@endif" <dir-param-nothing>

<define-block>       ::= "@define" <dir-param-var>
                         <blocks>
                        "@enddef"
<foreach-block>     ::= "@foreach" <dir-param-var>
                        <blocks>
                        "@endfor"