Skip to content

Commit 9c7fe77

Browse files
committed
windows/variants: Add support for build variants to windows port.
1 parent 81f706a commit 9c7fe77

File tree

9 files changed

+113
-11
lines changed

9 files changed

+113
-11
lines changed

ports/windows/Makefile

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
1+
# Select the variant to build for.
2+
VARIANT ?= standard
3+
4+
# If the build directory is not given, make it reflect the variant name.
5+
BUILD ?= build-$(VARIANT)
6+
7+
VARIANT_DIR ?= variants/$(VARIANT)
8+
ifeq ($(wildcard $(VARIANT_DIR)/.),)
9+
$(error Invalid VARIANT specified: $(VARIANT_DIR))
10+
endif
11+
112
include ../../py/mkenv.mk
213
-include mpconfigport.mk
14+
include $(VARIANT_DIR)/mpconfigvariant.mk
15+
16+
FROZEN_MANIFEST ?= variants/manifest.py
317

4-
# define main target
5-
PROG = micropython
18+
# Define main target
19+
# This should be configured by the mpconfigvariant.mk
20+
PROG ?= micropython
621

722
# qstr definitions (must come before including py.mk)
823
QSTR_DEFS = ../unix/qstrdefsport.h
24+
QSTR_GLOBAL_DEPENDENCIES = $(VARIANT_DIR)/mpconfigvariant.h
925

1026
# include py core make definitions
1127
include $(TOP)/py/py.mk
1228

1329
INC += -I.
1430
INC += -I$(TOP)
1531
INC += -I$(BUILD)
32+
INC += -I$(VARIANT_DIR)
1633

1734
# compiler settings
1835
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 = \
4158
init.c \
4259
sleep.c \
4360
fmode.c \
44-
$(SRC_MOD)
61+
$(SRC_MOD) \
62+
$(wildcard $(VARIANT_DIR)/*.c)
4563

4664
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
4765

ports/windows/mpconfigport.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
// options to control how MicroPython is built
2828

29+
// Variant-specific definitions.
30+
#include "mpconfigvariant.h"
31+
2932
// By default use MicroPython version of readline
3033
#ifndef MICROPY_USE_READLINE
3134
#define MICROPY_USE_READLINE (1)
@@ -54,9 +57,13 @@
5457
#define MICROPY_REPL_AUTO_INDENT (1)
5558
#define MICROPY_HELPER_LEXER_UNIX (1)
5659
#define MICROPY_ENABLE_SOURCE_LINE (1)
60+
#ifndef MICROPY_FLOAT_IMPL
5761
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
62+
#endif
5863
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
64+
#ifndef MICROPY_STREAMS_NON_BLOCK
5965
#define MICROPY_STREAMS_NON_BLOCK (1)
66+
#endif
6067
#define MICROPY_STREAMS_POSIX_API (1)
6168
#define MICROPY_OPT_COMPUTED_GOTO (0)
6269
#define MICROPY_MODULE_WEAK_LINKS (1)
@@ -76,8 +83,12 @@
7683
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1)
7784
#define MICROPY_PY_BUILTINS_INPUT (1)
7885
#define MICROPY_PY_BUILTINS_POW3 (1)
86+
#ifndef MICROPY_PY_BUILTINS_HELP
7987
#define MICROPY_PY_BUILTINS_HELP (1)
88+
#endif
89+
#ifndef MICROPY_PY_BUILTINS_HELP_MODULES
8090
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
91+
#endif
8192
#define MICROPY_PY_BUILTINS_ROUND_INT (1)
8293
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
8394
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
@@ -95,16 +106,18 @@
95106
#define MICROPY_PY_SYS_EXC_INFO (1)
96107
#define MICROPY_PY_COLLECTIONS_DEQUE (1)
97108
#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1)
109+
#ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
98110
#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (1)
99-
#define MICROPY_PY_MATH_ISCLOSE (1)
111+
#endif
112+
#define MICROPY_PY_MATH_ISCLOSE (MICROPY_PY_MATH_SPECIAL_FUNCTIONS)
100113
#define MICROPY_PY_CMATH (1)
101114
#define MICROPY_PY_IO_IOBASE (1)
102115
#define MICROPY_PY_IO_FILEIO (1)
103116
#define MICROPY_PY_GC_COLLECT_RETVAL (1)
104-
#define MICROPY_MODULE_FROZEN_STR (0)
105-
117+
#ifndef MICROPY_STACKLESS
106118
#define MICROPY_STACKLESS (0)
107119
#define MICROPY_STACKLESS_STRICT (0)
120+
#endif
108121

109122
#define MICROPY_PY_UTIME (1)
110123
#define MICROPY_PY_UTIME_MP_HAL (1)

ports/windows/mpconfigport.mk

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
# Enable/disable modules and 3rd-party libs to be included in interpreter
22

33
# Build 32-bit binaries on a 64-bit host
4-
MICROPY_FORCE_32BIT = 0
4+
MICROPY_FORCE_32BIT ?= 0
55

66
# This variable can take the following values:
77
# 0 - no readline, just simple stdin input
88
# 1 - use MicroPython version of readline
9-
MICROPY_USE_READLINE = 1
10-
11-
# ffi module requires libffi (libffi-dev Debian package)
12-
MICROPY_PY_FFI = 0
9+
MICROPY_USE_READLINE ?= 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include("$(PORT_DIR)/variants/manifest.py")
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Damien P. George
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#define MICROPY_REPL_EMACS_WORDS_MOVE (1)
28+
#define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (1)
29+
#define MICROPY_ENABLE_SCHEDULER (1)
30+
31+
#define MICROPY_PY_BUILTINS_HELP (1)
32+
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
33+
#define MICROPY_PY_SYS_SETTRACE (1)
34+
#define MICROPY_PERSISTENT_CODE_SAVE (1)
35+
#define MICROPY_COMP_CONST (0)
36+
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
37+
#define MICROPY_PY_BUILTINS_SLICE_INDICES (1)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PROG ?= micropython-dev
2+
3+
FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py
4+
5+
MICROPY_ROM_TEXT_COMPRESSION = 1

ports/windows/variants/manifest.py

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Damien P. George
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#define MICROPY_PY_BUILTINS_HELP (1)
28+
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This is the default variant when you `make` the Windows port.
2+
3+
PROG ?= micropython

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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