summaryrefslogtreecommitdiffstats
path: root/userspace-header-gen.py
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-28 14:14:27 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-28 14:35:10 +0200
commitb2e1123733db8fd1a83a893e980a9fe4da357bb6 (patch)
tree6e12112ac09568f21956793532bae9ee8a45ca83 /userspace-header-gen.py
parent43a39b7a5dff5f35131b8ca36e6755588adef9e0 (diff)
downloadrtems-libbsd-b2e1123733db8fd1a83a893e980a9fe4da357bb6.tar.bz2
userspace-header-gen.py: Sort file content
Sort the file content to make it less dependent on compiler code generation variances.
Diffstat (limited to 'userspace-header-gen.py')
-rwxr-xr-xuserspace-header-gen.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/userspace-header-gen.py b/userspace-header-gen.py
index f41feb4a..8c7ef76a 100755
--- a/userspace-header-gen.py
+++ b/userspace-header-gen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2016 embedded brains GmbH. All rights reserved.
@@ -275,7 +275,16 @@ class HeaderGenCU:
is_constant = True
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):
+ data_out_items = []
+ glob_data_out_items = []
+ namesp_out_items = []
+
for child in die.iter_children():
specdie = child
# get the name of the DIE
@@ -393,23 +402,23 @@ class HeaderGenCU:
# check if it is a static or a extern
if not is_extern:
var_with_type = "static " + var_with_type
- outfile = data_out
+ out_items = data_out_items
else:
self._err.write('WARNING: variable is not static: "%s" at %s\n' % \
(var_with_type, var_decl))
var_with_type = "extern " + var_with_type
- outfile = glob_data_out
+ out_items = glob_data_out_items
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
+ out_items = 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
+ out_items = data_out_items
# write output
if self._verbose >= VERBOSE_SOME:
@@ -419,13 +428,17 @@ 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) and (outfile is not None):
- outfile.write("RTEMS_LINKER_RWSET_CONTENT(bsd_prog_%s, %s);\n" % \
+ if (not is_function) and (out_items is not None):
+ out_items.append("RTEMS_LINKER_RWSET_CONTENT(bsd_prog_%s, %s);" % \
(self._progname, var_with_type))
if is_extern:
- namesp_out.write("#define %s %s%s\n" % \
+ namesp_out_items.append("#define %s %s%s" % \
(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:
def __init__(self, objfiles, progname, err = sys.stderr, verbose = 0,