php / php-sdk-binary-tools

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

Give users a chance to Input the path of `BuildTools\VC` #31

Open cchangwen opened 2 months ago

cchangwen commented 2 months ago

vswhere.exe return nothing If there is no complete installation of Visual Studio https://visualstudio.microsoft.com/visual-cpp-build-tools/

cmb69 commented 2 months ago

That worked fine for me a couple of years ago (see https://gist.github.com/cmb69/47b8c7fb392f5d79b245c74ac496632c).

Is it possible that you have the build tools for vs 17 installed (plus the MSVC v142 tools), but want to build for vs16? This is supported if you call phpsdk-starter.bat -c vs16 -a x64 -s 14.29 (i.e. you explicitly pass the -s option).

cchangwen commented 2 months ago

@cmb69 Just as you said.

phpsdk-vs16-x64.bat
Could not determine 'vs16' directory
phpsdk-starter.bat -c vs16 -a x64 -s 14.2
[vcvarsall.bat] Environment initialized for: 'x64'

PHP SDK 2.3.0

OS architecture:    x64
Build architecture: x64
Visual C++:         14.29.30154.0
PHP-SDK path:       d:\php-sdk-binary-tools-php-sdk-2.3.0
cchangwen commented 2 months ago

In some cases, vswhere. exe don't output valid information, causing all scripts that depend on it to not work properly. phpsdk_setshell.bat

cmb69 commented 2 months ago

Yes, this is a known issue. That part of detection is super strict and uses a range, to avoid finding another Visual Studio installation; this is important if you have multiple versions of Visual Studio installed. See also #29.

While offering the possibility to input the path manually (i.e. this PR) is certainly an option, I prefer to apply a local patch for easy of use (I start the php-sdk environments usually quite often).

Patch ````diff phpsdk-vc15-x64.bat | 2 +- phpsdk-vc15-x86.bat | 2 +- phpsdk-vs16-x64.bat | 2 +- phpsdk-vs16-x86.bat | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpsdk-vc15-x64.bat b/phpsdk-vc15-x64.bat index 5988bdb..12247b3 100755 --- a/phpsdk-vc15-x64.bat +++ b/phpsdk-vc15-x64.bat @@ -1,6 +1,6 @@ @echo off -call %~dp0phpsdk-starter.bat -c vc15 -a x64 %* +call %~dp0phpsdk-starter.bat -c vc15 -a x64 -s 14.16 %* exit /b %ERRORLEVEL% diff --git a/phpsdk-vc15-x86.bat b/phpsdk-vc15-x86.bat index 3721abe..468cbaf 100755 --- a/phpsdk-vc15-x86.bat +++ b/phpsdk-vc15-x86.bat @@ -1,6 +1,6 @@ @echo off -call %~dp0phpsdk-starter.bat -c vc15 -a x86 %* +call %~dp0phpsdk-starter.bat -c vc15 -a x86 -s 14.16 %* exit /b %ERRORLEVEL% diff --git a/phpsdk-vs16-x64.bat b/phpsdk-vs16-x64.bat index c0c58e4..07a1652 100755 --- a/phpsdk-vs16-x64.bat +++ b/phpsdk-vs16-x64.bat @@ -1,6 +1,6 @@ @echo off -call %~dp0phpsdk-starter.bat -c vs16 -a x64 %* +call %~dp0phpsdk-starter.bat -c vs16 -a x64 -s 14.29 %* exit /b %ERRORLEVEL% diff --git a/phpsdk-vs16-x86.bat b/phpsdk-vs16-x86.bat index 5162e0a..d6f07f6 100755 --- a/phpsdk-vs16-x86.bat +++ b/phpsdk-vs16-x86.bat @@ -1,6 +1,6 @@ @echo off -call %~dp0phpsdk-starter.bat -c vs16 -a x86 %* +call %~dp0phpsdk-starter.bat -c vs16 -a x86 -s 14.29 %* exit /b %ERRORLEVEL% ````