\page mipi_syst_catgen_page Automated Catalog Generation
[TOC]
Catalog Example {#mipi_syst_catgen_sample}
==============================================================================
The distribution includes an example application that uses catalog
messages generated by the [MIPI_SYST_CATPRINTF](@ref PrintfApi),
[MIPI_SYST_CATALOG64](@ref CatAPI64) or [MIPI_SYST_CATALOG32](@ref CatAPI32)
families of instrumentation API calls. The example also includes the necessary
configuration to support the automated decode collateral generation tool. This
tool scans the source code and extracts the catalog decode information into
collateral needed by SyS-T decoders.
The example is stored under `examples/client` in the source code distribution.
Decode Collateral Creation Tool {#mipi_syst_catgen_tool}
==============================================================================
The project includes a PERL based collateral generator that automates the
creation and updating of SyS-T decode collateral in XML format. This
generator parses the catalog instrumentation points by scanning the
client source code. The tool can be embedded into a software build process to
keep software builds and decode collateral updated at the same time. The tool
is stored in the ```collateral/generator``` directory of the project with the
name ```syst_cgen.pl```.
Dependencies {#mipi_syst_catgen_deps}
------------------------------------------------------------------------------
The generator is written in PERL and requires a PERL installation with the
following optional modules installed.
* String::Escape
* Xml::Simple
Refer to the documentation for your PERL installation on module installation.
On Linux, the following commands can be used:
```
$ perl -MCPAN -e 'install XML::Simple'
$ perl -MCPAN -e 'install String::Escape'
```
Collateral Generation Process {#mipi_syst_catgen_process}
------------------------------------------------------------------------------
The collateral generator takes a SyS-T collateral template and
a configuration file as input. The configuration file defines the locations
and file extensions of the source files to be scanned and how the catalog
message calls
inside the source code are named. The tool can then detect the catalog
calls, and extract the format strings, source locations, and
catalog IDs to update the collateral template file. The result is a
new collateral file that matches the actual state of the source code.
Catalog Generation Example {#mipi_syst_catgen_example_generation}
------------------------------------------------------------------------------
The client application in ```example/client``` uses various catalog calls.
It provides a configuration file for ```syst_cgen.pl``` to detect
the SyS-T catalog message calls, and a collateral template file that is
updated by the generator. It is executed in the following way:
```
$ perl ../../collateral/generator/syst_cgen.pl -config collateral_config.xml
syst_cgen.pl: Parsing: ./othersource.c
syst_cgen.pl: Add ./othersource.c with file id 1 to file catalog
syst_cgen.pl: Parsing finished: ./othersource.c, found 127 call(s)
syst_cgen.pl: Parsing: ./systclient.c
syst_cgen.pl: Add ./systclient.c with file id 2 to file catalog
syst_cgen.pl: Parsing finished: ./systclient.c, found 4 call(s)
syst_cgen.pl: Generating XML structure
syst_cgen.pl: Loaded template collateral file template.xml
syst_cgen.pl: Generating XML structure finished
syst_cgen.pl: Writing XML file: generated_catalog.xml
syst_cgen.pl: Writing XML file finished
```
Catalog Generator Configuration Example {#mipi_syst_catgen_example_config}
------------------------------------------------------------------------------
The following XML file shows the example configuration file from the client
example. The file lists the SyS-T catalog instrumentation call patterns and
can be reused for other clients. Only the options at the beginning may require
adaptations.
```{.xml}
```
Catalog Generator Template File {#mipi_syst_catgen_example_template}
------------------------------------------------------------------------------
The following XML file shows the template collateral file that is updated by
the generator tool with the source code information. Note the empty XML
elements called ````, ````, and
````. The generator replaces these empty elements with the
collected information. The remaining contents are kept unchanged.
```{.xml}
displayAsField
%x]]>
```