Skip to content

Commit

Permalink
all: Enable features we use and disable stack check.
Browse files Browse the repository at this point in the history
As much as possible is done with a variant but some modifications
are still needed:
- make our variant the default for simplicity
- disable stack check, mainly because we call MicroPython code from
  multiple threads which makes the stack check impossible
  • Loading branch information
stinos committed Feb 6, 2024
1 parent 46312f1 commit 26c5119
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 7 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/ports_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
matrix:
platform: [x86, x64]
configuration: [Debug, Release]
variant: [dev, standard]
variant: [dev, tns]
visualstudio: ['2017', '2019', '2022']
include:
- visualstudio: '2017'
Expand All @@ -38,7 +38,7 @@ jobs:
vs_version: '[17, 18)'
# trim down the number of jobs in the matrix
exclude:
- variant: standard
- variant: tns
configuration: Debug
- visualstudio: '2019'
configuration: Debug
Expand All @@ -60,6 +60,20 @@ jobs:
- uses: actions/checkout@v3
- name: Build mpy-cross.exe
run: msbuild mpy-cross\mpy-cross.vcxproj -maxcpucount -property:Configuration=${{ matrix.configuration }} -property:Platform=${{ matrix.platform }}
- name: Set custom build options
shell: pwsh
run: |
@'
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<!--To make the standard test suite pass.-->
<PreprocessorDefinitions>%(PreprocessorDefinitions);MICROPY_STACK_CHECK=1</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
</Project>
'@ | Set-Content ports\windows\msvc\user.props
- name: Build micropython.exe
run: msbuild ports\windows\micropythoncore.vcxproj;ports\windows\micropython.vcxproj -maxcpucount -property:Configuration=${{ matrix.configuration }} -property:Platform=${{ matrix.platform }} -property:PyVariant=${{ matrix.variant }}
- name: Get micropython.exe path
Expand Down Expand Up @@ -92,7 +106,7 @@ jobs:
strategy:
fail-fast: false
matrix:
variant: [dev, standard]
variant: [dev, tns]
sys: [mingw32, mingw64]
include:
- sys: mingw32
Expand Down Expand Up @@ -133,7 +147,7 @@ jobs:
- name: Update submodules
run: make -C ports/windows VARIANT=${{ matrix.variant }} submodules
- name: Build micropython.exe
run: make -C ports/windows -j2 VARIANT=${{ matrix.variant }}
run: make -C ports/windows -j2 VARIANT=${{ matrix.variant }} CFLAGS_EXTRA="-DMICROPY_STACK_CHECK=1"
- name: Run tests
id: test
# msys python breaks tests so we need to use "real" windows python
Expand Down
2 changes: 1 addition & 1 deletion ports/windows/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ifdef VARIANT_DIR
VARIANT ?= $(notdir $(VARIANT_DIR:/=))
else
# If not given on the command line, then default to standard.
VARIANT ?= standard
VARIANT ?= tns
VARIANT_DIR ?= variants/$(VARIANT)
endif

Expand Down
4 changes: 3 additions & 1 deletion ports/windows/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
#define MICROPY_ENABLE_GC (1)
#define MICROPY_ENABLE_FINALISER (1)
#define MICROPY_ENABLE_PYSTACK (1)
#define MICROPY_STACK_CHECK (1)
#ifndef MICROPY_STACK_CHECK
#define MICROPY_STACK_CHECK (0)
#endif
#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
#define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTER (&mp_stderr_print)
Expand Down
2 changes: 1 addition & 1 deletion ports/windows/msvc/variant.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Define the variant-related properties -->
<PropertyGroup Condition="'$(PyBuildingMpyCross)' != 'True'">
<PyVariantscluded>True</PyVariantscluded>
<PyVariant Condition="'$(PyVariant)' == ''">standard</PyVariant>
<PyVariant Condition="'$(PyVariant)' == ''">tns</PyVariant>
<PyBuild Condition="'$(PyBuild)' == ''">build-$(PyVariant)</PyBuild>
</PropertyGroup>
</Project>
4 changes: 4 additions & 0 deletions ports/windows/variants/tns/builtins.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "py/objexcept.h"

MP_DEFINE_EXCEPTION(ConnectionError, OSError)
MP_DEFINE_EXCEPTION(TimeoutError, OSError)
26 changes: 26 additions & 0 deletions ports/windows/variants/tns/mpconfigvariant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#define MICROPY_ENABLE_SCHEDULER (0)
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
#define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (1)
#define MICROPY_PY_BUILTINS_NEXT2 (1)
#define MICROPY_PY_BUILTINS_DESCRIPTOR (1)
#define MICROPY_PY_BUILTINS_RANGE_BINOP (1)
#define MICROPY_PY_BUILTINS_SLICE_INDICES (1)
#define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (1)
#define MICROPY_PY_MATH_CONSTANTS (1)
#define MICROPY_PY_MATH_FACTORIAL (1)
#define MICROPY_PY_SYS_EXECUTABLE (1)
#define MICROPY_PY_PLATFORM (1)
#define MICROPY_PY_RANDOM_EXTRA_FUNCS (1)
#define MICROPY_PY_RE_MATCH_GROUPS (1)
#define MICROPY_PY_RE_MATCH_SPAN_START_END (1)
#define MICROPY_PY_RE_SUB (1)
#define MICROPY_REPL_EMACS_WORDS_MOVE (1)
#define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (1)

extern const struct _mp_obj_type_t mp_type_ConnectionError;
extern const struct _mp_obj_type_t mp_type_TimeoutError;
#define MICROPY_PORT_EXTRA_BUILTINS \
{ MP_ROM_QSTR(MP_QSTR_ConnectionError), MP_ROM_PTR(&mp_type_ConnectionError) }, \
{ MP_ROM_QSTR(MP_QSTR_TimeoutError), MP_ROM_PTR(&mp_type_TimeoutError) }, \
// Extra line to avoid "backslash-newline at end of file" warning.
1 change: 1 addition & 0 deletions ports/windows/variants/tns/mpconfigvariant.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROG ?= micropython
8 changes: 8 additions & 0 deletions ports/windows/variants/tns/mpconfigvariant.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<PropertyGroup>
<PyProg>micropython</PyProg>
</PropertyGroup>
<ItemGroup>
<PyExtModSource Include="..\..\extmod\modplatform.c" />
</ItemGroup>
</Project>

0 comments on commit 26c5119

Please sign in to comment.