aboutsummaryrefslogtreecommitdiff
path: root/py/mkrules.mk
AgeCommit message (Collapse)Author
2020-12-14py/mkrules.mk: Remove stray vpath and unused -Itmp, add $(Q) for $(AR).Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-10-29py/makeqstrdefs.py: Support preprocessing C++ files for QSTR generation.stijn
When SCR_QSTR contains C++ files they should be preprocessed with the same compiler flags (CXXFLAGS) as they will be compiled with, to make sure code scanned for QSTR occurrences is effectively the code used in the rest of the build. The 'split SCR_QSTR in .c and .cpp files and process each with different flags' logic isn't trivial to express in a Makefile and the existing principle for deciding which files to preprocess was already rather complicated, so the actual preprocessing is moved into makeqstrdefs.py completely.
2020-10-29py/mkrules.mk: Add target for compiling C++ files.stijn
Move the target from the ESP32 Makefile since that does what is needed already, but also include files from user C modules as is done for the C files.
2020-04-14py: Always give noop defines when MICROPY_ROM_TEXT_COMPRESSION disabled.Damien George
This commit provides a typedef for mp_rom_error_text_t, and a macro define for MP_COMPRESSED_ROM_TEXT, when MICROPY_ROM_TEXT_COMPRESSION is disabled. This simplifies the configuration (it no longer has a special case for MICROPY_ENABLE_DYNRUNTIME) and makes it work for other cases that don't use compression (eg examples/embedding). This commit also ensures MICROPY_ROM_TEXT_COMPRESSION is defined during qstr processing.
2020-04-05py: Implement "common word" compression scheme for error messages.Jim Mussared
The idea here is that there's a moderate amount of ROM used up by exception text. Obviously we try to keep the messages short, and the code can enable terse errors, but it still adds up. Listed below is the total string data size for various ports: bare-arm 2860 minimal 2876 stm32 8926 (PYBV11) cc3200 3751 esp32 5721 This commit implements compression of these strings. It takes advantage of the fact that these strings are all 7-bit ascii and extracts the top 128 frequently used words from the messages and stores them packed (dropping their null-terminator), then uses (0x80 | index) inside strings to refer to these common words. Spaces are automatically added around words, saving more bytes. This happens transparently in the build process, mirroring the steps that are used to generate the QSTR data. The MP_COMPRESSED_ROM_TEXT macro wraps any literal string that should compressed, and it's automatically decompressed in mp_decompress_rom_string. There are many schemes that could be used for the compression, and some are included in py/makecompresseddata.py for reference (space, Huffman, ngram, common word). Results showed that the common-word compression gets better results. This is before counting the increased cost of the Huffman decoder. This might be slightly counter-intuitive, but this data is extremely repetitive at a word-level, and the byte-level entropy coder can't quite exploit that as efficiently. Ideally one would combine both approaches, but for now the common-word approach is the one that is used. For additional comparison, the size of the raw data compressed with gzip and zlib is calculated, as a sort of proxy for a lower entropy bound. With this scheme we come within 15% on stm32, and 30% on bare-arm (i.e. we use x% more bytes than the data compressed with gzip -- not counting the code overhead of a decoder, and how this would be hypothetically implemented). The feature is disabled by default and can be enabled by setting MICROPY_ROM_TEXT_COMPRESSION at the Makefile-level.
2019-10-21py/mkrules.mk: Add warning/error for invalid frozen config.Jim Mussared
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-15ports: Add new make target "submodules" which inits required modules.Damien George
2019-10-04docs/develop/qstr.rst: Add documentation for string interning.Jim Mussared
2019-09-12py/mkrules.mk: Add QSTR_GLOBAL_REQUIREMENTS variable for qstr auto-gen.Damien George
2019-06-25py/mkrules.mk: Use $(CPP) not $(CC) -E for preprocessor rule.Paul m. p. P
2019-06-03mpy-cross: Do not automatically build mpy-cross, rather do it manually.Damien George
Building mpy-cross automatically leads to some issues with the build process and slows it down. Instead, require it to be built manually.
2019-05-22py/mkrules.mk: Remove unnecessary ; in makefile.Sebastien Rinsoz
This ; make Windows compilation fail with GNU makefile 4.2.1. It was added in 0dc85c9f86735c35cf14555482b2c8923cf31a6a as part of a shell if- statement, but this if-statement was subsequently removed in 23a693ec2d8c2a194f61482dc0e1adb070fb6ad4 so the semicolon is not needed.
2019-05-22py: Update makefiles to use $(TOUCH) instead of hard coded "touch".Sebastien Rinsoz
The variable $(TOUCH) is initialized with the "touch" value in mkenv.mk like for the other command line tools (rm, echo, cp, mkdir etc). With this, for example, Windows users can specify the path of touch.exe.
2019-03-08py: Update and rework build system for including external C modules.Andrew Leech
How to use this feature is documented in docs/develop/cmodules.rst.
2019-03-08py: Implement a module system for external, user C modules.Ayke van Laethem
This system makes it a lot easier to include external libraries as static, native modules in MicroPython. Simply pass USER_C_MODULES (like FROZEN_MPY_DIR) as a make parameter.
2018-06-12py/mkrules.mk: Regenerate all qstrs when config files change.Damien George
A port can define QSTR_GLOBAL_DEPENDENCIES to add extra files.
2018-04-10py: Refactor how native emitter code is compiled with a file per arch.Damien George
Instead of emitnative.c having configuration code for each supported architecture, and then compiling this file multiple times with different macros defined, this patch adds a file per architecture with the necessary code to configure the native emitter. These files then #include the emitnative.c file. This simplifies emitnative.c (which is already very large), and simplifies the build system because emitnative.c no longer needs special handling for compilation and qstr extraction.
2018-02-22py: Use "GEN" consistently for describing files generated in the build.Damien George
2017-12-10py/mkrules.mk: Add "clean-frozen" target to clean frozen script/modules dir.Paul Sokolovsky
This target removes any stray files (i.e. something not committed to git) from scripts/ and modules/ dirs (or whatever FROZEN_DIR and FROZEN_MPY_DIR is set to). The expected workflow is: 1. make clean-frozen 2. micropython -m upip -p modules <packages_to_freeze> 3. make As it can be expected that people may drop random thing in those dirs which they can miss later, the content is actually backed up before cleaning.
2017-11-15py/mkenv.mk: Use $(PYTHON) consistently when calling Python tools.Christopher Arndt
Rationale: * Calling Python build tool scripts from makefiles should be done consistently using `python </path/to/script>`, instead of relying on the correct she-bang line in the script [1] and the executable bit on the script being set. This is more platform-independent. * The name/path of the Python executable should always be used via the makefile variable `PYTHON` set in `py/mkenv.mk`. This way it can be easily overwritten by the user with `make PYTHON=/path/to/my/python`. * The Python executable name should be part of the value of the makefile variable, which stands for the build tool command (e.g. `MAKE_FROZEN` and `MPY_TOOL`), not part of the command line where it is used. If a Python tool is substituted by another (non-python) program, no change to the Makefiles is necessary, except in `py/mkenv.mk`. * This also solves #3369 and #1616. [1] There are systems, where even the assumption that `/usr/bin/env` always exists, doesn't hold true, for example on Android (where otherwise the unix port compiles perfectly well).
2017-10-31Revert "py/{mkenv.mk,mkrules.mk}: Append .exe for Windows executable files."Damien George
This reverts commit 3289b9b7a76a1230b6bb631e191a47bfc6c7a8ee. The commit broke building on MINGW because the filename became micropython.exe.exe. A proper solution to support more Windows build environments requires more thought and testing.
2017-10-04py/{mkenv.mk,mkrules.mk}: Append .exe for Windows executable files.chrismas9
Building mpy-cross: this patch adds .exe to the PROG name when building executables for host (eg mpy-cross) on Windows. make clean now removes mpy-cross.exe under Windows. Building MicroPython: this patch sets MPY_CROSS to mpy-cross.exe or mpy-cross so they can coexist and use cygwin or WSL without rebuilding mpy-cross. The dependency in the mpy rule now uses mpy-cross.exe for Windows and mpy-cross for Linux.
2017-09-06all: Update Makefiles and others to build with new ports/ dir layout.Damien George
Also renames "stmhal" to "stm32" in documentation and everywhere else.
2017-08-21py/mkrules.mk: Use "find -path" when searching for frozen obj files.Damien George
This allows the command to succeed without error even if there is no $(BUILD)/build directory, which is the case for mpy-cross.
2017-08-06py/mkrules.mk: Show frozen modules sizes together with executable size.Paul Sokolovsky
This works for Unix and similar ports so far.
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-07-19all: Remove trailing spaces, per coding conventions.Damien George
2017-05-26py/mkrules.mk: Fix auto-qstr generation when "make -B" is used.Damien George
For make v3.81, using "make -B" can set $? to empty and in this case the auto-qstr generation needs to pass all args (ie $^) to cpp. The previous fix for this (which was removed in 23a693ec2d8c2a194f61482dc0e1adb070fb6ad4) used if statements in the shell command, which gave very long lines that didn't work on certain systems (eg cygwin). The fix in this patch is to use an $if(...) expression, which will evaluate to $? (only newer prerequisites) if it's non empty, otherwise it will use $^ (all prerequisites).
2017-05-11py/mkrules.mk: Add dependency of .mpy files upon mpy-cross.Damien George
This ensures that mpy-cross is automatically built (and is up-to-date) for ports that use frozen bytecode. It also makes sure that .mpy files are re-built if mpy-cross is changed.
2017-03-30zephyr/Makefile: Rework to use modern, official build integration.Paul Sokolovsky
Build happens in 3 stages: 1. Zephyr config header and make vars are generated from prj.conf. 2. libmicropython is built using them. 3. Zephyr is built and final link happens.
2017-03-15py/mkrules.mk: Remove special check for "-B" in qstr auto generation.Damien George
When make is passed "-B" it seems that everything is considered out-of-date and so $? expands to all prerequisites. Thus there is no need for a special check to see if $? is emtpy.
2017-01-05py/mkrules.mk: Add MPY_CROSS_FLAGS option to pass flags to mpy-cross.Damien George
So that ports can pass their own custom options to mpy-cross.
2016-12-09py: Integrate Xtensa assembler into native emitter.Damien George
The config option MICROPY_EMIT_XTENSA can now be enabled to target the Xtensa architecture with @micropython.native and @micropython.viper decorators.
2016-11-15py/*.mk: Replace uses of 'sed' with $(SED).Damien George
2016-11-15py/mkrules.mk: Rework find command so it works on OSX.Dave Hylands
The Mac version of find doesn't support -printf, so this changes things to use sed to strip off the leading path element instead.
2016-11-08py: Strip leading dirs from frozen mpy files, so any path can be used.Damien George
With this patch one can now do "make FROZEN_MPY_DIR=../../frozen" to specify a directory containing scripts to be frozen (as well as absolute paths). The compiled .mpy files are now stored in $(BUILD)/frozen_mpy/.
2016-11-08py: Move frozen bytecode Makefile rules from ports to common mk files.Damien George
Now, to use frozen bytecode all a port needs to do is define FROZEN_MPY_DIR to the directory containing the .py files to freeze, and define MICROPY_MODULE_FROZEN_MPY and MICROPY_QSTR_EXTRA_POOL.
2016-09-17py: Move frozen modules rules from esp8266 port for reuse across ports.Paul Sokolovsky
A port now just needs to define FROZEN_DIR var and add $(BUILD)/frozen.c to SRC_C to support frozen modules.
2016-08-30py/mkrules.mk: Allow to override name of libmicropython.aPaul Sokolovsky
Or alternatively, refer to an exact library file, not just phony target "lib".
2016-08-04py/mkrules.mk: Allow to add more items for "clean" target using CLEAN_EXTRA.Paul Sokolovsky
2016-06-16py: Rename __QSTR_EXTRACT flag to NO_QSTR.Paul Sokolovsky
It has more usages than just qstr extraction, for example, embedding (where people don't care about efficient predefined qstrs).
2016-06-16py/mkrules.mk: Define "lib" outside conditional block.Paul Sokolovsky
"lib" happened to be defined inside block conditional on $(PROG).
2016-04-26py/mkrules.mk: Typo fixes in comments.Paul Sokolovsky
2016-04-22py/mkrules.mk: Remove obsolete rules for auto qstr generation.Damien George
2016-04-19py: Divide "split" and "cat" phases of qstr extraction for better efficiency.Paul Sokolovsky
E.g. for stmhal, accumulated preprocessed output may grow large due to bloated vendor headers, and then reprocessing tens of megabytes on each build make take couple of seconds on fast hardware (=> potentially dozens of seconds on slow hardware). So instead, split once after each change, and only cat repetitively (guaranteed to be fast, as there're thousands of lines involved at most).
2016-04-19py/mkrules.mk: Fix Bashism.Paul Sokolovsky
2016-04-19py/mkrules.mk: Cleanup command passed to shell.Paul Sokolovsky
2016-04-19py/mkrules.mk: Try to detect and emulate make -B behavior for qstr extraction.Paul Sokolovsky
If make -B is run, the rule is run with $? empty. Extract fron all file in this case. But this gets fragile, really "make clean" should be used instead with such build complexity.