aboutsummaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)Author
2020-06-14tools/uncrustify: Update config for v0.71.0.David Lechner
This is the result of running... uncrustify -c tools/uncrustify.cfg --update-config-with-doc -o tools/uncrustify.cfg ...with some manual fixups to correct places where it changed things it should not have. Essentially it just adds new config parameters introduced in v0.71.0 with their default values. Signed-off-by: David Lechner <david@pybricks.com>
2020-06-14tools/codeformat.py: Remove sizeof fixup.David Lechner
Formatting for `* sizeof` was fixed in uncrustify v0.71, so we no longer need the fixups for it. Also, there was one file where the updated uncrustify caught a problem that the regex didn't pick up, which is updated in this commit. Signed-off-by: David Lechner <david@pybricks.com>
2020-06-14tools/uncrustify.cfg: Remove deprecated sp_word_brace option.David Lechner
This option was removed in uncrustify v0.71. Signed-off-by: David Lechner <david@pybricks.com>
2020-05-29tools/codeformat.py: Add verbose option to pass to uncrustify and black.David Lechner
This adds a new command line option `-v` to `tools/codeformat.py` to enable verbose printing of all files that are scanned. Normally `uncrustify` and `black` are called with the `-q` option so setting verbose suppresses the `-q` option and on `black` also enables the `-v` option which makes it print out all file names matching the filter similar to how `uncrustify` does by default.
2020-05-28tools/codeformat.py: Use -q option on uncrustify to make output quiet.David Lechner
This suppresses the Parsing: <file> as language C lines. This makes parsing run a bit faster and on CI it makes for less scrolling through logs (and black already uses the -q option).
2020-04-23all: Format code to add space after C++-style comment start.stijn
Note: the uncrustify configuration is explicitly set to 'add' instead of 'force' in order not to alter the comments which use extra spaces after // as a means of indenting text for clarity.
2020-04-22tools/check_code_size.sh: Remove unused script.Damien George
It's now replaced by tools/metrics.py.
2020-04-22tools/metrics.py: Use OrderedDict when reading build log.Damien George
So that the output (eg of the diff command) always has the lines in the same order.
2020-04-22tools/metrics.py: Don't build mpy-cross if not needed by any ports.Damien George
To save build time.
2020-04-22tools/metrics.py: Add option to diff to error if delta above threshold.Damien George
Useful for things like CI where the size check is automated.
2020-04-18all: Fix implicit conversion from double to float.stijn
These are found when building with -Wfloat-conversion.
2020-04-05py/objexcept: Allow compression of exception message text.Jim Mussared
The decompression of error-strings is only done if the string is accessed via printing or via er.args. Tests are added for this feature to ensure the decompression works.
2020-03-30tests: Format all Python code with black, except tests in basics subdir.David Lechner
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
2020-03-30tools/pyboard.py: Add -d as an alias for --device.Lars Kellogg-Stedman
2020-03-30tools/pyboard.py: Support setting device/baudrate from shell env vars.Lars Kellogg-Stedman
Allow defaults for --device and --baudrate to be set in the environment using PYBOARD_DEVICE and PYBOARD_BAUDRATE.
2020-03-28all: Remove spaces inside and around parenthesis.Damien George
Using new options enabled in the uncrustify configuration.
2020-03-25all: Remove spaces between nested paren and inside function arg paren.Damien George
Using new options enabled in the uncrustify configuration.
2020-03-25tools/codeformat.py: Include all msvc C code in auto-format.stijn
2020-03-22tools/pydfu.py: Display any error strings from device/mboot.Andrew Leech
2020-03-22tools/pydfu.py: Add args for VID/PID & exit with cleaner error handling.Andrew Leech
2020-03-11tools/codeformat.py: Eliminate need for sizeof fixup.David Lechner
This eliminates the need for the sizeof regex fixup by rearranging things a bit. All other bitfields already use the parentheses around expressions with sizeof, so one case is fixed by following this convention. VM_MAX_STATE_ON_STACK is the only remaining problem and it can be worked around by changing the order of the operands.
2020-03-11tools/metrics.py: Use check_call instead of run to error out on error.Damien George
2020-03-05tools/makemanifest.py: Fix build on Windows by adding .exe to mpy-cross.MikeTeachman
When using a manifest on Windows the reference to mpy-cross compiler was missing the .exe file extension, so add it when appropriate. Also allow the default path to mpy-cross to be overridden by the (optional) MICROPY_MPYCROSS environment variable, to allow full flexibility on any OS.
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28tools/codeformat.py: Add formatter using uncrustify for C, black for Py.Damien George
This commit adds a tool, codeformat.py, which will reformat C and Python code to fit a certain style. By default the tool will reformat (almost) all the original (ie not 3rd-party) .c, .h and .py files in this repository. Passing filenames on the command-line to codeformat.py will reformat only those. Reformatting is done in-place. uncrustify is used for C reformatting, which is available for many platforms and can be easily built from source, see https://github.com/uncrustify/uncrustify. The configuration for uncrustify is also added in this commit and values are chosen to best match the existing code style. A small post-processing stage on .c and .h files is done by codeformat.py (after running uncrustify) to fix up some minor items: - space inserted after * when used as multiplication with sizeof - #if/ifdef/ifndef/elif/else/endif are dedented by one level when they are configuring if-blocks and case-blocks. For Python code, the formatter used is black, which can be pip-installed; see https://github.com/psf/black. The defaults are used, except for line- length which is set at 99 characters to match the "about 100" line-length limit used in C code. The formatting tools used and their configuration were chosen to strike a balance between keeping existing style and not changing too many lines of code, and enforcing a relatively strict style (especially for Python code). This should help to keep the code consistent across everything, and reduce cognitive load when writing new code to match the style.
2020-02-20tools/makemanifest.py: Support freezing with empty list of mpy files.Damien George
Fixes issue #5655.
2020-02-01tools/pyboard.py: Change shebang to use python3.Michael Buesch
This script still works with Python 2 but Python 3 is recommended.
2020-02-01tools/pyboard.py: Use slice del instead of list.clear() for Py2 compat.Michael Buesch
Python 2 does not have list.clear().
2020-02-01tools/pyboard.py: Add option --no-follow to detach after sending script.Michael Buesch
This option makes pyboard.py exit as soon as the script/command is successfully sent to the device, ie it does not wait for any output. This can help to avoid hangs if the board is being rebooted with --comman (for example). Example usage: $ python3 ./tools/pyboard.py --device /dev/ttyUSB0 --no-follow \ --command 'import machine; machine.reset()'
2020-01-23tools/pydfu.py: Clean up syntax, update comments and docstrings.c0rejump
Some parts of code have been aligned to increase readability. In general '' instead of "" were used wherever possible to keep the same convention for entire file. Import inspect line has been moved to the top according to hints reported by pep8 tools. A few extra spaces were removed, a few missing spaces were added. Comments have been updated, mostly in "read_dfu_file" function. Some other comments have been capitalized and/or slightly updated. A few docstrings were fixed as well. No real code changes intended.
2020-01-23tools: Add metrics.py script to build and compute port sizes/metrics.Damien George
2020-01-06tools/gen-cpydiff.py: Adjust subsections to sentence case.Jason Neal
2019-12-19tools/tinytest-codegen.py: Add extra newline and result message.David Lechner
This is an alternative to f4ed2df that adds a newline so that the output of the test starts on a new line and the result of the test is prefixed with "result: " to distinguish it from the test output. Suggested-by: @dpgeorge
2019-12-19tools/pyboard.py: Support executing .mpy files directly.Damien George
This patch allows executing .mpy files (including native ones) directly on a target, eg a board over a serial connection. So there's no need to copy the file to its filesystem to test it. For example: $ mpy-cross foo.py $ pyboard.py foo.mpy
2019-12-17py/persistentcode: Move loading of rodata/bss to before obj/raw-code.Damien George
This makes the loading of viper-code-with-relocations a bit neater and easier to understand, by treating the rodata/bss like a special object to be loaded into the constant table (which is how it behaves).
2019-12-12tools/mpy-tool.py: Raise exception if trying to freeze relocatable mpy.Damien George
2019-12-12py/dynruntime: Add support for float API to make/get floats.Damien George
We don't want to add a feature flag to .mpy files that indicate float support because it will get complex and difficult to use. Instead the .mpy is built using whatever precision it chooses (float or double) and the native glue API will convert between this choice and what the host runtime actually uses.
2019-12-12tools/mpy_ld.py: Add new mpy_ld.py tool and associated build files.Damien George
This commit adds a new tool called mpy_ld.py which is essentially a linker that builds .mpy files directly from .o files. A new header file (dynruntime.h) and makefile fragment (dynruntime.mk) are also included which allow building .mpy files from C source code. Such .mpy files can then be dynamically imported as though they were a normal Python module, even though they are implemented in C. Converting .o files directly (rather than pre-linked .elf files) allows the resulting .mpy to be more efficient because it has more control over the relocations; for example it can skip PLT indirection. Doing it this way also allows supporting more architectures, such as Xtensa which has specific needs for position-independent code and the GOT. The tool supports targets of x86, x86-64, ARM Thumb and Xtensa (windowed and non-windowed). BSS, text and rodata sections are supported, with relocations to all internal sections and symbols, as well as relocations to some external symbols (defined by dynruntime.h), and linking of qstrs.
2019-12-12tools/mpy-tool.py: Add ability to merge multiple .mpy files into one.Damien George
Usage: mpy-tool.py -o merged.mpy --merge mod1.mpy mod2.mpy The constituent .mpy files are executed sequentially when the merged file is imported, and they all use the same global namespace.
2019-12-12py/nativeglue: Add new header file with native function table typedef.Damien George
2019-11-28tools/mpy-tool.py: Support qstr linking when freezing Xtensa native mpy.Damien George
2019-11-13tools/makemanifest.py: Use sys.executable when invoking Python scripts.Yonatan Goldschmidt
So the version of Python used to run makemanifest.py is also used for the sub-scripts.
2019-11-07tools/makemanifest.py: Skip freezing unsupported files with warning.Andrew Leech
2019-11-06tools/makemanifest.py: Follow symlinks when freezing linked directories.Mirko Vogt
While the new manifest.py style got introduced for freezing python code into the resulting binary, the old way - where files and modules within ports/*/modules where baked into the resulting binary - was still supported via `freeze('$(PORT_DIR)/modules')` within manifest.py. However behaviour changed for symlinked directories (=modules), as those links weren't followed anymore. This commit restores the original behaviour by explicitly following symlinks within a modules/ directory
2019-11-04tools/mpy-tool.py: Use "@progbits #" attribute for native xtensa code.Damien George
2019-10-21tools/makemanifest.py: Eval relative paths w.r.t. current manifest file.Jim Mussared
When loading a manifest file, e.g. by include(), it will chdir first to the directory of that manifest. This means that all file operations within a manifest are relative to that manifest's location. As a consequence of this, additional environment variables are needed to find absolute paths, so the following are added: $(MPY_LIB_DIR), $(PORT_DIR), $(BOARD_DIR). And rename $(MPY) to $(MPY_DIR) to be consistent. Existing manifests are updated to match.
2019-10-15tools: Add mechanism to provide a manifest of frozen files.Damien George
This introduces a new build variable FROZEN_MANIFEST which can be set to a manifest listing (written in Python) that describes the set of files to be frozen in to the firmware.
2019-10-15tools/make-frozen.py: Allow to run with no directory passed in.Damien George
In which case it will just emit empty frozen C definitions.
2019-10-15py/persistentcode: Make .mpy more compact with qstr directly in prelude.Damien George
Instead of encoding 4 zero bytes as placeholders for the simple_name and source_file qstrs, and storing the qstrs after the bytecode, store the qstrs at the location of these 4 bytes. This saves 4 bytes per bytecode function stored in a .mpy file (for example lcd160cr.mpy drops by 232 bytes, 4x 58 functions). And resulting code size is slightly reduced on ports that use this feature.
2019-10-05py: Add new Xtensa-Windowed arch for native emitter.Damien George
Enabled via the configuration MICROPY_EMIT_XTENSAWIN.