From 15322c688abafc5a21855352e4c428d9c8772f77 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Thu, 25 Nov 2021 12:16:29 +1100 Subject: [PATCH 1/5] windows/variants: Add support for build variants to windows port. --- ports/windows/Makefile | 24 ++++++++++-- ports/windows/mpconfigport.h | 19 ++++++++-- ports/windows/mpconfigport.mk | 7 +--- ports/windows/variants/dev/manifest.py | 1 + ports/windows/variants/dev/mpconfigvariant.h | 37 +++++++++++++++++++ ports/windows/variants/dev/mpconfigvariant.mk | 5 +++ ports/windows/variants/manifest.py | 0 .../variants/standard/mpconfigvariant.h | 28 ++++++++++++++ .../variants/standard/mpconfigvariant.mk | 3 ++ 9 files changed, 113 insertions(+), 11 deletions(-) create mode 100644 ports/windows/variants/dev/manifest.py create mode 100644 ports/windows/variants/dev/mpconfigvariant.h create mode 100644 ports/windows/variants/dev/mpconfigvariant.mk create mode 100644 ports/windows/variants/manifest.py create mode 100644 ports/windows/variants/standard/mpconfigvariant.h create mode 100644 ports/windows/variants/standard/mpconfigvariant.mk diff --git a/ports/windows/Makefile b/ports/windows/Makefile index cb2ebc22f7c51..b1d2d35c9a1a4 100644 --- a/ports/windows/Makefile +++ b/ports/windows/Makefile @@ -1,11 +1,27 @@ +# Select the variant to build for. +VARIANT ?= standard + +# If the build directory is not given, make it reflect the variant name. +BUILD ?= build-$(VARIANT) + +VARIANT_DIR ?= variants/$(VARIANT) +ifeq ($(wildcard $(VARIANT_DIR)/.),) +$(error Invalid VARIANT specified: $(VARIANT_DIR)) +endif + include ../../py/mkenv.mk -include mpconfigport.mk +include $(VARIANT_DIR)/mpconfigvariant.mk + +FROZEN_MANIFEST ?= variants/manifest.py -# define main target -PROG = micropython +# Define main target +# This should be configured by the mpconfigvariant.mk +PROG ?= micropython # qstr definitions (must come before including py.mk) QSTR_DEFS = ../unix/qstrdefsport.h +QSTR_GLOBAL_DEPENDENCIES = $(VARIANT_DIR)/mpconfigvariant.h # include py core make definitions include $(TOP)/py/py.mk @@ -13,6 +29,7 @@ include $(TOP)/py/py.mk INC += -I. INC += -I$(TOP) INC += -I$(BUILD) +INC += -I$(VARIANT_DIR) # compiler settings CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) @@ -41,7 +58,8 @@ SRC_C = \ init.c \ sleep.c \ fmode.c \ - $(SRC_MOD) + $(SRC_MOD) \ + $(wildcard $(VARIANT_DIR)/*.c) OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) diff --git a/ports/windows/mpconfigport.h b/ports/windows/mpconfigport.h index 30d8e09e6d8ee..9063813f9987d 100644 --- a/ports/windows/mpconfigport.h +++ b/ports/windows/mpconfigport.h @@ -26,6 +26,9 @@ // options to control how MicroPython is built +// Variant-specific definitions. +#include "mpconfigvariant.h" + // By default use MicroPython version of readline #ifndef MICROPY_USE_READLINE #define MICROPY_USE_READLINE (1) @@ -54,9 +57,13 @@ #define MICROPY_REPL_AUTO_INDENT (1) #define MICROPY_HELPER_LEXER_UNIX (1) #define MICROPY_ENABLE_SOURCE_LINE (1) +#ifndef MICROPY_FLOAT_IMPL #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) +#endif #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) +#ifndef MICROPY_STREAMS_NON_BLOCK #define MICROPY_STREAMS_NON_BLOCK (1) +#endif #define MICROPY_STREAMS_POSIX_API (1) #define MICROPY_OPT_COMPUTED_GOTO (0) #define MICROPY_MODULE_WEAK_LINKS (1) @@ -77,8 +84,12 @@ #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) #define MICROPY_PY_BUILTINS_INPUT (1) #define MICROPY_PY_BUILTINS_POW3 (1) +#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 #define MICROPY_PY_BUILTINS_ROUND_INT (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_ALL_SPECIAL_METHODS (1) @@ -97,16 +108,18 @@ #define MICROPY_PY_SYS_EXC_INFO (1) #define MICROPY_PY_COLLECTIONS_DEQUE (1) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) +#ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (1) -#define MICROPY_PY_MATH_ISCLOSE (1) +#endif +#define MICROPY_PY_MATH_ISCLOSE (MICROPY_PY_MATH_SPECIAL_FUNCTIONS) #define MICROPY_PY_CMATH (1) #define MICROPY_PY_IO_IOBASE (1) #define MICROPY_PY_IO_FILEIO (1) #define MICROPY_PY_GC_COLLECT_RETVAL (1) -#define MICROPY_MODULE_FROZEN_STR (0) - +#ifndef MICROPY_STACKLESS #define MICROPY_STACKLESS (0) #define MICROPY_STACKLESS_STRICT (0) +#endif #define MICROPY_PY_UTIME (1) #define MICROPY_PY_UTIME_MP_HAL (1) diff --git a/ports/windows/mpconfigport.mk b/ports/windows/mpconfigport.mk index a2c618f143c22..3b7cf2100d7c9 100644 --- a/ports/windows/mpconfigport.mk +++ b/ports/windows/mpconfigport.mk @@ -1,12 +1,9 @@ # Enable/disable modules and 3rd-party libs to be included in interpreter # Build 32-bit binaries on a 64-bit host -MICROPY_FORCE_32BIT = 0 +MICROPY_FORCE_32BIT ?= 0 # This variable can take the following values: # 0 - no readline, just simple stdin input # 1 - use MicroPython version of readline -MICROPY_USE_READLINE = 1 - -# ffi module requires libffi (libffi-dev Debian package) -MICROPY_PY_FFI = 0 +MICROPY_USE_READLINE ?= 1 diff --git a/ports/windows/variants/dev/manifest.py b/ports/windows/variants/dev/manifest.py new file mode 100644 index 0000000000000..08295fc678d02 --- /dev/null +++ b/ports/windows/variants/dev/manifest.py @@ -0,0 +1 @@ +include("$(PORT_DIR)/variants/manifest.py") diff --git a/ports/windows/variants/dev/mpconfigvariant.h b/ports/windows/variants/dev/mpconfigvariant.h new file mode 100644 index 0000000000000..2da0977140381 --- /dev/null +++ b/ports/windows/variants/dev/mpconfigvariant.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 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. + */ + +#define MICROPY_REPL_EMACS_WORDS_MOVE (1) +#define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (1) +#define MICROPY_ENABLE_SCHEDULER (1) + +#define MICROPY_PY_BUILTINS_HELP (1) +#define MICROPY_PY_BUILTINS_HELP_MODULES (1) +#define MICROPY_PY_SYS_SETTRACE (1) +#define MICROPY_PERSISTENT_CODE_SAVE (1) +#define MICROPY_COMP_CONST (0) +#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) +#define MICROPY_PY_BUILTINS_SLICE_INDICES (1) diff --git a/ports/windows/variants/dev/mpconfigvariant.mk b/ports/windows/variants/dev/mpconfigvariant.mk new file mode 100644 index 0000000000000..b2a0b5bb3388f --- /dev/null +++ b/ports/windows/variants/dev/mpconfigvariant.mk @@ -0,0 +1,5 @@ +PROG ?= micropython-dev + +FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py + +MICROPY_ROM_TEXT_COMPRESSION = 1 diff --git a/ports/windows/variants/manifest.py b/ports/windows/variants/manifest.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/ports/windows/variants/standard/mpconfigvariant.h b/ports/windows/variants/standard/mpconfigvariant.h new file mode 100644 index 0000000000000..3cdcfa8e9b8c9 --- /dev/null +++ b/ports/windows/variants/standard/mpconfigvariant.h @@ -0,0 +1,28 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 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. + */ + +#define MICROPY_PY_BUILTINS_HELP (1) +#define MICROPY_PY_BUILTINS_HELP_MODULES (1) diff --git a/ports/windows/variants/standard/mpconfigvariant.mk b/ports/windows/variants/standard/mpconfigvariant.mk new file mode 100644 index 0000000000000..9e1f5ae059cef --- /dev/null +++ b/ports/windows/variants/standard/mpconfigvariant.mk @@ -0,0 +1,3 @@ +# This is the default variant when you `make` the Windows port. + +PROG ?= micropython From 3d50bdbaaa69924aa3fbffd9a2e2ab9f33bdf804 Mon Sep 17 00:00:00 2001 From: stijn Date: Thu, 25 Nov 2021 11:33:35 +0100 Subject: [PATCH 2/5] windows: Add support for building variants with msvc. --- ports/windows/README.md | 20 +++++++++++++++++++ ports/windows/micropython.vcxproj | 2 ++ ports/windows/msvc/common.props | 9 +++++++++ ports/windows/msvc/paths.props | 9 ++++++--- .../variants/dev/mpconfigvariant.props | 5 +++++ .../variants/standard/mpconfigvariant.props | 5 +++++ 6 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 ports/windows/variants/dev/mpconfigvariant.props create mode 100644 ports/windows/variants/standard/mpconfigvariant.props diff --git a/ports/windows/README.md b/ports/windows/README.md index 55e23de7bf15a..713ea82b87a29 100644 --- a/ports/windows/README.md +++ b/ports/windows/README.md @@ -71,6 +71,26 @@ To build from the command line: msbuild ../../mpy-cross/mpy-cross.vcxproj msbuild micropython.vcxproj +__Variants__ + +The msvc port supports variants (like the unix and windows mingw ports) and the one which gets built is +controlled by the `PyVariant` msbuild property. It defaults to `standard`. +The other variants can be built like: + + msbuild micropython.vcxproj /p:PyVariant=dev + +Or by adding a file [Directory.build.props](https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build#directorybuildprops-and-directorybuildtargets) in this directory or a parent directory: + +```xml + + + dev + + +``` + +See [paths.props](msvc/paths.props) for other related variables like build and variant directories. + __Stack usage__ The msvc compiler is quite stack-hungry which might result in a "maximum recursion depth exceeded" diff --git a/ports/windows/micropython.vcxproj b/ports/windows/micropython.vcxproj index 1beca9e508d42..6817d6ed13b3d 100644 --- a/ports/windows/micropython.vcxproj +++ b/ports/windows/micropython.vcxproj @@ -64,6 +64,7 @@ msvc/user.props + $(PyProg) @@ -95,6 +96,7 @@ + diff --git a/ports/windows/msvc/common.props b/ports/windows/msvc/common.props index fcad5aeb6b7ab..ab9b055deffbf 100644 --- a/ports/windows/msvc/common.props +++ b/ports/windows/msvc/common.props @@ -1,7 +1,15 @@  + + + standard + build-$(PyVariant) + + @@ -31,6 +39,7 @@ $(PyTargetDir)%(FileName)%(Extension) + @@ -25,11 +27,12 @@ $([System.IO.Path]::GetFullPath(`$(MSBuildThisFileDirectory)..\..\..`))\ $(PyBaseDir)ports\windows\ - $(PyWinDir)build\ + $(PyWinDir)$(PyBuild)\ + $(PyWinDir)variants\$(PyVariant)\ $(PyWinDir) - $(PyIncDirs);$(PyBaseDir);$(PyWinDir);$(PyBuildDir);$(PyWinDir)msvc + $(PyIncDirs);$(PyBaseDir);$(PyWinDir);$(PyBuildDir);$(PyWinDir)msvc;$(PyVariantDir) + + + +

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy