diff options
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/codestats.sh | 6 | ||||
| -rw-r--r-- | tools/gen-cpydiff.py | 6 | ||||
| -rwxr-xr-x | tools/mpy-tool.py | 51 | ||||
| -rwxr-xr-x | tools/mpy_bin2res.py | 18 | ||||
| -rwxr-xr-x | tools/pyboard.py | 24 |
5 files changed, 77 insertions, 28 deletions
diff --git a/tools/codestats.sh b/tools/codestats.sh index c868199e1..5272f3e9c 100755 --- a/tools/codestats.sh +++ b/tools/codestats.sh @@ -28,9 +28,9 @@ bin_stmhal=stmhal/build-PYBV10/firmware.elf bin_barearm_1=bare-arm/build/flash.elf bin_barearm_2=bare-arm/build/firmware.elf bin_minimal=minimal/build/firmware.elf -bin_cc3200_1=cc3200/build/LAUNCHXL/application.axf -bin_cc3200_2=cc3200/build/LAUNCHXL/release/application.axf -bin_cc3200_3=cc3200/build/WIPY/release/application.axf +bin_cc3200_1=cc3200/build/LAUNCHXL/application.axf +bin_cc3200_2=cc3200/build/LAUNCHXL/release/application.axf +bin_cc3200_3=cc3200/build/WIPY/release/application.axf # start at zero size; if build fails reuse previous valid size size_unix="0" diff --git a/tools/gen-cpydiff.py b/tools/gen-cpydiff.py index 4b273d97f..aff5b56e7 100644 --- a/tools/gen-cpydiff.py +++ b/tools/gen-cpydiff.py @@ -33,7 +33,7 @@ import time import re from collections import namedtuple -# Micropython supports syntax of CPython 3.4 with some features from 3.5, and +# MicroPython supports syntax of CPython 3.4 with some features from 3.5, and # such version should be used to test for differences. If your default python3 # executable is of lower version, you can point MICROPY_CPYTHON3 environment var # to the correct executable. @@ -185,7 +185,9 @@ def gen_rst(results): rst.write(RSTCHARS[min(i, len(RSTCHARS)-1)] * len(section[i])) rst.write('\n\n') class_ = section - rst.write('**' + output.desc + '**\n\n') + rst.write('.. _cpydiff_%s:\n\n' % output.name.rsplit('.', 1)[0]) + rst.write(output.desc + '\n') + rst.write('~' * len(output.desc) + '\n\n') if output.cause != 'Unknown': rst.write('**Cause:** ' + output.cause + '\n\n') if output.workaround != 'Unknown': diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 544f90cc8..ded962487 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -239,7 +239,7 @@ class RawCode: def dump(self): # dump children first for rc in self.raw_codes: - rc.freeze() + rc.freeze('') # TODO def freeze(self, parent_name): @@ -331,27 +331,29 @@ class RawCode: # TODO raise FreezeError(self, 'freezing of object %r is not implemented' % (obj,)) - # generate constant table - print('STATIC const mp_rom_obj_t const_table_data_%s[%u] = {' - % (self.escaped_name, len(self.qstrs) + len(self.objs) + len(self.raw_codes))) - for qst in self.qstrs: - print(' MP_ROM_QSTR(%s),' % global_qstrs[qst].qstr_id) - for i in range(len(self.objs)): - if type(self.objs[i]) is float: - print('#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B') - print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i)) - print('#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C') - n = struct.unpack('<I', struct.pack('<f', self.objs[i]))[0] - n = ((n & ~0x3) | 2) + 0x80800000 - print(' (mp_rom_obj_t)(0x%08x),' % (n,)) - print('#else') - print('#error "MICROPY_OBJ_REPR_D not supported with floats in frozen mpy files"') - print('#endif') - else: - print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i)) - for rc in self.raw_codes: - print(' MP_ROM_PTR(&raw_code_%s),' % rc.escaped_name) - print('};') + # generate constant table, if it has any entries + const_table_len = len(self.qstrs) + len(self.objs) + len(self.raw_codes) + if const_table_len: + print('STATIC const mp_rom_obj_t const_table_data_%s[%u] = {' + % (self.escaped_name, const_table_len)) + for qst in self.qstrs: + print(' MP_ROM_QSTR(%s),' % global_qstrs[qst].qstr_id) + for i in range(len(self.objs)): + if type(self.objs[i]) is float: + print('#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B') + print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i)) + print('#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C') + n = struct.unpack('<I', struct.pack('<f', self.objs[i]))[0] + n = ((n & ~0x3) | 2) + 0x80800000 + print(' (mp_rom_obj_t)(0x%08x),' % (n,)) + print('#else') + print('#error "MICROPY_OBJ_REPR_D not supported with floats in frozen mpy files"') + print('#endif') + else: + print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i)) + for rc in self.raw_codes: + print(' MP_ROM_PTR(&raw_code_%s),' % rc.escaped_name) + print('};') # generate module if self.simple_name.str != '<module>': @@ -362,7 +364,10 @@ class RawCode: print(' .n_pos_args = %u,' % self.prelude[3]) print(' .data.u_byte = {') print(' .bytecode = bytecode_data_%s,' % self.escaped_name) - print(' .const_table = (mp_uint_t*)const_table_data_%s,' % self.escaped_name) + if const_table_len: + print(' .const_table = (mp_uint_t*)const_table_data_%s,' % self.escaped_name) + else: + print(' .const_table = NULL,') print(' #if MICROPY_PERSISTENT_CODE_SAVE') print(' .bc_len = %u,' % len(self.bytecode)) print(' .n_obj = %u,' % len(self.objs)) diff --git a/tools/mpy_bin2res.py b/tools/mpy_bin2res.py new file mode 100755 index 000000000..0c89e7e92 --- /dev/null +++ b/tools/mpy_bin2res.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# +# This tool converts binary resource files passed on the command line +# into a Python source file containing data from these files, which can +# be accessed using standard pkg_resources.resource_stream() function +# from micropython-lib: +# https://github.com/micropython/micropython-lib/tree/master/pkg_resources +# +import sys + +print("R = {") + +for fname in sys.argv[1:]: + with open(fname, "rb") as f: + b = f.read() + print("%r: %r," % (fname, b)) + +print("}") diff --git a/tools/pyboard.py b/tools/pyboard.py index 921ffc52d..d15f520ac 100755 --- a/tools/pyboard.py +++ b/tools/pyboard.py @@ -1,4 +1,28 @@ #!/usr/bin/env python +# +# This file is part of the MicroPython project, http://micropython.org/ +# +# The MIT License (MIT) +# +# Copyright (c) 2014-2016 Damien P. George +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. """ pyboard interface |
