diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index 08df47f7..e95298fa 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -36,4 +36,17 @@ class openssl extends Extension } return $args; } + + public function getWindowsConfigureArg(bool $shared = false): string + { + $args = '--with-openssl'; + if ( + $this->builder->getPHPVersionID() >= 80500 && + ($ver = $this->builder->getLib('openssl')->getLibVersion()) && + version_compare($ver, '3.2.0', '>=') + ) { + $args .= ' --with-openssl-argon2'; + } + return $args; + } } diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 401bb3d7..2a3ed9be 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -29,7 +29,7 @@ use SPC\store\FileSystem; class openssl extends LinuxLibraryBase { - use \SPC\builder\unix\library\openssl; + use \SPC\builder\traits\openssl; public const NAME = 'openssl'; diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index 3edc15e7..df0f4a52 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -28,7 +28,7 @@ use SPC\store\FileSystem; class openssl extends MacOSLibraryBase { - use \SPC\builder\unix\library\openssl; + use \SPC\builder\traits\openssl; public const NAME = 'openssl'; diff --git a/src/SPC/builder/traits/openssl.php b/src/SPC/builder/traits/openssl.php new file mode 100644 index 00000000..47becc99 --- /dev/null +++ b/src/SPC/builder/traits/openssl.php @@ -0,0 +1,38 @@ +source_dir}/VERSION.dat")) { + // parse as INI + $version = parse_ini_file("{$this->source_dir}/VERSION.dat"); + if ($version !== false) { + return "{$version['MAJOR']}.{$version['MINOR']}.{$version['PATCH']}"; + } + } + // get openssl version from pkg-config + if (PHP_OS_FAMILY !== 'Windows') { + try { + return PkgConfigUtil::getModuleVersion('openssl'); + } catch (RuntimeException) { + } + } + // get openssl version from header openssl/opensslv.h + if (file_exists(BUILD_INCLUDE_PATH . '/openssl/opensslv.h')) { + if (preg_match('/OPENSSL_VERSION_STR "(.*)"/', FileSystem::readFile(BUILD_INCLUDE_PATH . '/openssl/opensslv.h'), $match)) { + return $match[1]; + } + } + return null; + } +} diff --git a/src/SPC/builder/unix/library/openssl.php b/src/SPC/builder/unix/library/openssl.php deleted file mode 100644 index 4acef78c..00000000 --- a/src/SPC/builder/unix/library/openssl.php +++ /dev/null @@ -1,21 +0,0 @@ -source_dir}/VERSION.dat")) { - // parse as INI - $version = parse_ini_file("{$this->source_dir}/VERSION.dat"); - if ($version !== false) { - return "{$version['MAJOR']}.{$version['MINOR']}.{$version['PATCH']}"; - } - } - return null; - } -} diff --git a/src/SPC/util/PkgConfigUtil.php b/src/SPC/util/PkgConfigUtil.php index 87075b49..94aaf6c2 100644 --- a/src/SPC/util/PkgConfigUtil.php +++ b/src/SPC/util/PkgConfigUtil.php @@ -8,6 +8,21 @@ use SPC\exception\RuntimeException; class PkgConfigUtil { + /** + * Returns the version of a module. + * This method uses `pkg-config --modversion` to get the version of the specified module. + * If the module is not found, it will throw a RuntimeException. + * + * @param string $pkg_config_str .pc file str, accepts multiple files + * @return string version string, e.g. "1.2.3" + * @throws RuntimeException + */ + public static function getModuleVersion(string $pkg_config_str): string + { + $result = self::execWithResult("pkg-config --modversion {$pkg_config_str}"); + return trim($result); + } + /** * Returns --cflags-only-other output. * The reason we return the string is we cannot use array_unique() on cflags, diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index df222fa3..a5b3a9d7 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -16,7 +16,7 @@ $test_php_version = [ // '8.1', // '8.2', // '8.3', - // '8.4', + '8.4', 'git', ]; @@ -49,8 +49,8 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'bcmath', - 'Windows' => 'curl', + 'Linux', 'Darwin' => 'openssl', + 'Windows' => 'openssl', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). @@ -73,7 +73,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'common', + 'Linux', 'Darwin' => 'minimal', 'Windows' => 'none', };