File generator to reduce the manual effort to prepare another scripting files which contain C code information derived by a C source file.
$ cyagen --source ./example/source/sample.c --temp-dir ./example/template --output-dir ./.output
$ cd .output
$ cmake -S . -B build
$ cmake --build build
$ cd build && ctest
All the available identifiers can be found on docs.rs
Notice: all the new identifiers are not supported on the old style of template (not jinja2 format).
``` let sourcename = "source"; let code = "\
static int var = 1; static int func1(void) { return 0; } int func2(char c) { return func1(); } "; let temp = "\ // include {%- for inc in incs %} {{ inc.captured | safe }} {%- endfor %}
// local variables {%- for var in static_vars %} {{ var.dtype }} {{ var.name }}; {%- endfor %}
// functions {%- for fnc in fncs %} {{ fnc.rtype }} {{ fnc.name }}({{ fnc.args }}); {%- endfor %} "; let parser = cyagen::Parser::parse(code); let gen = cyagen::generateusingtera(&parser, temp, sourcename); println!("{}", gen); ```
``` // include
// local variables int var;
// functions int func1(); int func2(char c);
```
``` $ cyagen --help cyagen 0.1.10 Text file generator based on C file and templates
USAGE:
cyagen [OPTIONS] --source
OPTIONS:
-s, --source