@@ -57,20 +57,24 @@ public static function setCurrentArchName(string $arch) : void
5757 public static function getCurrentArchName () : string
5858 {/*{{{*/
5959 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+ }
6568
66- exec ("cl.exe /? 2>&1 " , $ out );
69+ exec ("cl.exe /? 2>&1 " , $ out );
6770
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+ }
7478 }
7579 }
7680
@@ -85,18 +89,22 @@ public static function setCurrentCrtName(string $crt) : void
8589 public static function getCurrentCrtName () : ?string
8690 {/*{{{*/
8791 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 ();
8996
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+ }
93100
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+ }
98105
99- self ::setCurrentCrtName (array_keys ($ branch )[0 ]);
106+ self ::setCurrentCrtName (array_keys ($ branch )[0 ]);
107+ }
100108 }
101109
102110 return self ::$ currentCrtName ;
0 commit comments