@@ -57,20 +57,24 @@ public static function setCurrentArchName(string $arch) : void
57
57
public static function getCurrentArchName () : string
58
58
{/*{{{*/
59
59
if (NULL === self ::$ currentArchName ) {
60
- /* XXX this might be not true for other compilers! */
61
- passthru ("where cl.exe >nul " , $ status );
62
- if ($ status ) {
63
- throw new Exception ("Couldn't execute cl.exe. " );
64
- }
60
+ if (FALSE !== ($ env = getenv ('PHP_SDK_ARCH ' ))) {
61
+ self ::setCurrentArchName ($ env );
62
+ } else {
63
+ /* XXX this might be not true for other compilers! */
64
+ passthru ("where cl.exe >nul " , $ status );
65
+ if ($ status ) {
66
+ throw new Exception ("Couldn't execute cl.exe. " );
67
+ }
65
68
66
- exec ("cl.exe /? 2>&1 " , $ out );
69
+ exec ("cl.exe /? 2>&1 " , $ out );
67
70
68
- if (preg_match (",x64, " , $ out [0 ])) {
69
- self ::setCurrentArchName ("x64 " );
70
- } elseif (preg_match (",x86, " , $ out [0 ])) {
71
- self ::setCurrentArchName ("x86 " );
72
- } else {
73
- throw new Exception ("Couldn't determine Arch. " );
71
+ if (preg_match (",x64, " , $ out [0 ])) {
72
+ self ::setCurrentArchName ("x64 " );
73
+ } elseif (preg_match (",x86, " , $ out [0 ])) {
74
+ self ::setCurrentArchName ("x86 " );
75
+ } else {
76
+ throw new Exception ("Couldn't determine Arch. " );
77
+ }
74
78
}
75
79
}
76
80
@@ -85,18 +89,22 @@ public static function setCurrentCrtName(string $crt) : void
85
89
public static function getCurrentCrtName () : ?string
86
90
{/*{{{*/
87
91
if (NULL === self ::$ currentCrtName ) {
88
- $ all_branches = Config::getKnownBranches ();
92
+ if (FALSE !== ($ env = getenv ('PHP_SDK_VS ' ))) {
93
+ self ::setCurrentCrtName ($ env );
94
+ } else {
95
+ $ all_branches = Config::getKnownBranches ();
89
96
90
- if (!isset ($ all_branches [Config::getCurrentBranchName ()])) {
91
- throw new Exception ("Couldn't find any configuration for branch ' " . Config::getCurrentBranchName () . "' " );
92
- }
97
+ if (!isset ($ all_branches [Config::getCurrentBranchName ()])) {
98
+ throw new Exception ("Couldn't find any configuration for branch ' " . Config::getCurrentBranchName () . "' " );
99
+ }
93
100
94
- $ branch = $ all_branches [Config::getCurrentBranchName ()];
95
- if (count ($ branch ) > 1 ) {
96
- throw new Exception ("Multiple CRTs are available for this branch, please choose one from " . implode (", " , array_keys ($ branch )));
97
- }
101
+ $ branch = $ all_branches [Config::getCurrentBranchName ()];
102
+ if (count ($ branch ) > 1 ) {
103
+ throw new Exception ("Multiple CRTs are available for this branch, please choose one from " . implode (", " , array_keys ($ branch )));
104
+ }
98
105
99
- self ::setCurrentCrtName (array_keys ($ branch )[0 ]);
106
+ self ::setCurrentCrtName (array_keys ($ branch )[0 ]);
107
+ }
100
108
}
101
109
102
110
return self ::$ currentCrtName ;
0 commit comments