From 26c352ba39160200ef615bcf16a6a1bc6c3d7058 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Wed, 22 Apr 2026 10:55:38 +1000 Subject: [PATCH] ports/windows: Allow variant override of common config defines. Wrap most of the unconditional config defines in mpconfigport.h with #ifndef/#endif guards so that a port variant can override them via its own mpconfigvariant.h. This brings the windows port into line with what the unix port already does and is needed by minimal/specialised variants that want to disable e.g. helpers, hashlib, or json without patching the shared port config. Defaults are preserved; behaviour for the existing standard variant is unchanged. Signed-off-by: Andrew Leech --- ports/windows/mpconfigport.h | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/ports/windows/mpconfigport.h b/ports/windows/mpconfigport.h index 1edcd0eded155..e7af7c4c89650 100644 --- a/ports/windows/mpconfigport.h +++ b/ports/windows/mpconfigport.h @@ -52,15 +52,27 @@ #define MICROPY_ENABLE_FINALISER (1) #define MICROPY_ENABLE_PYSTACK (1) #define MICROPY_STACK_CHECK (1) +#ifndef MICROPY_MALLOC_USES_ALLOCATED_SIZE #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1) +#endif +#ifndef MICROPY_MEM_STATS #define MICROPY_MEM_STATS (1) +#endif #define MICROPY_DEBUG_PRINTER (&mp_stderr_print) +#ifndef MICROPY_DEBUG_PRINTERS #define MICROPY_DEBUG_PRINTERS (1) +#endif #define MICROPY_READER_POSIX (1) #define MICROPY_READER_VFS (1) +#ifndef MICROPY_HELPER_REPL #define MICROPY_HELPER_REPL (1) +#endif +#ifndef MICROPY_REPL_EMACS_KEYS #define MICROPY_REPL_EMACS_KEYS (1) +#endif +#ifndef MICROPY_REPL_AUTO_INDENT #define MICROPY_REPL_AUTO_INDENT (1) +#endif #define MICROPY_HELPER_LEXER_UNIX (1) #define MICROPY_ENABLE_SOURCE_LINE (1) #ifndef MICROPY_FLOAT_IMPL @@ -79,9 +91,15 @@ #endif #define MICROPY_VFS (1) #define MICROPY_VFS_POSIX (1) +#ifndef MICROPY_PY_FUNCTION_ATTRS #define MICROPY_PY_FUNCTION_ATTRS (1) +#endif +#ifndef MICROPY_PY_DESCRIPTORS #define MICROPY_PY_DESCRIPTORS (1) +#endif +#ifndef MICROPY_PY_DELATTR_SETATTR #define MICROPY_PY_DELATTR_SETATTR (1) +#endif #define MICROPY_PY_FSTRINGS (1) #define MICROPY_PY_BUILTINS_BYTES_HEX (1) #define MICROPY_PY_BUILTINS_STR_UNICODE (1) @@ -89,26 +107,50 @@ #define MICROPY_PY_BUILTINS_STR_PARTITION (1) #define MICROPY_PY_BUILTINS_STR_SPLITLINES (1) #define MICROPY_PY_BUILTINS_MEMORYVIEW (1) +#ifndef MICROPY_PY_BUILTINS_FROZENSET #define MICROPY_PY_BUILTINS_FROZENSET (1) +#endif +#ifndef MICROPY_PY_BUILTINS_COMPILE #define MICROPY_PY_BUILTINS_COMPILE (1) +#endif +#ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) +#endif +#ifndef MICROPY_PY_BUILTINS_INPUT #define MICROPY_PY_BUILTINS_INPUT (1) +#endif +#ifndef MICROPY_PY_BUILTINS_POW3 #define MICROPY_PY_BUILTINS_POW3 (1) +#endif #ifndef MICROPY_PY_BUILTINS_HELP #define MICROPY_PY_BUILTINS_HELP (1) #endif #ifndef MICROPY_PY_BUILTINS_HELP_MODULES #define MICROPY_PY_BUILTINS_HELP_MODULES (1) #endif +#ifndef MICROPY_PY_BUILTINS_ROUND_INT #define MICROPY_PY_BUILTINS_ROUND_INT (1) +#endif +#ifndef MICROPY_PY_MICROPYTHON_MEM_INFO #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) +#endif +#ifndef MICROPY_PY_ALL_SPECIAL_METHODS #define MICROPY_PY_ALL_SPECIAL_METHODS (1) +#endif +#ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS #define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) +#endif #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) +#ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS #define MICROPY_PY_BUILTINS_SLICE_ATTRS (1) +#endif +#ifndef MICROPY_PY_SYS_PATH_ARGV_DEFAULTS #define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (0) +#endif #define MICROPY_PY_SYS_EXIT (1) +#ifndef MICROPY_PY_SYS_ATEXIT #define MICROPY_PY_SYS_ATEXIT (1) +#endif #define MICROPY_PY_SYS_PLATFORM "win32" #ifndef MICROPY_PY_SYS_PATH_DEFAULT #define MICROPY_PY_SYS_PATH_DEFAULT ".frozen;~/.micropython/lib" @@ -116,15 +158,27 @@ #define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_EXC_INFO (1) +#ifndef MICROPY_PY_COLLECTIONS_DEQUE #define MICROPY_PY_COLLECTIONS_DEQUE (1) +#endif +#ifndef MICROPY_PY_COLLECTIONS_DEQUE_ITER #define MICROPY_PY_COLLECTIONS_DEQUE_ITER (1) +#endif +#ifndef MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR #define MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR (1) +#endif +#ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) +#endif #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (1) #endif +#ifndef MICROPY_PY_MATH_ISCLOSE #define MICROPY_PY_MATH_ISCLOSE (MICROPY_PY_MATH_SPECIAL_FUNCTIONS) +#endif +#ifndef MICROPY_PY_CMATH #define MICROPY_PY_CMATH (1) +#endif #define MICROPY_PY_IO_IOBASE (1) #define MICROPY_PY_GC_COLLECT_RETVAL (1) #ifndef MICROPY_STACKLESS @@ -143,21 +197,45 @@ #define MICROPY_PY_TIME_TIME_TIME_NS (1) #define MICROPY_PY_TIME_CUSTOM_SLEEP (1) #define MICROPY_PY_TIME_INCLUDEFILE "ports/unix/modtime.c" +#ifndef MICROPY_PY_ERRNO #define MICROPY_PY_ERRNO (1) +#endif +#ifndef MICROPY_PY_UCTYPES #define MICROPY_PY_UCTYPES (1) +#endif +#ifndef MICROPY_PY_DEFLATE #define MICROPY_PY_DEFLATE (1) +#endif +#ifndef MICROPY_PY_DEFLATE_COMPRESS #define MICROPY_PY_DEFLATE_COMPRESS (1) +#endif +#ifndef MICROPY_PY_JSON #define MICROPY_PY_JSON (1) +#endif +#ifndef MICROPY_PY_RE #define MICROPY_PY_RE (1) +#endif +#ifndef MICROPY_PY_HEAPQ #define MICROPY_PY_HEAPQ (1) +#endif +#ifndef MICROPY_PY_HASHLIB #define MICROPY_PY_HASHLIB (1) +#endif #define MICROPY_PY_BINASCII (1) #define MICROPY_PY_BINASCII_CRC32 (1) +#ifndef MICROPY_PY_RANDOM #define MICROPY_PY_RANDOM (1) +#endif +#ifndef MICROPY_PY_MACHINE #define MICROPY_PY_MACHINE (1) +#endif #define MICROPY_PY_MACHINE_INCLUDEFILE "ports/unix/modmachine.c" +#ifndef MICROPY_PY_MACHINE_PULSE #define MICROPY_PY_MACHINE_PULSE (1) +#endif +#ifndef MICROPY_PY_MACHINE_PIN_BASE #define MICROPY_PY_MACHINE_PIN_BASE (1) +#endif #define MICROPY_MACHINE_MEM_GET_READ_ADDR mod_machine_mem_get_addr #define MICROPY_MACHINE_MEM_GET_WRITE_ADDR mod_machine_mem_get_addr @@ -167,10 +245,16 @@ // Enable handling of sys.exit() exit codes. #define MICROPY_PYEXEC_ENABLE_EXIT_CODE_HANDLING (1) +#ifndef MICROPY_ERROR_REPORTING #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) +#endif #define MICROPY_ERROR_PRINTER (&mp_stderr_print) +#ifndef MICROPY_WARNINGS #define MICROPY_WARNINGS (1) +#endif +#ifndef MICROPY_PY_STR_BYTES_CMP_WARN #define MICROPY_PY_STR_BYTES_CMP_WARN (1) +#endif // VFS stat functions should return time values relative to 1970/1/1 #define MICROPY_EPOCH_IS_1970 (1)