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