microsoft / php-sdk-binary-tools

Tool kit for building PHP under Windows
BSD 2-Clause "Simplified" License
271 stars 78 forks source link

Supporting multiple toolsets for a single VS installation #62

Closed nono303 closed 4 years ago

nono303 commented 5 years ago

Hi @weltling, I try to manage VC15 & VS16 php build with VS 2019 preview.

according to https://github.com/Microsoft/vswhere/issues/158 VS 2019 preview is only seen by vswhere as a prerelease... Also note that vswhere -nologo -version "[15,16)" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text -prerelease didn't return anything where vswhere -nologo -version 16 -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text -prerelease & vswhere -nologo -version 15 -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text -prerelease both correctly return the VS installation path ^^

Also, having the two version of the compiler tools (14.16 & 14.22) one the same VS 2019 preview instance, here is the way I've managed it with phpsdk_setshell.bat

diff --git "a/bin/phpsdk_setshell.bat" "b/bin/phpsdk_setshell.bat"
index 3d12e3b..248c872 100644
--- "a/bin/phpsdk_setshell.bat"
+++ "b/bin/phpsdk_setshell.bat"
@@ -84,8 +84,7 @@ if 15 gtr %PHP_SDK_VS_NUM% (
    rem build the version range, e.g. "[15,16)"
    set /a PHP_SDK_VS_RANGE=PHP_SDK_VS_NUM + 1
    set PHP_SDK_VS_RANGE="[%PHP_SDK_VS_NUM%,!PHP_SDK_VS_RANGE%!)"
-
-   for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
+   for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text -prerelease') do (
        set PHP_SDK_VC_DIR=%%b\VC
    )
    if not exist "!PHP_SDK_VC_DIR!" (
@@ -144,15 +143,15 @@ if 15 gtr %PHP_SDK_VS_NUM% (

 if /i "%PHP_SDK_ARCH%"=="x64" (
    if 15 gtr %PHP_SDK_VS_NUM% (
-       set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64
+       set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64 -vcvars_ver=%vcvars_ver%
    ) else (
-       set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" amd64
+       set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" amd64 -vcvars_ver=%vcvars_ver%
    )
 ) else (
    if 15 gtr %PHP_SDK_VS_NUM% (
-       set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86
+       set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86 -vcvars_ver=%vcvars_ver%
    ) else (
-       set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" x86
+       set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" x86 -vcvars_ver=%vcvars_ver%
    )
 )

where vcvars_ver is

For sure it may not be the good way to do it but this draft works ^^

cmb69 commented 5 years ago

Any particular reason why you use VS 2019 preview? Anyhow, VS 2019 preview works fine on AppVeyor with an unmodified php-sdk-2.2.0beta6, see https://ci.appveyor.com/project/derickr/xdebug/builds/25369672.

Supporting multiple toolsets for a single VS installation could be interesting.

nono303 commented 5 years ago

Any particular reason why you use VS 2019 preview?

preview (16.2.0p2) or not (16.1.3) doesn't change anything

Anyhow, VS 2019 preview works fine on AppVeyor with an unmodified php-sdk-2.2.0beta6, see https://ci.appveyor.com/project/derickr/xdebug/builds/25369672.

I agree... for vs16 build, not for vc15

Supporting multiple toolsets for a single VS installation could be interesting.

That's the point of my request ;)

weltling commented 5 years ago

@nono303 sure, that's a justified request, as a newer Visual Studio version still can use another toolset. Whereby we've recently moved to vs instead of vc, to refer to the default toolset in the given Visual Studio version. Doing this might be confusing in the future, but functionally it should be possible. @cmb, what do you think?

We have a little to no chance to come to an implementation in the close future. If someone can, we could at least have a better idea looking at a pull request. Please note though, that we have to keep the existing functionality unchanged.

Thanks.