From: Philippe Proulx Date: Thu, 27 Aug 2020 17:37:30 +0000 (-0400) Subject: Add `common.j2` template X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;ds=sidebyside;h=a8731bda3155750398e4b1b031523d5692702a40;p=deliverable%2Fbarectf.git 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 --- 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 %}