mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-23 10:11:05 +08:00
userspace-header-gen.py: Sort file content
Sort the file content to make it less dependent on compiler code generation variances.
This commit is contained in:
parent
43a39b7a5d
commit
b2e1123733
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2016 embedded brains GmbH. All rights reserved.
|
# Copyright (c) 2016 embedded brains GmbH. All rights reserved.
|
||||||
@ -275,7 +275,16 @@ class HeaderGenCU:
|
|||||||
is_constant = True
|
is_constant = True
|
||||||
return is_constant
|
return is_constant
|
||||||
|
|
||||||
|
def _write_list_to_file(self, l, f):
|
||||||
|
if l:
|
||||||
|
l.sort()
|
||||||
|
f.write('\n'.join(l) + '\n')
|
||||||
|
|
||||||
def _process_die(self, die, data_out, glob_data_out, namesp_out):
|
def _process_die(self, die, data_out, glob_data_out, namesp_out):
|
||||||
|
data_out_items = []
|
||||||
|
glob_data_out_items = []
|
||||||
|
namesp_out_items = []
|
||||||
|
|
||||||
for child in die.iter_children():
|
for child in die.iter_children():
|
||||||
specdie = child
|
specdie = child
|
||||||
# get the name of the DIE
|
# get the name of the DIE
|
||||||
@ -393,23 +402,23 @@ class HeaderGenCU:
|
|||||||
# check if it is a static or a extern
|
# check if it is a static or a extern
|
||||||
if not is_extern:
|
if not is_extern:
|
||||||
var_with_type = "static " + var_with_type
|
var_with_type = "static " + var_with_type
|
||||||
outfile = data_out
|
out_items = data_out_items
|
||||||
else:
|
else:
|
||||||
self._err.write('WARNING: variable is not static: "%s" at %s\n' % \
|
self._err.write('WARNING: variable is not static: "%s" at %s\n' % \
|
||||||
(var_with_type, var_decl))
|
(var_with_type, var_decl))
|
||||||
var_with_type = "extern " + var_with_type
|
var_with_type = "extern " + var_with_type
|
||||||
outfile = glob_data_out
|
out_items = glob_data_out_items
|
||||||
|
|
||||||
for flt in self._filter_special_vars:
|
for flt in self._filter_special_vars:
|
||||||
if flt["re"].match(var_with_type) is not None:
|
if flt["re"].match(var_with_type) is not None:
|
||||||
if flt["action"] == "no_section":
|
if flt["action"] == "no_section":
|
||||||
self._err.write('Don\'t put "%s" into section. Reason: %s.\n' % \
|
self._err.write('Don\'t put "%s" into section. Reason: %s.\n' % \
|
||||||
(var_with_type, flt["reason"]))
|
(var_with_type, flt["reason"]))
|
||||||
outfile = None
|
out_items = None
|
||||||
if flt["action"] == "ignore_extern":
|
if flt["action"] == "ignore_extern":
|
||||||
self._err.write('Ignore extern of variable "%s". Reason: %s.\n' % \
|
self._err.write('Ignore extern of variable "%s". Reason: %s.\n' % \
|
||||||
(var_with_type, flt["reason"]))
|
(var_with_type, flt["reason"]))
|
||||||
outfile = data_out
|
out_items = data_out_items
|
||||||
|
|
||||||
# write output
|
# write output
|
||||||
if self._verbose >= VERBOSE_SOME:
|
if self._verbose >= VERBOSE_SOME:
|
||||||
@ -419,13 +428,17 @@ class HeaderGenCU:
|
|||||||
else:
|
else:
|
||||||
self._err.write('Found a function "%s" at %s (DIE offset %s); extern: %r\n' % \
|
self._err.write('Found a function "%s" at %s (DIE offset %s); extern: %r\n' % \
|
||||||
(varname, var_decl, child.offset, is_extern))
|
(varname, var_decl, child.offset, is_extern))
|
||||||
if (not is_function) and (outfile is not None):
|
if (not is_function) and (out_items is not None):
|
||||||
outfile.write("RTEMS_LINKER_RWSET_CONTENT(bsd_prog_%s, %s);\n" % \
|
out_items.append("RTEMS_LINKER_RWSET_CONTENT(bsd_prog_%s, %s);" % \
|
||||||
(self._progname, var_with_type))
|
(self._progname, var_with_type))
|
||||||
if is_extern:
|
if is_extern:
|
||||||
namesp_out.write("#define %s %s%s\n" % \
|
namesp_out_items.append("#define %s %s%s" % \
|
||||||
(varname, self._namespace_prefix, varname))
|
(varname, self._namespace_prefix, varname))
|
||||||
|
|
||||||
|
self._write_list_to_file(data_out_items, data_out)
|
||||||
|
self._write_list_to_file(glob_data_out_items, glob_data_out)
|
||||||
|
self._write_list_to_file(namesp_out_items, namesp_out)
|
||||||
|
|
||||||
|
|
||||||
class UserspaceHeaderGen:
|
class UserspaceHeaderGen:
|
||||||
def __init__(self, objfiles, progname, err = sys.stderr, verbose = 0,
|
def __init__(self, objfiles, progname, err = sys.stderr, verbose = 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user