Changeset b2e1123 in rtems-libbsd


Ignore:
Timestamp:
Aug 28, 2018, 12:14:27 PM (8 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
647dd08ae2aa69b935c2847ea450fb824322ecae, c6261f97870562d4c797cfb1ff1ba0affb85a916
Children:
b6c64e1
Parents:
43a39b7
git-author:
Sebastian Huber <sebastian.huber@…> (08/28/18 12:14:27)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/28/18 12:35:10)
Message:

userspace-header-gen.py: Sort file content

Sort the file content to make it less dependent on compiler code
generation variances.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • userspace-header-gen.py

    r43a39b7 rb2e1123  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22# -*- coding: utf-8 -*-
    33
     
    276276        return is_constant
    277277
     278    def _write_list_to_file(self, l, f):
     279        if l:
     280            l.sort()
     281            f.write('\n'.join(l) + '\n')
     282
    278283    def _process_die(self, die, data_out, glob_data_out, namesp_out):
     284        data_out_items = []
     285        glob_data_out_items = []
     286        namesp_out_items = []
     287
    279288        for child in die.iter_children():
    280289            specdie = child
     
    394403                if not is_extern:
    395404                    var_with_type = "static " + var_with_type
    396                     outfile = data_out
     405                    out_items = data_out_items
    397406                else:
    398407                    self._err.write('WARNING: variable is not static: "%s" at %s\n' % \
    399408                                    (var_with_type, var_decl))
    400409                    var_with_type = "extern " + var_with_type
    401                     outfile = glob_data_out
     410                    out_items = glob_data_out_items
    402411
    403412                for flt in self._filter_special_vars:
     
    406415                            self._err.write('Don\'t put "%s" into section. Reason: %s.\n' % \
    407416                                            (var_with_type, flt["reason"]))
    408                             outfile = None
     417                            out_items = None
    409418                        if flt["action"] == "ignore_extern":
    410419                            self._err.write('Ignore extern of variable "%s". Reason: %s.\n' % \
    411420                                            (var_with_type, flt["reason"]))
    412                             outfile = data_out
     421                            out_items = data_out_items
    413422
    414423            # write output
     
    420429                    self._err.write('Found a function "%s" at %s (DIE offset %s); extern: %r\n' % \
    421430                                    (varname, var_decl, child.offset, is_extern))
    422             if (not is_function) and (outfile is not None):
    423                 outfile.write("RTEMS_LINKER_RWSET_CONTENT(bsd_prog_%s, %s);\n" % \
     431            if (not is_function) and (out_items is not None):
     432                out_items.append("RTEMS_LINKER_RWSET_CONTENT(bsd_prog_%s, %s);" % \
    424433                        (self._progname, var_with_type))
    425434            if is_extern:
    426                 namesp_out.write("#define %s %s%s\n" % \
     435                namesp_out_items.append("#define %s %s%s" % \
    427436                                 (varname, self._namespace_prefix, varname))
     437
     438        self._write_list_to_file(data_out_items, data_out)
     439        self._write_list_to_file(glob_data_out_items, glob_data_out)
     440        self._write_list_to_file(namesp_out_items, namesp_out)
    428441
    429442
Note: See TracChangeset for help on using the changeset viewer.