RFC: overriding mpconfig(port).h macros
Introduction of variants came along with wrapping a bunch of definitions in mpconfigport.h with #ifndef MICROPY_SOME_OPTION because otherwise these couldn't be defined in mpconfigvariant.h anymore. Likewise this also means that a variant cannot define anything which is already defined in mpconfigport.h and is not yet wrapped. Which is not ideal.
A simple solution is allowing to include another file after everything in mpconfigport.h (or even mpconfgh.h). In such file users can then #undef and #define again at will.
So how about adding
#ifdef MP_POSTCONFIGFILE
#include MP_POSTCONFIGFILE
#endif
at the end of mpconfig.h ? (name is chosen for consistency with MP_CONFIGFILE at the top though that doesn't follow naming conventions).
Alternatively this could go at the end of each mpconfigport.h but I'm not sure that is needed.
unix: Refactor variant config and enable features in standard build.
Summary:
- Remove the special-casing of the minimal variant and simplify mpconfigport/mpconfigvariant.
- Make the default build useful by default.
- Remove "unused" variants.
- Make coverage build use the "everything" level, and update mpconfig.h to define features for that level.
This is a no-op for the coverage variant.
For the minimal variant it is effectively the same except:
- some additional configuration macros get defined but are not used (e.g.
MICROPY_MACHINE_MEM_GET_READ_ADDR) - three new features macros enabled --
MICROPY_PY_SYS_EXIT&MICROPY_PY_SYS_PATH_ARGV_DEFAULTS&MICROPY_MODULE_OVERRIDE_MAIN_IMPORT. Arguably those last two should have been enabled already.
The dev variant and standard variant are now combined into the standard variant. The logic here is:
- The default unix build should be at least feature compatible with a common bare-metal board. e.g. pybv11. This means enabling asyncio, random extra, etc. The full list is below.
- I know there's history here, but my logic is that the default build is primarily for developers to run MicroPython code locally (either for development/debugging of MicroPython itself, or for rapid iteration of code intended for a device). If people want to tune the Unix port for a specific target, this is now much easier to do with config levels and the simplified mpconfigport/mpconfigvariant layout introduced in this PR.
Removes the "fast" and "freedos" variants. Fast doesn't really make sense except to game a specific benchmark. Perhaps in the future we should replace it with experimental optimisations that we don't have code size for on bare-metal. "freedos" is too difficult to maintain (and isn't tested by CI either).
Bluetooth (which was enabled in the dev variant) is disabled in the default variant. It adds an extra dependency on NimBLE, and isn't terribly useful out-of-the-box because it requires a HCI UART. It can be easily enabled by make arguments.
settrace was also enabled in dev. It can also be enabled easily with a single make argument, but I would suggest that we enable this by default in the default build.
Another thing I'd like to consider is making the default variant even more like bare metal, e.g. use extmod/uselect rather than unix/select (to ensure compatibility with bare-metal -- e.g. aioble doesn't work with the unix version), and disabling FFI/JNI/etc (to reduce build dependencies). I suggest we could add a "posix" (or "unix"?) variant that enables these "I'm using this as a CPython replacement" use cases.
TODO: Update README (I want to move the Unix section out of the top level and into ports/unix) and docs.
cc @dlech @mattytrentini @andrewleech
Extra features added to standard:
MICROPY_ENABLE_SCHEDULER
MICROPY_MODULE_ATTR_DELEGATION
MICROPY_MODULE_BUILTIN_INIT
MICROPY_OPT_MATH_FACTORIAL
MICROPY_OPT_MPZ_BITWISE
MICROPY_PY_BUILTINS_EXECFILE
MICROPY_PY_FRAMEBUF
MICROPY_PY_MATH_CONSTANTS
MICROPY_PY_MATH_FACTORIAL
MICROPY_PY_SYS_ATTR_DELEGATION
MICROPY_PY_SYS_PS1_PS2
MICROPY_PY_SYS_STDIO_BUFFER
MICROPY_PY_UASYNCIO
MICROPY_PY_URANDOM_EXTRA_FUNCS
MICROPY_PY_URE_SUB
MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE
MICROPY_REPL_EMACS_WORDS_MOVE
MICROPY_VFS_FAT
MICROPY_VFS_LFS1
MICROPY_VFS_LFS2