diff options
Diffstat (limited to 'windows')
-rw-r--r-- | windows/.gitignore | 2 | ||||
-rw-r--r-- | windows/Makefile | 2 | ||||
-rw-r--r-- | windows/README | 56 | ||||
-rw-r--r-- | windows/README.md | 74 | ||||
-rw-r--r-- | windows/micropython.vcxproj | 8 | ||||
-rw-r--r-- | windows/mpconfigport.h | 23 | ||||
-rw-r--r-- | windows/msvc/debug.props | 8 | ||||
-rw-r--r-- | windows/msvc/genhdr.targets | 24 | ||||
-rw-r--r-- | windows/msvc/sources.props | 4 | ||||
-rw-r--r-- | windows/windows_mphal.c | 6 |
10 files changed, 127 insertions, 80 deletions
diff --git a/windows/.gitignore b/windows/.gitignore index d26ef4db7..12235e7c9 100644 --- a/windows/.gitignore +++ b/windows/.gitignore @@ -7,3 +7,5 @@ *.ilk *.filters /build/* +.vs/* +*.VC.*db diff --git a/windows/Makefile b/windows/Makefile index 68de66a07..72c97381b 100644 --- a/windows/Makefile +++ b/windows/Makefile @@ -15,7 +15,7 @@ INC += -I.. INC += -I$(BUILD) # compiler settings -CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) +CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) LDFLAGS = $(LDFLAGS_MOD) -lm # Debugging/Optimization diff --git a/windows/README b/windows/README deleted file mode 100644 index 4b383eaed..000000000 --- a/windows/README +++ /dev/null @@ -1,56 +0,0 @@ -This is experimental, community-supported Windows port of MicroPython. -It is based on Unix port, and expected to remain so. -The port requires additional testing, debugging, and patches. Please -consider to contribute. - - -To cross-compile under Debian/Ubuntu Linux system: - -sudo apt-get install gcc-mingw-w64 -make CROSS_COMPILE=i686-w64-mingw32- - -If for some reason the mingw-w64 crosscompiler is not available, you can try -mingw32 instead, but it comes with a really old gcc which may produce some -spurious errors (you may need to disable -Werror): - -sudo apt-get install mingw32 mingw32-binutils mingw32-runtime -make CROSS_COMPILE=i586-mingw32msvc- - - -To compile under Cygwin: - -Install following packages using cygwin's setup.exe: -mingw64-i686-gcc-core, mingw64-x86_64-gcc-core, make -Build using: - -make CROSS_COMPILE=i686-w64-mingw32- - -or for 64bit: - -make CROSS_COMPILE=x86_64-w64-mingw32- - - -To compile using Visual Studio 2013 (or higher): - -Open micropython.vcxproj and build - - -To compile using Visual Studio 2013 (or higher) commandline: - -msbuild micropython.vcxproj - - -To run on Linux using Wine: - -The default build (MICROPY_USE_READLINE=1) uses extended Windows console -functions and thus should be run using "wineconsole" tool. Depending -on the Wine build configuration, you may also want to select the curses -backend which has the look&feel of a standard Unix console: - - wineconsole --backend=curses ./micropython.exe - -For more info, see https://www.winehq.org/docs/wineusr-guide/cui-programs - -If built without line editing and history capabilities -(MICROPY_USE_READLINE=0), the resulting binary can be run using the standard -"wine" tool. diff --git a/windows/README.md b/windows/README.md new file mode 100644 index 000000000..6d3249903 --- /dev/null +++ b/windows/README.md @@ -0,0 +1,74 @@ +This is the experimental, community-supported Windows port of MicroPython. +It is based on Unix port, and expected to remain so. +The port requires additional testing, debugging, and patches. Please +consider to contribute. + + +Building on Debian/Ubuntu Linux system +--------------------------------------- + + sudo apt-get install gcc-mingw-w64 + make CROSS_COMPILE=i686-w64-mingw32- + +If for some reason the mingw-w64 crosscompiler is not available, you can try +mingw32 instead, but it comes with a really old gcc which may produce some +spurious errors (you may need to disable -Werror): + + sudo apt-get install mingw32 mingw32-binutils mingw32-runtime + make CROSS_COMPILE=i586-mingw32msvc- + + +Building under Cygwin +--------------------- + +Install following packages using cygwin's setup.exe: + +* mingw64-i686-gcc-core +* mingw64-x86_64-gcc-core +* make + +Build using: + + make CROSS_COMPILE=i686-w64-mingw32- + +Or for 64bit: + + make CROSS_COMPILE=x86_64-w64-mingw32- + + +Building using MS Visual Studio 2013 (or higher) +------------------------------------------------ + +In the IDE, open `micropython.vcxproj` and build. + +To build from the command line: + + msbuild micropython.vcxproj + +__Stack usage__ + +The msvc compiler is quite stack-hungry which might result in a "maximum recursion depth exceeded" +RuntimeError for code with lots of nested function calls. +There are several ways to deal with this: +- increase the threshold used for detection by altering the argument to `mp_stack_set_limit` in `unix/main.c` +- disable detection all together by setting `MICROPY_STACK_CHECK` to "0" in `windows/mpconfigport.h` +- disable the /GL compiler flag by setting `WholeProgramOptimization` to "false" + +See [issue 2927](https://github.com/micropython/micropython/issues/2927) for more information. + + +Running on Linux using Wine +--------------------------- + +The default build (MICROPY_USE_READLINE=1) uses extended Windows console +functions and thus should be ran using the `wineconsole` tool. Depending +on the Wine build configuration, you may also want to select the curses +backend which has the look&feel of a standard Unix console: + + wineconsole --backend=curses ./micropython.exe + +For more info, see https://www.winehq.org/docs/wineusr-guide/cui-programs . + +If built without line editing and history capabilities +(MICROPY_USE_READLINE=0), the resulting binary can be run using the standard +`wine` tool. diff --git a/windows/micropython.vcxproj b/windows/micropython.vcxproj index 6f6e11ab4..ee0b98abb 100644 --- a/windows/micropython.vcxproj +++ b/windows/micropython.vcxproj @@ -26,26 +26,26 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset> <CharacterSet>MultiByte</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset> <WholeProgramOptimization>true</WholeProgramOptimization> <CharacterSet>MultiByte</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset> <CharacterSet>MultiByte</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset> <WholeProgramOptimization>true</WholeProgramOptimization> <CharacterSet>MultiByte</CharacterSet> </PropertyGroup> diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h index 6156ad39e..8cef50671 100644 --- a/windows/mpconfigport.h +++ b/windows/mpconfigport.h @@ -32,17 +32,20 @@ #endif #define MICROPY_ALLOC_PATH_MAX (260) //see minwindef.h for msvc or limits.h for mingw +#define MICROPY_PERSISTENT_CODE_LOAD (1) #define MICROPY_EMIT_X64 (0) #define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_COMP_MODULE_CONST (1) #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1) +#define MICROPY_COMP_RETURN_IF_EXPR (1) #define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_FINALISER (1) #define MICROPY_STACK_CHECK (1) #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1) #define MICROPY_MEM_STATS (1) #define MICROPY_DEBUG_PRINTERS (1) +#define MICROPY_DEBUG_PRINTER_DEST mp_stderr_print #define MICROPY_READER_POSIX (1) #define MICROPY_USE_READLINE_HISTORY (1) #define MICROPY_HELPER_REPL (1) @@ -59,11 +62,14 @@ #define MICROPY_PY_FUNCTION_ATTRS (1) #define MICROPY_PY_DESCRIPTORS (1) #define MICROPY_PY_BUILTINS_STR_UNICODE (1) +#define MICROPY_PY_BUILTINS_STR_CENTER (1) +#define MICROPY_PY_BUILTINS_STR_PARTITION (1) #define MICROPY_PY_BUILTINS_STR_SPLITLINES (1) #define MICROPY_PY_BUILTINS_MEMORYVIEW (1) #define MICROPY_PY_BUILTINS_FROZENSET (1) #define MICROPY_PY_BUILTINS_COMPILE (1) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) +#define MICROPY_PY_BUILTINS_POW3 (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_ALL_SPECIAL_METHODS (1) #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) @@ -83,27 +89,35 @@ #define MICROPY_STACKLESS (0) #define MICROPY_STACKLESS_STRICT (0) +#define MICROPY_PY_UTIME (1) +#define MICROPY_PY_UTIME_MP_HAL (1) #define MICROPY_PY_UERRNO (1) #define MICROPY_PY_UCTYPES (1) #define MICROPY_PY_UZLIB (1) #define MICROPY_PY_UJSON (1) #define MICROPY_PY_URE (1) #define MICROPY_PY_UHEAPQ (1) +#define MICROPY_PY_UTIMEQ (1) #define MICROPY_PY_UHASHLIB (1) #define MICROPY_PY_UBINASCII (1) +#define MICROPY_PY_UBINASCII_CRC32 (1) #define MICROPY_PY_URANDOM (1) -#define MICROPY_PY_UTIME (1) -#define MICROPY_PY_UTIME_MP_HAL (1) #define MICROPY_PY_MACHINE (1) +#define MICROPY_PY_MACHINE_PULSE (1) +#define MICROPY_MACHINE_MEM_GET_READ_ADDR mod_machine_mem_get_addr +#define MICROPY_MACHINE_MEM_GET_WRITE_ADDR mod_machine_mem_get_addr #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) #define MICROPY_WARNINGS (1) +#define MICROPY_PY_STR_BYTES_CMP_WARN (1) + #ifdef _MSC_VER #define MICROPY_GCREGS_SETJMP (1) #endif #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1) #define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (256) +#define MICROPY_KBD_EXCEPTION (1) #define MICROPY_PORT_INIT_FUNC init() #define MICROPY_PORT_DEINIT_FUNC deinit() @@ -128,8 +142,6 @@ typedef int mp_int_t; // must be pointer size typedef unsigned int mp_uint_t; // must be pointer size #endif -#define BYTES_PER_WORD sizeof(mp_int_t) - // Just assume Windows is little-endian - mingw32 gcc doesn't // define standard endianness macros. #define MP_ENDIANNESS_LITTLE (1) @@ -163,8 +175,7 @@ extern const struct _mp_obj_module_t mp_module_time; #if MICROPY_USE_READLINE == 1 #define MICROPY_PORT_ROOT_POINTERS \ - char *readline_hist[50]; \ - mp_obj_t keyboard_interrupt_obj; + char *readline_hist[50]; #endif #define MP_STATE_PORT MP_STATE_VM diff --git a/windows/msvc/debug.props b/windows/msvc/debug.props index c0a22be85..fa1ca4fcb 100644 --- a/windows/msvc/debug.props +++ b/windows/msvc/debug.props @@ -4,10 +4,6 @@ <PropertyGroup Label="UserMacros" /> <PropertyGroup> </PropertyGroup> - <ItemDefinitionGroup> - <ClCompile> - <PreprocessorDefinitions>DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ClCompile> - </ItemDefinitionGroup> + <ItemDefinitionGroup /> <ItemGroup /> -</Project> +</Project>
\ No newline at end of file diff --git a/windows/msvc/genhdr.targets b/windows/msvc/genhdr.targets index 8c2ba8eb2..cac3e3ddc 100644 --- a/windows/msvc/genhdr.targets +++ b/windows/msvc/genhdr.targets @@ -43,8 +43,13 @@ using(var outFile = System.IO.File.CreateText(OutputFile)) { </Task> </UsingTask> + <!-- If any of these changed we'll force all qstrs to be generated again--> + <ItemGroup> + <QstrDependencies Include="$(PyWinDir)mpconfigport.h;$(PySrcDir)mpconfig.h;$(PySrcDir)makeqstrdata.py"/> + </ItemGroup> + <!-- Preprocess changed files, concatenate and feed into makeqstrdefs.py split/cat--> - <Target Name="MakeQstrDefs" DependsOnTargets="MakeDestDir" Inputs="@(ClCompile)" Outputs="$(QstrDefsCollected)"> + <Target Name="MakeQstrDefs" DependsOnTargets="MakeDestDir" Inputs="@(ClCompile);@(QstrDependencies)" Outputs="$(QstrDefsCollected)"> <ItemGroup> <PyIncDirs Include="$(PyIncDirs)"/> <PreProcDefs Include="%(ClCompile.PreProcessorDefinitions);NO_QSTR;N_X64;N_X86;N_THUMB;N_ARM"/> @@ -56,15 +61,22 @@ using(var outFile = System.IO.File.CreateText(OutputFile)) { <OutDir>$([System.IO.Path]::GetDirectoryName('%(OutFile)'))</OutDir> </PyQstrSourceFiles> <PyQstrSourceFiles> - <Changed>$([System.DateTime]::Compare($([System.IO.File]::GetLastWriteTime('%(FullPath)')), $([System.IO.File]::GetLastWriteTime('%(OutFile)'))))</Changed> + <Changed Condition="$([System.DateTime]::Compare($([System.IO.File]::GetLastWriteTime('%(FullPath)')), $([System.IO.File]::GetLastWriteTime('%(OutFile)')))) > 0">True</Changed> </PyQstrSourceFiles> + <QstrDependencies> + <Changed Condition="$([System.DateTime]::Compare($([System.IO.File]::GetLastWriteTime('%(FullPath)')), $([System.IO.File]::GetLastWriteTime('$(DestDir)qstr.i.last')))) > 0">True</Changed> + </QstrDependencies> </ItemGroup> + <PropertyGroup> + <ForceQstrRebuild>@(QstrDependencies->AnyHaveMetadataValue('Changed', 'True'))</ForceQstrRebuild> + <RunPreProcConcat>@(PyQstrSourceFiles->AnyHaveMetadataValue('Changed', 'True'))</RunPreProcConcat> + </PropertyGroup> <MakeDir Directories="@(PyQstrSourceFiles->'%(OutDir)')"/> <Exec Command="cl /nologo /I@(PyIncDirs, ' /I') /D@(PreProcDefs, ' /D') /Fi%(PyQstrSourceFiles.OutFile) /P %(PyQstrSourceFiles.Identity)" - Condition="%(PyQstrSourceFiles.Changed) > 0"/> + Condition="'%(PyQstrSourceFiles.Changed)' == 'True' Or '$(ForceQstrRebuild)' == 'True'"/> <ConcatPreProcFiles InputFiles="@(PyQstrSourceFiles->'%(OutFile)')" OutputFile="$(DestDir)qstr.i.last" - Condition="%(PyQstrSourceFiles.Changed) > 0"/> + Condition="'$(RunPreProcConcat)' == 'True' Or '$(ForceQstrRebuild)' == 'True'"/> <Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py split $(DestDir)qstr.i.last $(DestDir)qstr $(QstrDefsCollected)"/> <Exec Command="$(PyPython) $(PySrcDir)makeqstrdefs.py cat $(DestDir)qstr.i.last $(DestDir)qstr $(QstrDefsCollected)"/> </Target> @@ -87,6 +99,10 @@ using(var outFile = System.IO.File.CreateText(OutputFile)) { <MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="CopyFileIfDifferent" Properties="SourceFile=$(TmpFile);DestFile=$(DestFile)"/> </Target> + <Target Name="RemoveGeneratedFiles" AfterTargets="Clean"> + <RemoveDir Directories="$(DestDir)"/> + </Target> + <!--Copies SourceFile to DestFile only if SourceFile's content differs from DestFile's. We use this to 'touch' the generated files only when they are really newer so a build is only triggered if the generated content actually changed, diff --git a/windows/msvc/sources.props b/windows/msvc/sources.props index 4ea917552..a97686cdc 100644 --- a/windows/msvc/sources.props +++ b/windows/msvc/sources.props @@ -15,6 +15,8 @@ <ClCompile Include="$(PyBaseDir)unix\modmachine.c" /> <ClCompile Include="$(PyBaseDir)extmod\machine_mem.c" /> <ClCompile Include="$(PyBaseDir)extmod\machine_pinbase.c" /> + <ClCompile Include="$(PyBaseDir)extmod\machine_pulse.c" /> + <ClCompile Include="$(PyBaseDir)extmod\machine_signal.c" /> <ClCompile Include="$(PyBaseDir)extmod\modubinascii.c" /> <ClCompile Include="$(PyBaseDir)extmod\moductypes.c" /> <ClCompile Include="$(PyBaseDir)extmod\moduhashlib.c" /> @@ -22,8 +24,10 @@ <ClCompile Include="$(PyBaseDir)extmod\modujson.c" /> <ClCompile Include="$(PyBaseDir)extmod\modurandom.c" /> <ClCompile Include="$(PyBaseDir)extmod\modure.c" /> + <ClCompile Include="$(PyBaseDir)extmod\modutimeq.c" /> <ClCompile Include="$(PyBaseDir)extmod\moduzlib.c" /> <ClCompile Include="$(PyBaseDir)extmod\utime_mphal.c" /> + <ClCompile Include="$(PyBaseDir)extmod\virtpin.c" /> </ItemGroup> <ItemGroup> <ClInclude Include="$(PyBaseDir)py\*.h" /> diff --git a/windows/windows_mphal.c b/windows/windows_mphal.c index 3ad693905..1dd3105d8 100644 --- a/windows/windows_mphal.c +++ b/windows/windows_mphal.c @@ -79,12 +79,12 @@ void mp_hal_stdio_mode_orig(void) { // the thread created for handling it might not be running yet so we'd miss the notification. BOOL WINAPI console_sighandler(DWORD evt) { if (evt == CTRL_C_EVENT) { - if (MP_STATE_VM(mp_pending_exception) == MP_STATE_VM(keyboard_interrupt_obj)) { + if (MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) { // this is the second time we are called, so die straight away exit(1); } - mp_obj_exception_clear_traceback(MP_STATE_VM(keyboard_interrupt_obj)); - MP_STATE_VM(mp_pending_exception) = MP_STATE_VM(keyboard_interrupt_obj); + mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))); + MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)); return TRUE; } return FALSE; |