Skip to content

Commit aee165f

Browse files
committed
refactor dependency dir recognition
1 parent 0223331 commit aee165f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/php/libsdk/SDK/Config.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,26 @@ public static function getSdkVersion() : string
296296

297297
public static function getDepsLocalPath() : ?string
298298
{/*{{{*/
299+
if (NULL == self::$depsLocalPath) {
300+
if (file_exists("Makefile")) {
301+
$s = file_get_contents("Makefile");
302+
303+
if (preg_match(",PHP_BUILD=(.+),", $s, $m)) {
304+
if (isset($m[1]) && is_dir($m[1])) {
305+
self::setDepsLocalPath(realpath($m[1]));
306+
}
307+
}
308+
}
309+
}
310+
299311
if (NULL == self::$depsLocalPath) {
300312
if (file_exists("../deps")) {
301313
self::setDepsLocalPath(realpath("../deps"));
302-
} else if (file_exists("main/php_version.h")) {
314+
}
315+
}
316+
317+
if (NULL == self::$depsLocalPath) {
318+
if (file_exists("main/php_version.h")) {
303319
/* Deps dir might not exist. */
304320
self::setDepsLocalPath(realpath("..") . DIRECTORY_SEPARATOR . "deps");
305321
}

0 commit comments

Comments
 (0)