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