Changeset a35b458 in mainline for tools/mkarray.py


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/mkarray.py

    r3061bc1 ra35b458  
    5757def main():
    5858        arg_check()
    59        
     59
    6060        if sys.argv[1] == "--deflate":
    6161                sys.argv.pop(1)
     
    6464        else:
    6565                compress = False
    66        
     66
    6767        dest = sys.argv[1]
    6868        label = sys.argv[2]
    6969        as_prolog = sys.argv[3]
    7070        section = sys.argv[4]
    71        
     71
    7272        timestamp = (1980, 1, 1, 0, 0, 0)
    73        
     73
    7474        header_ctx = []
    7575        desc_ctx = []
    7676        size_ctx = []
    7777        data_ctx = []
    78        
     78
    7979        src_cnt = 0
    80        
     80
    8181        archive = zipfile.ZipFile("%s.zip" % dest, "w", zipfile.ZIP_STORED)
    82        
     82
    8383        for src in sys.argv[5:]:
    8484                basename = os.path.basename(src)
    8585                plainname = os.path.splitext(basename)[0]
    8686                symbol = basename.replace(".", "_")
    87                
     87
    8888                print("%s -> %s" % (src, symbol))
    89                
     89
    9090                src_in = open(src, "rb")
    9191                src_data = src_in.read()
    9292                src_in.close()
    93                
     93
    9494                length = len(src_data)
    95                
     95
    9696                if compress:
    9797                        src_data = deflate(src_data)
     
    101101                else:
    102102                        src_fname = src
    103                
     103
    104104                if sys.version_info < (3,):
    105105                        src_data = bytearray(src_data)
    106                
     106
    107107                length_out = len(src_data)
    108                
     108
    109109                header_ctx.append("extern uint8_t %s[];" % symbol)
    110110                header_ctx.append("extern size_t %s_size;" % symbol)
    111                
     111
    112112                data_ctx.append(".globl %s" % symbol)
    113113                data_ctx.append(".balign 8")
     
    115115                data_ctx.append("%s:" % symbol)
    116116                data_ctx.append("\t.incbin \"%s\"\n" % src_fname)
    117                
     117
    118118                desc_field = []
    119119                desc_field.append("\t{")
     
    122122                desc_field.append("\t\t.size = %u," % length_out)
    123123                desc_field.append("\t\t.inflated = %u," % length)
    124                
     124
    125125                if compress:
    126126                        desc_field.append("\t\t.compressed = true")
    127127                else:
    128128                        desc_field.append("\t\t.compressed = false")
    129                
     129
    130130                desc_field.append("\t}")
    131                
     131
    132132                desc_ctx.append("\n".join(desc_field))
    133                
     133
    134134                size_ctx.append("size_t %s_size = %u;" % (symbol, length_out))
    135                
     135
    136136                src_cnt += 1
    137        
     137
    138138        data = ''
    139139        data += '/***************************************\n'
     
    160160        zipinfo = zipfile.ZipInfo("%s.h" % dest, timestamp)
    161161        archive.writestr(zipinfo, data)
    162        
     162
    163163        data = ''
    164164        data += '/***************************************\n'
     
    172172        zipinfo = zipfile.ZipInfo("%s.s" % dest, timestamp)
    173173        archive.writestr(zipinfo, data)
    174        
     174
    175175        data = ''
    176176        data += '/***************************************\n'
     
    187187        zipinfo = zipfile.ZipInfo("%s_desc.c" % dest, timestamp)
    188188        archive.writestr(zipinfo, data)
    189        
     189
    190190        archive.close()
    191191
Note: See TracChangeset for help on using the changeset viewer.