From 7b3cac440b91d5ff687f5751b2450f6a1bbe11a5 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 25 Aug 2020 05:03:29 +0200 Subject: [PATCH] bpo-41630: Build _curses and _curses_panel using Visual Studio --- .../2020-08-25-06-17-50.bpo-41630.-0ymGh.rst | 1 + Modules/_cursesmodule.c | 5 +- PCbuild/_curses.vcxproj | 115 ++++++++++ PCbuild/_curses.vcxproj.filters | 29 +++ PCbuild/_curses_panel.vcxproj | 115 ++++++++++ PCbuild/_curses_panel.vcxproj.filters | 29 +++ PCbuild/build.bat | 4 + PCbuild/get_externals.bat | 12 +- PCbuild/ncurses.props | 21 ++ PCbuild/ncurses_panel.props | 21 ++ PCbuild/pcbuild.proj | 3 + PCbuild/pcbuild.sln | 60 +++++ PCbuild/prepare_libffi.bat | 8 +- PCbuild/prepare_ncurses.bat | 205 ++++++++++++++++++ PCbuild/python.props | 3 + 15 files changed, 625 insertions(+), 6 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2020-08-25-06-17-50.bpo-41630.-0ymGh.rst create mode 100644 PCbuild/_curses.vcxproj create mode 100644 PCbuild/_curses.vcxproj.filters create mode 100644 PCbuild/_curses_panel.vcxproj create mode 100644 PCbuild/_curses_panel.vcxproj.filters create mode 100644 PCbuild/ncurses.props create mode 100644 PCbuild/ncurses_panel.props create mode 100644 PCbuild/prepare_ncurses.bat diff --git a/Misc/NEWS.d/next/Build/2020-08-25-06-17-50.bpo-41630.-0ymGh.rst b/Misc/NEWS.d/next/Build/2020-08-25-06-17-50.bpo-41630.-0ymGh.rst new file mode 100644 index 000000000000000..050021f970f378a --- /dev/null +++ b/Misc/NEWS.d/next/Build/2020-08-25-06-17-50.bpo-41630.-0ymGh.rst @@ -0,0 +1 @@ +Build _curses and _curses_panel using Visual Studio. \ No newline at end of file diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 34331017f85c7b9..f570851eba2abba 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -104,6 +104,9 @@ static const char PyCursesVersion[] = "2.2"; #include "Python.h" +#if defined(MS_WINDOWS) +#include +#endif #ifdef __hpux #define STRICT_SYSV_CURSES @@ -654,7 +657,7 @@ PyCursesWindow_New(WINDOW *win, const char *encoding) if (encoding == NULL) { #if defined(MS_WINDOWS) - char *buffer[100]; + char buffer[100]; UINT cp; cp = GetConsoleOutputCP(); if (cp != 0) { diff --git a/PCbuild/_curses.vcxproj b/PCbuild/_curses.vcxproj new file mode 100644 index 000000000000000..fe9e9dfd444ef23 --- /dev/null +++ b/PCbuild/_curses.vcxproj @@ -0,0 +1,115 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + PGInstrument + ARM + + + PGInstrument + ARM64 + + + PGInstrument + Win32 + + + PGInstrument + x64 + + + PGUpdate + ARM + + + PGUpdate + ARM64 + + + PGUpdate + Win32 + + + PGUpdate + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {84DA5419-2E88-4BFA-8C08-D4944C022F37} + _curses + Win32Proj + + + + + DynamicLibrary + NotSet + + + + .pyd + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + + + + HAVE_NCURSES_H;%(PreprocessorDefinitions) + + + + + + + + + + + + + + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + + + + \ No newline at end of file diff --git a/PCbuild/_curses.vcxproj.filters b/PCbuild/_curses.vcxproj.filters new file mode 100644 index 000000000000000..4853a2662a7ea8e --- /dev/null +++ b/PCbuild/_curses.vcxproj.filters @@ -0,0 +1,29 @@ + + + + + {806081ee-2af0-48d0-a83e-ee02a74baa0f} + + + {dbdea1f2-ad8b-44ca-b782-fcf65d91559b} + + + {31a37bb4-c384-41ff-9ec1-8ad98d482e22} + + + + + Header Files + + + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/PCbuild/_curses_panel.vcxproj b/PCbuild/_curses_panel.vcxproj new file mode 100644 index 000000000000000..b599c1717109af9 --- /dev/null +++ b/PCbuild/_curses_panel.vcxproj @@ -0,0 +1,115 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + PGInstrument + ARM + + + PGInstrument + ARM64 + + + PGInstrument + Win32 + + + PGInstrument + x64 + + + PGUpdate + ARM + + + PGUpdate + ARM64 + + + PGUpdate + Win32 + + + PGUpdate + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE} + _curses_panel + Win32Proj + + + + + DynamicLibrary + NotSet + + + + .pyd + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + + + + HAVE_NCURSES_H;%(PreprocessorDefinitions) + + + + + + + + + + + + + + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + + + + \ No newline at end of file diff --git a/PCbuild/_curses_panel.vcxproj.filters b/PCbuild/_curses_panel.vcxproj.filters new file mode 100644 index 000000000000000..df923c3c201b4a1 --- /dev/null +++ b/PCbuild/_curses_panel.vcxproj.filters @@ -0,0 +1,29 @@ + + + + + {806081ee-2af0-48d0-a83e-ee02a74baa0f} + + + {dbdea1f2-ad8b-44ca-b782-fcf65d91559b} + + + {31a37bb4-c384-41ff-9ec1-8ad98d482e22} + + + + + Header Files + + + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/PCbuild/build.bat b/PCbuild/build.bat index ba7154d8cb1e56a..9360806153b28b8 100644 --- a/PCbuild/build.bat +++ b/PCbuild/build.bat @@ -39,6 +39,7 @@ echo. echo.Available flags to avoid building certain modules. echo.These flags have no effect if '-e' is not given: echo. --no-ctypes Do not attempt to build _ctypes +echo. --no-curses Do not attempt to build _curses and _curses_panel echo. --no-ssl Do not attempt to build _ssl echo. --no-tkinter Do not attempt to build Tkinter echo. @@ -89,11 +90,13 @@ rem anyway for visibility so set defaults after this if "%~1"=="-e" (set IncludeExternals=true) & shift & goto CheckOpts if "%~1"=="-E" (set IncludeExternals=false) & shift & goto CheckOpts if "%~1"=="--no-ctypes" (set IncludeCTypes=false) & shift & goto CheckOpts +if "%~1"=="--no-ccurses" (set IncludeCurses=false) & shift & goto CheckOpts if "%~1"=="--no-ssl" (set IncludeSSL=false) & shift & goto CheckOpts if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts if "%IncludeExternals%"=="" set IncludeExternals=true if "%IncludeCTypes%"=="" set IncludeCTypes=true +if "%IncludeCurses%"=="" set IncludeCurses=true if "%IncludeSSL%"=="" set IncludeSSL=true if "%IncludeTkinter%"=="" set IncludeTkinter=true @@ -156,6 +159,7 @@ echo on /p:Configuration=%conf% /p:Platform=%platf%^ /p:IncludeExternals=%IncludeExternals%^ /p:IncludeCTypes=%IncludeCTypes%^ + /p:IncludeCurses=%IncludeCurses%^ /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^ /p:UseTestMarker=%UseTestMarker% %GITProperty%^ %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/PCbuild/get_externals.bat b/PCbuild/get_externals.bat index a48b59cad2ed1c1..7687cbd80debc8d 100644 --- a/PCbuild/get_externals.bat +++ b/PCbuild/get_externals.bat @@ -8,6 +8,7 @@ if NOT DEFINED EXTERNALS_DIR (set EXTERNALS_DIR=%PCBUILD%\..\externals) set DO_FETCH=true set DO_CLEAN=false set IncludeLibffiSrc=false +set IncludeNCursesSrc=false set IncludeTkinterSrc=false set IncludeSSLSrc=false @@ -18,6 +19,7 @@ if "%~1"=="--no-libffi" (set IncludeLibffi=false) & shift & goto CheckOpts if "%~1"=="--tkinter-src" (set IncludeTkinterSrc=true) & shift & goto CheckOpts if "%~1"=="--openssl-src" (set IncludeSSLSrc=true) & shift & goto CheckOpts if "%~1"=="--libffi-src" (set IncludeLibffiSrc=true) & shift & goto CheckOpts +if "%~1"=="--ncurses-src" (set IncludeNCursesSrc=true) & shift & goto CheckOpts if "%~1"=="--python" (set PYTHON=%2) & shift & shift & goto CheckOpts if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts @@ -53,6 +55,7 @@ echo.Fetching external libraries... set libraries= set libraries=%libraries% bzip2-1.0.6 if NOT "%IncludeLibffiSrc%"=="false" set libraries=%libraries% libffi +if NOT "%IncludeNCursesSrc%"=="false" set libraries=%libraries% ncurses if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-1.1.1g set libraries=%libraries% sqlite-3.32.3.0 if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-core-8.6.9.0 @@ -76,10 +79,11 @@ for %%e in (%libraries%) do ( echo.Fetching external binaries... set binaries= -if NOT "%IncludeLibffi%"=="false" set binaries=%binaries% libffi -if NOT "%IncludeSSL%"=="false" set binaries=%binaries% openssl-bin-1.1.1g -if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-8.6.9.0 -if NOT "%IncludeSSLSrc%"=="false" set binaries=%binaries% nasm-2.11.06 +if NOT "%IncludeLibffi%"=="false" set binaries=%binaries% libffi +if NOT "%IncludeNCurses%"=="false" set binaries=%binaries% ncurses +if NOT "%IncludeSSL%"=="false" set binaries=%binaries% openssl-bin-1.1.1g +if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-8.6.9.0 +if NOT "%IncludeSSLSrc%"=="false" set binaries=%binaries% nasm-2.11.06 for %%b in (%binaries%) do ( if exist "%EXTERNALS_DIR%\%%b" ( diff --git a/PCbuild/ncurses.props b/PCbuild/ncurses.props new file mode 100644 index 000000000000000..79acbec48995321 --- /dev/null +++ b/PCbuild/ncurses.props @@ -0,0 +1,21 @@ + + + + + $(ncursesIncludeDir);%(AdditionalIncludeDirectories) + + + $(ncursesOutDir);%(AdditionalLibraryDirectories) + ncursesw.dll.lib;%(AdditionalDependencies) + + + + <_NCURSESDLL Include="$(ncursesOutDir)\ncursesw6.dll" /> + + + + + + + + \ No newline at end of file diff --git a/PCbuild/ncurses_panel.props b/PCbuild/ncurses_panel.props new file mode 100644 index 000000000000000..a8bc82b547c17eb --- /dev/null +++ b/PCbuild/ncurses_panel.props @@ -0,0 +1,21 @@ + + + + + $(ncursesIncludeDir);%(AdditionalIncludeDirectories) + + + $(ncursesOutDir);%(AdditionalLibraryDirectories) + panelw.dll.lib;ncursesw.dll.lib;%(AdditionalDependencies) + + + + <_PANELDLL Include="$(ncursesOutDir)\panelw6.dll" /> + + + + + + + + \ No newline at end of file diff --git a/PCbuild/pcbuild.proj b/PCbuild/pcbuild.proj index 4d416c589e4c47e..679b1683fb1fdc5 100644 --- a/PCbuild/pcbuild.proj +++ b/PCbuild/pcbuild.proj @@ -8,6 +8,7 @@ true true true + true true true false @@ -53,6 +54,8 @@ + + diff --git a/PCbuild/pcbuild.sln b/PCbuild/pcbuild.sln index 4b6dc1e6771dc3d..577f8302522621b 100644 --- a/PCbuild/pcbuild.sln +++ b/PCbuild/pcbuild.sln @@ -107,6 +107,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonw_uwp", "pythonw_uwp. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_uuid", "_uuid.vcxproj", "{CB435430-EBB1-478B-8F4E-C256F6838F55}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_curses", "_curses.vcxproj", "{84DA5419-2E88-4BFA-8C08-D4944C022F37}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_curses_panel", "_curses_panel.vcxproj", "{A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -1508,6 +1512,62 @@ Global {CB435430-EBB1-478B-8F4E-C256F6838F55}.Release|Win32.Build.0 = Release|Win32 {CB435430-EBB1-478B-8F4E-C256F6838F55}.Release|x64.ActiveCfg = Release|x64 {CB435430-EBB1-478B-8F4E-C256F6838F55}.Release|x64.Build.0 = Release|x64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Debug|ARM.ActiveCfg = Debug|ARM + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Debug|Win32.ActiveCfg = Debug|Win32 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Debug|Win32.Build.0 = Debug|Win32 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Debug|x64.ActiveCfg = Debug|x64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Debug|x64.Build.0 = Debug|x64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGInstrument|ARM.ActiveCfg = Release|ARM + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGInstrument|ARM.Build.0 = Release|ARM + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGInstrument|ARM64.ActiveCfg = Release|ARM64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGInstrument|ARM64.Build.0 = Release|ARM64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGInstrument|Win32.ActiveCfg = Release|Win32 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGInstrument|Win32.Build.0 = Release|Win32 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGInstrument|x64.ActiveCfg = Release|x64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGInstrument|x64.Build.0 = Release|x64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGUpdate|ARM.ActiveCfg = Release|ARM + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGUpdate|ARM.Build.0 = Release|ARM + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGUpdate|ARM64.ActiveCfg = Release|ARM64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGUpdate|ARM64.Build.0 = Release|ARM64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGUpdate|Win32.ActiveCfg = Release|Win32 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGUpdate|Win32.Build.0 = Release|Win32 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGUpdate|x64.ActiveCfg = Release|x64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.PGUpdate|x64.Build.0 = Release|x64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Release|ARM.ActiveCfg = Release|ARM + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Release|ARM64.ActiveCfg = Release|ARM64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Release|Win32.ActiveCfg = Release|Win32 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Release|Win32.Build.0 = Release|Win32 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Release|x64.ActiveCfg = Release|x64 + {84DA5419-2E88-4BFA-8C08-D4944C022F37}.Release|x64.Build.0 = Release|x64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Debug|ARM.ActiveCfg = Debug|ARM + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Debug|Win32.ActiveCfg = Debug|Win32 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Debug|Win32.Build.0 = Debug|Win32 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Debug|x64.ActiveCfg = Debug|x64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Debug|x64.Build.0 = Debug|x64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGInstrument|ARM.ActiveCfg = Release|ARM + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGInstrument|ARM.Build.0 = Release|ARM + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGInstrument|ARM64.ActiveCfg = Release|ARM64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGInstrument|ARM64.Build.0 = Release|ARM64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGInstrument|Win32.ActiveCfg = Release|Win32 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGInstrument|Win32.Build.0 = Release|Win32 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGInstrument|x64.ActiveCfg = Release|x64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGInstrument|x64.Build.0 = Release|x64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGUpdate|ARM.ActiveCfg = Release|ARM + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGUpdate|ARM.Build.0 = Release|ARM + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGUpdate|ARM64.ActiveCfg = Release|ARM64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGUpdate|ARM64.Build.0 = Release|ARM64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGUpdate|Win32.ActiveCfg = Release|Win32 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGUpdate|Win32.Build.0 = Release|Win32 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGUpdate|x64.ActiveCfg = Release|x64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.PGUpdate|x64.Build.0 = Release|x64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Release|ARM.ActiveCfg = Release|ARM + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Release|ARM64.ActiveCfg = Release|ARM64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Release|Win32.ActiveCfg = Release|Win32 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Release|Win32.Build.0 = Release|Win32 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Release|x64.ActiveCfg = Release|x64 + {A22F1610-1D53-43C2-9EDC-7CB5D1E1F3CE}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PCbuild/prepare_libffi.bat b/PCbuild/prepare_libffi.bat index f41ba83379af961..b9741c00551dbd5 100644 --- a/PCbuild/prepare_libffi.bat +++ b/PCbuild/prepare_libffi.bat @@ -47,7 +47,7 @@ if /I "%1"=="-x86" (set BUILD_X86=1) & shift & goto :CheckOpts if /I "%1"=="-arm32" (set BUILD_ARM32=1) & shift & goto :CheckOpts if /I "%1"=="-arm64" (set BUILD_ARM64=1) & shift & goto :CheckOpts if /I "%1"=="-pdb" (set BUILD_PDB=-g) & shift & goto :CheckOpts -if /I "%1"=="-noopt" (set BUILD_NOOPT=CFLAGS='-Od -warn all') & shift & goto :CheckOpts +if /I "%1"=="-noopt" (set BUILD_NOOPT=1) & shift & goto :CheckOpts if /I "%1"=="-?" goto :Usage if /I "%1"=="--install-cygwin" (set INSTALL_CYGWIN=1) & shift & goto :CheckOpts goto :Usage @@ -61,6 +61,12 @@ if NOT DEFINED BUILD_X64 if NOT DEFINED BUILD_X86 if NOT DEFINED BUILD_ARM32 if set BUILD_ARM64=1 ) +if DEFINED BUILD_NOOPT ( + set OPTFLAGS=-O0 +) else ( + set OPTFLAGS=-O2 -Ob2 +) + if "%INSTALL_CYGWIN%"=="1" call :InstallCygwin setlocal diff --git a/PCbuild/prepare_ncurses.bat b/PCbuild/prepare_ncurses.bat new file mode 100644 index 000000000000000..25ea684a67b18a2 --- /dev/null +++ b/PCbuild/prepare_ncurses.bat @@ -0,0 +1,205 @@ +@echo off +goto :Run + +:Usage +echo. +echo Before running prepare_ncurses.bat +echo NCURSES_SOURCE environment variable must be set to the location of +echo of python-source-deps clone of ncurses branch +echo VCVARSALL must be set to location of vcvarsall.bat +echo cygwin must be installed (see below) +echo SH environment variable must be set to the location of sh.exe +echo. +echo Tested with cygwin-x86 from https://www.cygwin.com/install.html +echo Select http://mirrors.kernel.org as the download site +echo Include the following cygwin packages in cygwin configuration: +echo awk cat chmod date make rm sed +echo. +echo Based on https://github.com/conan-io/conan-center-index/blob/master/recipes/ncurses/all/conanfile.py +echo. +echo.Available flags: +echo. -x64 build for x64 +echo. -x86 build for x86 +echo. -arm32 build for arm32 +echo. -arm64 build for arm64 +echo. -? this help +echo. --install-cygwin install cygwin to c:\cygwin +exit /b 127 + +:Run + +set BUILD_X64= +set BUILD_X86= +set BUILD_ARM32= +set BUILD_ARM64= +set BUILD_PDB= +set BUILD_NOOPT= +set INSTALL_CYGWIN= + +:CheckOpts +if "%1"=="" goto :CheckOptsDone +if /I "%1"=="-x64" (set BUILD_X64=1) & shift & goto :CheckOpts +if /I "%1"=="-x86" (set BUILD_X86=1) & shift & goto :CheckOpts +if /I "%1"=="-arm32" (set BUILD_ARM32=1) & shift & goto :CheckOpts +if /I "%1"=="-arm64" (set BUILD_ARM64=1) & shift & goto :CheckOpts +if /I "%1"=="-pdb" (set BUILD_PDB=-debug) & shift & goto :CheckOpts +if /I "%1"=="-noopt" (set BUILD_NOOPT=1) & shift & goto :CheckOpts +if /I "%1"=="-?" goto :Usage +if /I "%1"=="--install-cygwin" (set INSTALL_CYGWIN=1) & shift & goto :CheckOpts +goto :Usage + +:CheckOptsDone + +if NOT DEFINED BUILD_X64 if NOT DEFINED BUILD_X86 if NOT DEFINED BUILD_ARM32 if NOT DEFINED BUILD_ARM64 ( + set BUILD_X64=1 + set BUILD_X86=1 + set BUILD_ARM32=1 + set BUILD_ARM64=1 +) + +if DEFINED BUILD_NOOPT ( + set OPTCFLAGS=-O0 +) else ( + set OPTCFLAGS=-O2 -Ob2 +) + +if DEFINED BUILD_PDB ( + set OPTCFLAGS=%OPTCFLAGS% -debug -MDd + set OPTLDFLAGS=-debug -pdb +) else ( + set OPTCFLAGS=%OPTCFLAGS -MD +) + +if "%INSTALL_CYGWIN%"=="1" call :InstallCygwin + +setlocal +if NOT DEFINED SH if exist c:\cygwin\bin\sh.exe set SH=c:\cygwin\bin\sh.exe + +if NOT DEFINED VCVARSALL ( + if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ( + set VCVARSALL="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" + ) else ( + echo VCVARSALL could not be auto-detected. Please define it. + exit /b 127 + ) +) +if ^%VCVARSALL:~0,1% NEQ ^" SET VCVARSALL="%VCVARSALL%" + +if NOT DEFINED NCURSES_SOURCE echo.&&echo ERROR NCURSES_SOURCE environment variable not set && goto :Usage +if NOT DEFINED SH echo ERROR SH environment variable not set && goto :Usage + +if not exist %SH% echo ERROR %SH% does not exist && goto :Usage +if not exist %NCURSES_SOURCE% echo ERROR %NCURSES_SOURCE% does not exist && goto :Usage + +pushd %NCURSES_SOURCE% + +%SH% --login -lc "cygcheck -dc cygwin" + +echo. +echo VCVARSALL : %VCVARSALL% +echo SH : %SH% +echo NCURSES_SOURCE: %NCURSES_SOURCE% +echo. + +if "%BUILD_X64%"=="1" call :BuildOne x64 x86_64-w64-mingw32-msvc7 x86_64-w64-mingw32-msvc7 +if "%BUILD_X86%"=="1" call :BuildOne x86 i686-pc-mingw32-msvc7 i686-pc-mingw32-msvc7 +if "%BUILD_ARM32%"=="1" call :BuildOne x86_arm i686-pc-mingw32-msvc7 arm-w32-mingw32-msvc7 +if "%BUILD_ARM64%"=="1" call :BuildOne x86_arm64 i686-pc-mingw32-msvc7 aarch64-w64-mingw32-msvc7 + +popd +endlocal +exit /b 0 +REM all done + + +REM this subroutine is called once for each architecture +:BuildOne + +setlocal + +REM Initialize variables +set VCVARS_PLATFORM=%1 +set BUILD=%2 +set HOST=%3 +set ASSEMBLER= +set SRC_ARCHITECTURE=x86 + +if NOT DEFINED VCVARS_PLATFORM echo ERROR bad VCVARS_PLATFORM&&exit /b 123 + +if /I "%VCVARS_PLATFORM%" EQU "x64" ( + set ARCH=amd64 +) +if /I "%VCVARS_PLATFORM%" EQU "x86" ( + set ARCH=win32 +) +if /I "%VCVARS_PLATFORM%" EQU "x86_arm" ( + set ARCH=arm32 +) +if /I "%VCVARS_PLATFORM%" EQU "x86_arm64" ( + set ARCH=arm64 +) + +set BUILDDIR=%NCURSES_SOURCE%\%HOST% +md %BUILDDIR% + +if NOT DEFINED NCURSES_OUT set NCURSES_OUT=%~dp0\..\externals\ncurses +set _NCURSES_OUT=%NCURSES_OUT%\%ARCH% + +echo get VS build environment +call %VCVARSALL% %VCVARS_PLATFORM% + +echo clean %_NCURSES_OUT% +if exist %_NCURSES_OUT% (rd %_NCURSES_OUT% /s/q) + +echo ================================================================ +echo Configure the build +echo ================================================================ +%SH% -lc "(cd $BUILDDIR; sh ../configure CC='cl -nologo' CFLAGS='%OPTFLAGS%' LDFLAGS='%OPTLDFLAG%' AR='lib' LD='link -nologo' CPP='cl -nologo -EP' CPPFLAGS='' NM='dumpbin -symbols' RANLIB=':' STRIP=':' --enable-widec --disable-ext-colors --disable-reentrant --without-pcre2 --without-cxx-binding --without-progs --with-shared --without-normal --without-debug --without-tests --disable-macros --disable-termcap --enable-database --enable-sp-funcs --enable-term-driver --enable-interop ac_cv_func_getopt=yes --build=$BUILD --host=$HOST;)" +if errorlevel 1 exit /B %ERRORLEVEL% + +echo ================================================================ +echo Building ncurses +echo ================================================================ +%SH% -lc "(cd $BUILDDIR; make -j4;)" +if errorlevel 1 exit /B %ERRORLEVEL% + +REM Tests are not built because MSVC does not have getopt +REM Tests are not needed to produce artifacts +if "%NCURSES_TEST%" EQU "1" ( + echo "Running tests..." + %SH% -lc "(cd $BUILDDIR; make test;)" +) else ( + echo "Not running tests" +) + +echo copying files to %_NCURSES_OUT% +if not exist %_NCURSES_OUT%\include (md %_NCURSES_OUT%\include) +copy %NCURSES_SOURCE%/COPYING %NCURSES_OUT% +copy %BUILDDIR%\lib\ncursesw6.dll %_NCURSES_OUT% +copy %BUILDDIR%\lib\ncursesw.dll.lib %_NCURSES_OUT% +copy %BUILDDIR%\lib\panelw6.dll %_NCURSES_OUT% +copy %BUILDDIR%\lib\panelw.dll.lib %_NCURSES_OUT% +copy %BUILDDIR%\lib\menuw6.dll %_NCURSES_OUT% +copy %BUILDDIR%\lib\menuw.dll.lib %_NCURSES_OUT% +copy %BUILDDIR%\lib\formw6.dll %_NCURSES_OUT% +copy %BUILDDIR%\lib\formw.dll.lib %_NCURSES_OUT% +copy %BUILDDIR%\include\*.h %_NCURSES_OUT%\include +copy %BUILDDIR%\include\curses.h %_NCURSES_OUT%\include\ncurses.h + +endlocal +exit /b + +:InstallCygwin +setlocal + +if NOT DEFINED CYG_ROOT (set CYG_ROOT=c:/cygwin) +if NOT DEFINED CYG_CACHE (set CYG_CACHE=C:/cygwin/var/cache/setup) +if NOT DEFINED CYG_MIRROR (set CYG_MIRROR=http://mirrors.kernel.org/sourceware/cygwin/) + +powershell -c "md $env:CYG_ROOT -ErrorAction SilentlyContinue" +powershell -c "$setup = $env:CYG_ROOT+'/setup.exe'; if (!(Test-Path $setup)){invoke-webrequest https://cygwin.com/setup-x86.exe -outfile $setup} +%CYG_ROOT%/setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P make -P awk -P sed -P rm -P cat -P chmod -P date + +endlocal +exit /b + diff --git a/PCbuild/python.props b/PCbuild/python.props index 5f4926efa25172c..d3c50b0fa5808fc 100644 --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -66,6 +66,9 @@ $(ExternalsDir)openssl-bin-1.1.1g\$(ArchName)\ $(opensslOutDir)include $(ExternalsDir)\nasm-2.11.06\ + $(ExternalsDir)ncurses\ + $(ExternalsDir)ncurses\$(ArchName)\ + $(ncursesOutDir)include $(ExternalsDir)\zlib-1.2.11\