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