diff options
author | Christian Mauderer <christian.mauderer@embedded-brains.de> | 2018-06-13 15:04:47 +0200 |
---|---|---|
committer | Christian Mauderer <christian.mauderer@embedded-brains.de> | 2018-08-01 09:55:27 +0200 |
commit | 879eaa7c1a62cb8043b63242e5d339f0ced50f29 (patch) | |
tree | 2ec6b1cfa2f91d90f57bef6d5303740c1964ba90 | |
parent | random: Implement read_random via getentropy. (diff) | |
download | rtems-libbsd-879eaa7c1a62cb8043b63242e5d339f0ced50f29.tar.bz2 |
userspace-header-gen: Special case for Yacc / Lex.
Some variables generated by Yacc / Lex need a special treatment. That
had been done by manual editing of the generated headers in the past.
This patch integrate these changes into the generator.
Diffstat (limited to '')
-rwxr-xr-x | userspace-header-gen.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/userspace-header-gen.py b/userspace-header-gen.py index cd50c1ef..f41feb4a 100755 --- a/userspace-header-gen.py +++ b/userspace-header-gen.py @@ -81,6 +81,25 @@ class HeaderGenCU: self._rtems_port_names.append("_Linker_set_bsd_prog_%s_end" % progname) self._rtems_port_names.append("rtems_bsd_command_%s" % progname) + self._filter_special_vars = [] + # Take some special care for some yacc variables. This matches the yyval + # and yylval. These two always make trouble in the generated headers. + # yyval is initialized by Yacc generated code so it's not + # necessary to move them into the copy back region. yylval is used only + # for transporting a value. It will be set when used. + self._filter_special_vars.append({ + "re":re.compile('extern YYSTYPE .*val'), + "reason":"Lex / Yacc variable initialized by generated code", + "action":"no_section" + }) + # Lex generates an external variable that shouldn't be extern. Move it + # to the current data header file. + self._filter_special_vars.append({ + "re":re.compile('extern yy_size_t .*len'), + "reason":"Lex adds an extern to this variable that is not necessary.", + "action":"ignore_extern" + }) + self._err = err self._verbose = verbose self._cu = cu @@ -381,6 +400,17 @@ class HeaderGenCU: var_with_type = "extern " + var_with_type outfile = glob_data_out + for flt in self._filter_special_vars: + if flt["re"].match(var_with_type) is not None: + if flt["action"] == "no_section": + self._err.write('Don\'t put "%s" into section. Reason: %s.\n' % \ + (var_with_type, flt["reason"])) + outfile = None + if flt["action"] == "ignore_extern": + self._err.write('Ignore extern of variable "%s". Reason: %s.\n' % \ + (var_with_type, flt["reason"])) + outfile = data_out + # write output if self._verbose >= VERBOSE_SOME: if not is_function: @@ -389,7 +419,7 @@ class HeaderGenCU: else: self._err.write('Found a function "%s" at %s (DIE offset %s); extern: %r\n' % \ (varname, var_decl, child.offset, is_extern)) - if not is_function: + if (not is_function) and (outfile is not None): outfile.write("RTEMS_LINKER_RWSET_CONTENT(bsd_prog_%s, %s);\n" % \ (self._progname, var_with_type)) if is_extern: |