From aee165fe0535734eb01f86fc7db41d5fbaf463d0 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 17 Aug 2017 14:06:01 +0200 Subject: [PATCH] refactor dependency dir recognition --- lib/php/libsdk/SDK/Config.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/php/libsdk/SDK/Config.php b/lib/php/libsdk/SDK/Config.php index 0ded632..02a9059 100644 --- a/lib/php/libsdk/SDK/Config.php +++ b/lib/php/libsdk/SDK/Config.php @@ -296,10 +296,26 @@ class Config public static function getDepsLocalPath() : ?string {/*{{{*/ + if (NULL == self::$depsLocalPath) { + if (file_exists("Makefile")) { + $s = file_get_contents("Makefile"); + + if (preg_match(",PHP_BUILD=(.+),", $s, $m)) { + if (isset($m[1]) && is_dir($m[1])) { + self::setDepsLocalPath(realpath($m[1])); + } + } + } + } + if (NULL == self::$depsLocalPath) { if (file_exists("../deps")) { self::setDepsLocalPath(realpath("../deps")); - } else if (file_exists("main/php_version.h")) { + } + } + + if (NULL == self::$depsLocalPath) { + if (file_exists("main/php_version.h")) { /* Deps dir might not exist. */ self::setDepsLocalPath(realpath("..") . DIRECTORY_SEPARATOR . "deps"); }