Skip to content

Commit 49254be

Browse files
andrewleechpi-anl
authored andcommitted
windows/variants: Add support for build variants to windows port.
Increase configuration consistency with the unix port.
1 parent 6952704 commit 49254be

File tree

9 files changed

+180
-23
lines changed

9 files changed

+180
-23
lines changed

ports/windows/Makefile

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
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+
# use FROZEN_MANIFEST for new projects, others are legacy
17+
FROZEN_MANIFEST ?= variants/manifest.py
18+
FROZEN_DIR =
19+
FROZEN_MPY_DIR =
320

4-
# define main target
5-
PROG = micropython
21+
# Define main target
22+
# This should be configured by the mpconfigvariant.mk
23+
PROG ?= micropython
624

725
# qstr definitions (must come before including py.mk)
826
QSTR_DEFS = ../unix/qstrdefsport.h
27+
QSTR_GLOBAL_DEPENDENCIES = $(VARIANT_DIR)/mpconfigvariant.h
928

1029
# include py core make definitions
1130
include $(TOP)/py/py.mk
@@ -15,7 +34,7 @@ INC += -I$(TOP)
1534
INC += -I$(BUILD)
1635

1736
# compiler settings
18-
CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
37+
CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) -I$(VARIANT_DIR) $(CFLAGS_EXTRA)
1938
LDFLAGS = $(LDFLAGS_MOD) -lm $(LDFLAGS_EXTRA)
2039

2140
# Debugging/Optimization
@@ -34,16 +53,32 @@ SRC_C = \
3453
ports/unix/input.c \
3554
ports/unix/modos.c \
3655
ports/unix/modmachine.c \
56+
ports/unix/modos.c \
57+
ports/unix/moduos_vfs.c \
3758
ports/unix/modtime.c \
3859
ports/unix/gccollect.c \
3960
windows_mphal.c \
4061
realpath.c \
4162
init.c \
4263
sleep.c \
4364
fmode.c \
44-
$(SRC_MOD)
65+
$(SRC_MOD) \
66+
$(wildcard $(VARIANT_DIR)/*.c)
67+
68+
SHARED_SRC_C += $(addprefix shared/,\
69+
runtime/gchelper_generic.c \
70+
timeutils/timeutils.c \
71+
$(SHARED_SRC_C_EXTRA) \
72+
)
73+
74+
SRC_CXX += \
75+
$(SRC_MOD_CXX)
4576

4677
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
78+
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
79+
OBJ += $(addprefix $(BUILD)/, $(SHARED_SRC_C:.c=.o))
80+
OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o))
81+
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
4782

4883
ifeq ($(MICROPY_USE_READLINE),1)
4984
CFLAGS_MOD += -DMICROPY_USE_READLINE=1
@@ -53,11 +88,16 @@ endif
5388
LIB += -lws2_32
5489

5590
# List of sources for qstr extraction
56-
SRC_QSTR += $(SRC_C)
91+
SRC_QSTR += $(SRC_C) $(SRC_CXX) $(SHARED_SRC_C) $(EXTMOD_SRC_C)
5792
# Append any auto-generated sources that are needed by sources listed in
5893
# SRC_QSTR
5994
SRC_QSTR_AUTO_DEPS +=
6095

96+
ifeq ($(MICROPY_PY_SOCKET),1)
97+
CFLAGS_MOD += -DMICROPY_PY_SOCKET=1
98+
SRC_MOD += ports/unix/modusocket.c
99+
endif
100+
61101
ifneq ($(FROZEN_MANIFEST),)
62102
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool -DMICROPY_MODULE_FROZEN_MPY=1 -DMPZ_DIG_SIZE=16
63103
endif

ports/windows/mpconfigport.h

Lines changed: 51 additions & 13 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)
@@ -45,18 +48,24 @@
4548
#define MICROPY_STACK_CHECK (1)
4649
#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
4750
#define MICROPY_MEM_STATS (1)
48-
#define MICROPY_DEBUG_PRINTER (&mp_stderr_print)
4951
#define MICROPY_DEBUG_PRINTERS (1)
52+
// Printing debug to stderr may give tests which
53+
// check stdout a chance to pass, etc.
54+
#define MICROPY_DEBUG_PRINTER (&mp_stderr_print)
5055
#define MICROPY_READER_POSIX (1)
5156
#define MICROPY_USE_READLINE_HISTORY (1)
5257
#define MICROPY_HELPER_REPL (1)
5358
#define MICROPY_REPL_EMACS_KEYS (1)
5459
#define MICROPY_REPL_AUTO_INDENT (1)
5560
#define MICROPY_HELPER_LEXER_UNIX (1)
5661
#define MICROPY_ENABLE_SOURCE_LINE (1)
62+
#ifndef MICROPY_FLOAT_IMPL
5763
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
64+
#endif
5865
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
66+
#ifndef MICROPY_STREAMS_NON_BLOCK
5967
#define MICROPY_STREAMS_NON_BLOCK (1)
68+
#endif
6069
#define MICROPY_STREAMS_POSIX_API (1)
6170
#define MICROPY_OPT_COMPUTED_GOTO (0)
6271
#define MICROPY_MODULE_WEAK_LINKS (1)
@@ -76,14 +85,19 @@
7685
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1)
7786
#define MICROPY_PY_BUILTINS_INPUT (1)
7887
#define MICROPY_PY_BUILTINS_POW3 (1)
88+
#ifndef MICROPY_PY_BUILTINS_HELP
7989
#define MICROPY_PY_BUILTINS_HELP (1)
90+
#endif
91+
#ifndef MICROPY_PY_BUILTINS_HELP_MODULES
8092
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
93+
#endif
8194
#define MICROPY_PY_BUILTINS_ROUND_INT (1)
8295
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
8396
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
8497
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
8598
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
8699
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
100+
#define MICROPY_PY_BUILTINS_SLICE_INDICES (1)
87101
#define MICROPY_PY_SYS_EXIT (1)
88102
#define MICROPY_PY_SYS_ATEXIT (1)
89103
#define MICROPY_PY_SYS_PLATFORM "win32"
@@ -95,16 +109,18 @@
95109
#define MICROPY_PY_SYS_EXC_INFO (1)
96110
#define MICROPY_PY_COLLECTIONS_DEQUE (1)
97111
#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1)
112+
#ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
98113
#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (1)
99-
#define MICROPY_PY_MATH_ISCLOSE (1)
114+
#endif
115+
#define MICROPY_PY_MATH_ISCLOSE (MICROPY_PY_MATH_SPECIAL_FUNCTIONS)
100116
#define MICROPY_PY_CMATH (1)
101117
#define MICROPY_PY_IO_IOBASE (1)
102118
#define MICROPY_PY_IO_FILEIO (1)
103119
#define MICROPY_PY_GC_COLLECT_RETVAL (1)
104-
#define MICROPY_MODULE_FROZEN_STR (0)
105-
120+
#ifndef MICROPY_STACKLESS
106121
#define MICROPY_STACKLESS (0)
107122
#define MICROPY_STACKLESS_STRICT (0)
123+
#endif
108124

109125
#define MICROPY_PY_UTIME (1)
110126
#define MICROPY_PY_UTIME_MP_HAL (1)
@@ -116,17 +132,23 @@
116132
#define MICROPY_PY_UHEAPQ (1)
117133
#define MICROPY_PY_UTIMEQ (1)
118134
#define MICROPY_PY_UHASHLIB (1)
135+
#if MICROPY_PY_USSL
136+
#define MICROPY_PY_UHASHLIB_MD5 (1)
137+
#define MICROPY_PY_UHASHLIB_SHA1 (1)
138+
#define MICROPY_PY_UCRYPTOLIB (1)
139+
#endif
119140
#define MICROPY_PY_UBINASCII (1)
120141
#define MICROPY_PY_UBINASCII_CRC32 (1)
121142
#define MICROPY_PY_URANDOM (1)
143+
#define MICROPY_PY_UWEBSOCKET (1)
122144
#define MICROPY_PY_MACHINE (1)
123145
#define MICROPY_PY_MACHINE_PULSE (1)
124146
#define MICROPY_MACHINE_MEM_GET_READ_ADDR mod_machine_mem_get_addr
125147
#define MICROPY_MACHINE_MEM_GET_WRITE_ADDR mod_machine_mem_get_addr
126148

127149
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)
128-
#define MICROPY_ERROR_PRINTER (&mp_stderr_print)
129150
#define MICROPY_WARNINGS (1)
151+
#define MICROPY_ERROR_PRINTER (&mp_stderr_print)
130152
#define MICROPY_PY_STR_BYTES_CMP_WARN (1)
131153
#ifndef MICROPY_ENABLE_SCHEDULER
132154
#define MICROPY_ENABLE_SCHEDULER (1)
@@ -152,6 +174,29 @@ extern const struct _mp_print_t mp_stderr_print;
152174
#define MICROPY_PORT_INIT_FUNC init()
153175
#define MICROPY_PORT_DEINIT_FUNC deinit()
154176

177+
extern const struct _mp_obj_module_t mp_module_machine;
178+
extern const struct _mp_obj_module_t mp_module_os;
179+
extern const struct _mp_obj_module_t mp_module_uos_vfs;
180+
extern const struct _mp_obj_module_t mp_module_time;
181+
extern const struct _mp_obj_module_t mp_module_socket;
182+
extern const struct _mp_obj_module_t mp_module_ffi;
183+
184+
#if MICROPY_PY_UOS_VFS
185+
#define MICROPY_PY_UOS_DEF { MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_uos_vfs) },
186+
#else
187+
#define MICROPY_PY_UOS_DEF { MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_os) },
188+
#endif
189+
#if MICROPY_PY_UTIME
190+
#define MICROPY_PY_UTIME_DEF { MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_time) },
191+
#else
192+
#define MICROPY_PY_UTIME_DEF
193+
#endif
194+
195+
#define MICROPY_PORT_BUILTIN_MODULES \
196+
MICROPY_PY_UTIME_DEF \
197+
MICROPY_PY_UOS_DEF \
198+
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&mp_module_machine) }, \
199+
155200
// type definitions for the specific machine
156201

157202
#if defined(__MINGW32__) && defined(__LP64__)
@@ -188,20 +233,13 @@ typedef long mp_off_t;
188233
#define MICROPY_PORT_BUILTINS \
189234
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
190235

191-
extern const struct _mp_obj_module_t mp_module_os;
192-
extern const struct _mp_obj_module_t mp_module_time;
193-
#define MICROPY_PORT_BUILTIN_MODULES \
194-
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_time) }, \
195-
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&mp_module_machine) }, \
196-
{ MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_os) }, \
236+
#define MP_STATE_PORT MP_STATE_VM
197237

198238
#if MICROPY_USE_READLINE == 1
199239
#define MICROPY_PORT_ROOT_POINTERS \
200240
char *readline_hist[50];
201241
#endif
202242

203-
#define MP_STATE_PORT MP_STATE_VM
204-
205243
#define MICROPY_MPHALPORT_H "windows_mphal.h"
206244

207245
#if MICROPY_ENABLE_SCHEDULER

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include("$(PORT_DIR)/variants/manifest.py")
2+
3+
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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_USELECT (1)
38+
39+
#ifndef MICROPY_PY_UASYNCIO
40+
#define MICROPY_PY_UASYNCIO (1)
41+
#endif
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PROG ?= micropython-dev.exe
2+
3+
FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py
4+
5+
MICROPY_ROM_TEXT_COMPRESSION = 1

ports/windows/variants/manifest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
freeze_as_mpy("$(MPY_DIR)/tools", "upip.py")
2+
freeze_as_mpy("$(MPY_DIR)/tools", "upip_utarfile.py", opt=3)
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 Unix port.
2+
3+
PROG ?= micropython.exe

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