Jinja 2 templates: stylize block comments like C block comments
[deliverable/barectf.git] / barectf / templates / metadata.j2
CommitLineData
de49021e
PP
1/* CTF 1.8 */
2
3/*
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2015-2020 Philippe Proulx <pproulx@efficios.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
27 *
28 * The following TSDL code was generated by barectf v{{ barectf_version.__version__ }}
29 * on {{ cfg.trace.environment['barectf_gen_date'] }}.
30 *
31 * For more details, see <https://barectf.org/>.
32 */
33{#
8f0d81a0
PP
34 # Generates a root field type string named `name` for the field type
35 # `rft` with all the lines except the first one indented with a single
36 # tab.
37 #}
de49021e
PP
38{% macro root_ft(name, rft) -%}
39{{ name }} := {{ rft | ft_str | indent_tab }};
40{%- endmacro %}
41
42trace {
43 major = 1;
44 minor = 8;
45 byte_order = {{ cfg.trace.type.default_byte_order | bo_str }};
46 {% if cfg.trace.type.uuid %}
47 uuid = "{{ cfg.trace.type.uuid }}";
48 {% endif %}
49 {% if cfg.trace.type._pkt_header_ft %}
50 {{ root_ft('packet.header', cfg.trace.type._pkt_header_ft) }}
51 {% endif %}
52};
53
54env {
55{% for name, value in cfg.trace.environment.items() %}
56 {{ name }} = {{ value if value is number else '"{}"'.format(value | escape_dq) }};
57{% endfor %}
58};
59
60{# all clock types (stream types's default clock types) #}
61{% for clk_type in cfg.trace.type.clock_types | sort %}
62clock {
63 name = {{ clk_type.name }};
64 {% if clk_type.description %}
65 description = "{{ clk_type.description | escape_dq }}";
66 {% endif %}
67 {% if clk_type.uuid %}
68 uuid = "{{ clk_type.uuid }}";
69 {% endif %}
70 freq = {{ clk_type.frequency }};
71 precision = {{ clk_type.precision }};
72 offset_s = {{ clk_type.offset.seconds }};
73 offset = {{ clk_type.offset.cycles }};
74 absolute = {{ 'true' if clk_type.origin_is_unix_epoch else 'false' }};
75};
76
77{% endfor %}
78{# stream types and their event types #}
79{%- for stream_type in cfg.trace.type.stream_types | sort %}
80/* Stream type `{{ stream_type.name }}` */
81stream {
82 id = {{ stream_type.id }};
83 {{ root_ft('packet.context', stream_type._pkt_ctx_ft) }}
84 {% if stream_type._ev_header_ft %}
85 {{ root_ft('event.header', stream_type._ev_header_ft) }}
86 {% endif %}
87 {% if stream_type.event_common_context_field_type %}
88 {{ root_ft('event.context', stream_type.event_common_context_field_type) }}
89 {% endif %}
90};
91
92{# stream type's event types #}
93{% for ev_type in stream_type.event_types | sort %}
94event {
95 id = {{ ev_type.id }};
96 stream_id = {{ stream_type.id }};
97 name = "{{ ev_type.name }}";
98 {% if ev_type.log_level %}
99 loglevel = {{ ev_type.log_level }};
100 {% endif %}
101 {% if ev_type.specific_context_field_type %}
102 {{ root_ft('context', ev_type.specific_context_field_type) }}
103 {% endif %}
104 {% if ev_type.payload_field_type %}
105 {{ root_ft('fields', ev_type.payload_field_type) }}
106 {% endif %}
107};
108
109{% endfor %}
110{% endfor %}
This page took 0.026698 seconds and 4 git commands to generate.