@@ -46,30 +46,42 @@ set TMP_CHK=
46
46
47
47
if /i not " %2 " == " x64" (
48
48
if /i not " %2 " == " x86" (
49
- echo Unsupported arch " %2 "
50
- goto out_error
49
+ if /i not " %2 " == " arm64" (
50
+ echo Unsupported arch " %2 "
51
+ goto out_error
52
+ )
51
53
)
52
54
)
53
55
54
56
set PHP_SDK_ARCH = %2
55
57
56
58
rem check OS arch
57
- set TMPKEY = HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion
58
- reg query " %TMPKEY% " /v " ProgramFilesDir (x86) " > nul 2 > nul
59
+ rem Architecture=9 meaning x86_64
60
+ wmic cpu get Architecture /value | findstr " Architecture=9\> " > nul 2 > nul
59
61
if not errorlevel 1 (
60
62
set PHP_SDK_OS_ARCH = x64
61
- ) else (
62
- if /i " %PHP_SDK_ARCH% " == " x64" (
63
- echo 32-bit OS detected, native 64-bit toolchain is unavailable.
64
- goto out_error
65
- )
63
+ )
64
+ rem Architecture=12 meaning arm64
65
+ wmic cpu get Architecture /value | findstr " Architecture=12\>" > nul 2 > nul
66
+ if not errorlevel 1 (
67
+ set PHP_SDK_OS_ARCH = arm64
68
+ )
69
+ rem Architecture=0 meaning x86
70
+ wmic cpu get Architecture /value | findstr " Architecture=0\>" > nul 2 > nul
71
+ if not errorlevel 1 (
66
72
set PHP_SDK_OS_ARCH = x86
67
73
)
68
- set TMPKEY =
74
+
75
+ rem cross compile is ok, so we donot need this
76
+ rem if not /i "%PHP_SDK_ARCH%"=="PHP_SDK_OS_ARCH" (
77
+ rem echo 32-bit OS detected, native 64-bit toolchain is unavailable.
78
+ rem goto out_error
79
+ rem )
69
80
70
81
rem get vc base dir
71
82
if 15 gtr %PHP_SDK_VS_NUM% (
72
- if /i " %PHP_SDK_OS_ARCH% " == " x64" (
83
+ rem for arch other than x86, use WOW6432
84
+ if /i not " %PHP_SDK_OS_ARCH% " == " x86" (
73
85
set TMPKEY = HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VS:~2 % .0\Setup\VC
74
86
) else (
75
87
set TMPKEY = HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VS:~2 % .0\Setup\VC
@@ -85,16 +97,20 @@ if 15 gtr %PHP_SDK_VS_NUM% (
85
97
set /a PHP_SDK_VS_RANGE = PHP_SDK_VS_NUM + 1
86
98
set PHP_SDK_VS_RANGE = " [%PHP_SDK_VS_NUM% ,!PHP_SDK_VS_RANGE%! )"
87
99
88
- 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 (
100
+ set APPEND = x86.x64
101
+ if /i " %PHP_SDK_OS_ARCH% " == " arm64" (
102
+ set APPEND = ARM64
103
+ )
104
+ 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 (
89
105
set PHP_SDK_VC_DIR = %%b \VC
90
106
)
91
107
if not exist " !PHP_SDK_VC_DIR! " (
92
- 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.x86.x64 -property installationPath -format text') do (
108
+ 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 (
93
109
set PHP_SDK_VC_DIR = %%b \VC
94
110
)
95
111
if not exist " !PHP_SDK_VC_DIR! " (
96
112
rem check for a preview release
97
- for /f " tokens=1* delims=: " %%a in ('%~dp0 \vswhere -nologo -version !PHP_SDK_VS_RANGE! -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
113
+ 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 (
98
114
set PHP_SDK_VC_DIR = %%b \VC
99
115
)
100
116
if not exist " !PHP_SDK_VC_DIR! " (
@@ -105,13 +121,15 @@ if 15 gtr %PHP_SDK_VS_NUM% (
105
121
)
106
122
set VSCMD_ARG_no_logo = nologo
107
123
)
124
+ set APPEND =
108
125
set TMPKEY =
109
126
set PHP_SDK_VS_RANGE =
110
127
111
128
if 15 gtr %PHP_SDK_VS_NUM% (
112
129
rem get sdk dir
113
130
rem if 10.0 is available, it's ok
114
- if /i " %PHP_SDK_OS_ARCH% " == " x64" (
131
+ rem for arch other than x86, use WOW6432
132
+ if /i not " %PHP_SDK_OS_ARCH% " == " x86" (
115
133
set TMPKEY = HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0
116
134
) else (
117
135
set TMPKEY = HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0
@@ -125,7 +143,8 @@ if 15 gtr %PHP_SDK_VS_NUM% (
125
143
)
126
144
127
145
rem Otherwise 8.1 should be available anyway
128
- if /i " %PHP_SDK_OS_ARCH% " == " x64" (
146
+ rem for arch other than x86, use WOW6432
147
+ if /i not " %PHP_SDK_OS_ARCH% " == " x86" (
129
148
set TMPKEY = HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1
130
149
) else (
131
150
set TMPKEY = HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1
@@ -143,17 +162,21 @@ if 15 gtr %PHP_SDK_VS_NUM% (
143
162
)
144
163
145
164
if /i " %PHP_SDK_ARCH% " == " x64" (
146
- if 15 gtr %PHP_SDK_VS_NUM% (
147
- set PHP_SDK_VS_SHELL_CMD = " !PHP_SDK_VC_DIR! \vcvarsall.bat" amd64
148
- ) else (
149
- set PHP_SDK_VS_SHELL_CMD = " !PHP_SDK_VC_DIR! \Auxiliary\Build\vcvarsall.bat" amd64
150
- )
165
+ set TARGET_ARCH_NAME = amd64
151
166
) else (
152
- if 15 gtr %PHP_SDK_VS_NUM% (
153
- set PHP_SDK_VS_SHELL_CMD = " !PHP_SDK_VC_DIR! \vcvarsall.bat" x86
154
- ) else (
155
- set PHP_SDK_VS_SHELL_CMD = " !PHP_SDK_VC_DIR! \Auxiliary\Build\vcvarsall.bat" x86
156
- )
167
+ set TARGET_ARCH_NAME = %PHP_SDK_ARCH%
168
+ )
169
+
170
+ if /i " %PHP_SDK_OS_ARCH% " == " x64" (
171
+ set HOST_ARCH_NAME = amd64
172
+ ) else (
173
+ set HOST_ARCH_NAME = %PHP_SDK_ARCH%
174
+ )
175
+
176
+ if 15 gtr %PHP_SDK_VS_NUM% (
177
+ set PHP_SDK_VS_SHELL_CMD = " !PHP_SDK_VC_DIR! \vcvarsall.bat" !HOST_ARCH_NAME! _!TARGET_ARCH_NAME!
178
+ ) else (
179
+ set PHP_SDK_VS_SHELL_CMD = " !PHP_SDK_VC_DIR! \Auxiliary\Build\vcvarsall.bat" !HOST_ARCH_NAME! _!TARGET_ARCH_NAME!
157
180
)
158
181
159
182
rem echo Visual Studio VC path %PHP_SDK_VC_DIR%
0 commit comments