Skip to content

Commit d1036b5

Browse files
authored
Add support for toolset (#15)
1 parent 19c8ccb commit d1036b5

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

bin/phpsdk_setshell.bat

+18-5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ if "%PHP_SDK_ARCH%"=="" (
5555
goto out_error
5656
)
5757

58+
set TOOLSET=
59+
if NOT "%3"=="" SET TOOLSET=%3
60+
5861
rem check OS arch
5962
rem todo: allow user choose host sdk arch (i.e. x64 target can be compiled at x64(native) or x86(cross))
6063
for /f "usebackq tokens=1*" %%i in (`wmic cpu get Architecture /value /format:table ^| findstr /r "[1234567890][1234567890]*"`) do (
@@ -119,16 +122,18 @@ if 15 gtr %PHP_SDK_VS_NUM% (
119122
if /i "%PHP_SDK_OS_ARCH%"=="arm64" (
120123
set APPEND=ARM64
121124
)
122-
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -property installationPath -format text') do (
125+
set VS_VERSION_ARGS="-latest"
126+
if "%TOOLSET%"=="" set VS_VERSION_ARGS=-version !PHP_SDK_VS_RANGE!
127+
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo !VS_VERSION_ARGS! -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -property installationPath -format text') do (
123128
set PHP_SDK_VC_DIR=%%b\VC
124129
)
125130
if not exist "!PHP_SDK_VC_DIR!" (
126-
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -property installationPath -format text') do (
131+
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo !VS_VERSION_ARGS! -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -property installationPath -format text') do (
127132
set PHP_SDK_VC_DIR=%%b\VC
128133
)
129134
if not exist "!PHP_SDK_VC_DIR!" (
130135
rem check for a preview release
131-
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -property installationPath -format text') do (
136+
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo !VS_VERSION_ARGS! -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -property installationPath -format text') do (
132137
set PHP_SDK_VC_DIR=%%b\VC
133138
)
134139
if not exist "!PHP_SDK_VC_DIR!" (
@@ -199,9 +204,17 @@ if "%HOST_ARCH_NAME%"=="%TARGET_ARCH_NAME%" (
199204
set VCVARSALL_ARCH_NAME=%HOST_ARCH_NAME%_%TARGET_ARCH_NAME%
200205
)
201206
if 15 gtr %PHP_SDK_VS_NUM% (
202-
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" !VCVARSALL_ARCH_NAME!
207+
if NOT "%TOOLSET%"=="" (
208+
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" !VCVARSALL_ARCH_NAME! -vcvars_ver=%TOOLSET%
209+
) else (
210+
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" !VCVARSALL_ARCH_NAME!
211+
)
203212
) else (
204-
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" !VCVARSALL_ARCH_NAME!
213+
if NOT "%TOOLSET%"=="" (
214+
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" !VCVARSALL_ARCH_NAME! -vcvars_ver=%TOOLSET%
215+
) else (
216+
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" !VCVARSALL_ARCH_NAME!
217+
)
205218
)
206219
set VCVARSALL_ARCH_NAME=
207220

phpsdk-starter.bat

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ set PHP_SDK_ROOT_PATH=%PHP_SDK_ROOT_PATH:~0,-1%
1414
if /i "%1" equ "-h" goto help
1515
if /i "%1" equ "-c" set CRT=%2 & shift
1616
if /i "%1" equ "-a" set ARCH=%2 & shift
17+
if /i "%1" equ "-s" set TOOLSET=%2 & shift
1718
if /i "%1" equ "-t" set TASK=%2 & shift
1819
if /i "%1" equ "--task-args" set TASK_ARGS=%2 & shift
1920
shift
@@ -37,7 +38,7 @@ set PHP_SDK_RUN_FROM_ROOT=1
3738

3839
title PHP SDK %CRT% %ARCH%
3940

40-
call %PHP_SDK_ROOT_PATH%\bin\phpsdk_setshell.bat %CRT% %ARCH%
41+
call %PHP_SDK_ROOT_PATH%\bin\phpsdk_setshell.bat %CRT% %ARCH% %TOOLSET%
4142

4243
set PHP_SDK_RUN_FROM_ROOT=
4344
set CRT=

0 commit comments

Comments
 (0)