From a8731bda3155750398e4b1b031523d5692702a40 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 27 Aug 2020 13:37:30 -0400 Subject: [PATCH] Add `common.j2` template This file can contain common variables and macros. It is to be imported by other templates, for example by `bitfield.h.j2` in this patch. Signed-off-by: Philippe Proulx --- barectf/templates/bitfield.h.j2 | 5 +++-- barectf/templates/common.j2 | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 barectf/templates/common.j2 diff --git a/barectf/templates/bitfield.h.j2 b/barectf/templates/bitfield.h.j2 index 8cb46ba..51ea797 100644 --- a/barectf/templates/bitfield.h.j2 +++ b/barectf/templates/bitfield.h.j2 @@ -1,5 +1,6 @@ -{% set prefix = cfg.options.code_generation_options.identifier_prefix %} -{% set ucprefix = prefix | upper %} +{% import 'common.j2' as common %} +{% set prefix = common.prefix %} +{% set ucprefix = common.ucprefix %} #ifndef _{{ ucprefix }}BITFIELD_H #define _{{ ucprefix }}BITFIELD_H diff --git a/barectf/templates/common.j2 b/barectf/templates/common.j2 new file mode 100644 index 0000000..c346ffa --- /dev/null +++ b/barectf/templates/common.j2 @@ -0,0 +1,7 @@ +{# + # Common variables and macros. + #} + +{# identifier prefix and its uppercase equivalent #} +{% set prefix = cfg.options.code_generation_options.identifier_prefix %} +{% set ucprefix = prefix | upper %} -- 2.34.1