summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2020-08-31 13:54:47 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-09-01 15:10:09 +0000
commit6006ca85714fd2829f3e20429683f18d70943c04 (patch)
treedecbc2c28588e5028cbf1667e807315dbd333f6f /src/tools
parent61f49aa38e02d2f78e7033b5c97e6a90ebdecd0f (diff)
vppapigen: supports backwards compatible marking of enums
enum bar_enum { BAR1 = 0, BAR2, BAR3 [backwards_compatible], BAR4 = 9 [backwards_compatible], }; This allows adding backwards compatible (as guaranteed by the developer) enums. The enums marked backwards compatible are not considered in the CRC calculation. Type: improvement Change-Id: I6fc0c21b19e1a02cff7f5d279a0f3a32d2f8b630 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/tools')
-rwxr-xr-xsrc/tools/vppapigen/vppapigen.py56
1 files changed, 38 insertions, 18 deletions
diff --git a/src/tools/vppapigen/vppapigen.py b/src/tools/vppapigen/vppapigen.py
index 3626ff8b05c..9d74a5b0357 100755
--- a/src/tools/vppapigen/vppapigen.py
+++ b/src/tools/vppapigen/vppapigen.py
@@ -142,11 +142,6 @@ class VPPAPILexer(object):
t_ignore = ' \t'
-def crc_block_combine(block, crc):
- s = str(block).encode()
- return binascii.crc32(s, crc) & 0xffffffff
-
-
def vla_is_last_check(name, block):
vla = False
for i, b in enumerate(block):
@@ -227,7 +222,12 @@ class Using():
else:
a = {'type': alias.fieldtype}
self.alias = a
- self.crc = str(alias).encode()
+ #
+ # Should have been:
+ # self.crc = str(alias).encode()
+ # but to be backwards compatible use the block ([])
+ #
+ self.crc = str(self.block).encode()
global_type_add(name, self)
def __repr__(self):
@@ -303,15 +303,27 @@ class Enum():
self.vla = False
count = 0
- for i, b in enumerate(block):
- if type(b) is list:
- count = b[1]
+ block2 = []
+ block3 = []
+ bc_set = False
+
+ for b in block:
+ if 'value' in b:
+ count = b['value']
else:
count += 1
- block[i] = [b, count]
-
- self.block = block
- self.crc = str(block).encode()
+ block2.append([b['id'], count])
+ try:
+ if b['option']['backwards_compatible']:
+ pass
+ bc_set = True
+ except KeyError:
+ block3.append([b['id'], count])
+ if bc_set:
+ raise ValueError("Backward compatible enum must be last {!r} {!r}"
+ .format(name, b['id']))
+ self.block = block2
+ self.crc = str(block3).encode()
global_type_add(name, self)
def __repr__(self):
@@ -621,11 +633,19 @@ class VPPAPIParser(object):
def p_enum_statement(self, p):
'''enum_statement : ID '=' NUM ','
- | ID ',' '''
- if len(p) == 5:
- p[0] = [p[1], p[3]]
+ | ID ','
+ | ID '[' field_options ']' ','
+ | ID '=' NUM '[' field_options ']' ',' '''
+ if len(p) == 3:
+ p[0] = {'id': p[1]}
+ elif len(p) == 5:
+ p[0] = {'id': p[1], 'value': p[3]}
+ elif len(p) == 6:
+ p[0] = {'id': p[1], 'option': p[3]}
+ elif len(p) == 8:
+ p[0] = {'id': p[1], 'value': p[3], 'option': p[5]}
else:
- p[0] = p[1]
+ self._parse_error('ERROR', self._token_coord(p, 1))
def p_field_options(self, p):
'''field_options : field_option
@@ -934,7 +954,7 @@ def foldup_blocks(block, crc):
# Recursively
t = global_types[b.fieldtype]
try:
- crc = crc_block_combine(t.block, crc)
+ crc = binascii.crc32(t.crc, crc) & 0xffffffff
crc = foldup_blocks(t.block, crc)
except AttributeError:
pass
#ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
---
# file: roles/trex/tasks/main.yaml

- name: Inst - Update Package Cache (APT)
  apt:
    update_cache: yes
    cache_valid_time: 3600
  when:
    - ansible_distribution|lower == 'ubuntu'
  tags:
    - trex-inst-prerequisites

- name: Inst - Prerequisites
  package:
    name: "{{ packages | flatten(levels=1) }}"
    state: latest
  tags:
    - trex-inst-prerequisites

- name: Inst - Multiple T-Rex Versions
  include_tasks: deploy_block.yaml
  loop: "{{ trex_version }}"
  tags:
    - trex-inst