Compare commits

..

4 Commits
2.3.3 ... 2.3.4

Author SHA1 Message Date
Jerry Ma
29efc2c5a5 Add extension gmssl support (#544)
* Add extension gmssl support

* cs-fix

* Add framework for gmssl
2024-09-20 12:32:31 +08:00
Jerry Ma
e35836943e Update FUNDING.yml 2024-09-19 21:27:24 +08:00
Jerry Ma
2beecee219 Add extension msgpack support (#543) 2024-09-17 22:34:57 +08:00
Jerry Ma
ad098d085e Update redis to 6.0.2, add alternative license file searcher (#539)
* Update redis to 6.0.2, add alternative license file searcher

* Update docs about source module
2024-09-09 17:41:29 +08:00
16 changed files with 242 additions and 12 deletions

4
.github/FUNDING.yml vendored
View File

@@ -3,7 +3,7 @@
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
ko_fi: crazywhalecc # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
@@ -11,5 +11,5 @@ issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
# noinspection YAMLSchemaValidation
buy_me_a_coffee: crazywhalecc
buy_me_a_coffee: # crazywhalecc
custom: 'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@@ -189,6 +189,16 @@
"gmp"
]
},
"gmssl": {
"support": {
"BSD": "wip"
},
"type": "external",
"source": "ext-gmssl",
"lib-depends": [
"gmssl"
]
},
"iconv": {
"support": {
"BSD": "wip"
@@ -360,6 +370,15 @@
"zlib"
]
},
"msgpack": {
"support": {
"BSD": "wip"
},
"type": "external",
"source": "msgpack",
"arg-type-unix": "with",
"arg-type-win": "enable"
},
"mysqli": {
"type": "builtin",
"arg-type": "with",

View File

@@ -127,6 +127,18 @@
"gmp.h"
]
},
"gmssl": {
"source": "gmssl",
"static-libs-unix": [
"libgmssl.a"
],
"static-libs-windows": [
"gmssl.lib"
],
"frameworks": [
"Security"
]
},
"icu": {
"source": "icu",
"cpp-library": true,

View File

@@ -83,6 +83,15 @@
"path": "LICENSE"
}
},
"ext-gmssl": {
"type": "ghtar",
"repo": "gmssl/GmSSL-PHP",
"path": "php-src/ext/gmssl",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-imagick": {
"type": "url",
"url": "https://pecl.php.net/get/imagick",
@@ -194,6 +203,14 @@
"text": "Since version 6, GMP is distributed under the dual licenses, GNU LGPL v3 and GNU GPL v2. These licenses make the library free to use, share, and improve, and allow you to pass on the result. The GNU licenses give freedoms, but also set firm restrictions on the use with non-free programs."
}
},
"gmssl": {
"type": "ghtar",
"repo": "guanzhi/GmSSL",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"icu": {
"type": "ghrel",
"repo": "unicode-org/icu",
@@ -514,6 +531,16 @@
"path": "LICENSE"
}
},
"msgpack": {
"type": "url",
"url": "https://pecl.php.net/get/msgpack",
"path": "php-src/ext/msgpack",
"filename": "msgpack.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ncurses": {
"type": "filelist",
"url": "https://ftp.gnu.org/pub/gnu/ncurses/",
@@ -649,11 +676,14 @@
"redis": {
"type": "git",
"path": "php-src/ext/redis",
"rev": "5.3.7",
"rev": "release/6.0.2",
"url": "https://github.com/phpredis/phpredis",
"license": {
"type": "file",
"path": "COPYING"
"path": [
"LICENSE",
"COPYING"
]
}
},
"snappy": {

View File

@@ -317,3 +317,24 @@ When an open source project has multiple licenses, multiple files can be specifi
}
}
```
When the license of an open source project uses different files between versions,
`path` can be used as an array to list the possible license files:
```json
{
"redis": {
"type": "git",
"path": "php-src/ext/redis",
"rev": "release/6.0.2",
"url": "https://github.com/phpredis/phpredis",
"license": {
"type": "file",
"path": [
"LICENSE",
"COPYING"
]
}
}
}
```

View File

@@ -297,3 +297,23 @@ pkg.json 存放的是非源码类型的文件资源,例如 musl-toolchain、UP
}
}
```
当一个开源项目的许可证在不同版本间使用不同的文件,`path` 参数可以使用数组将可能的许可证文件列出:
```json
{
"redis": {
"type": "git",
"path": "php-src/ext/redis",
"rev": "release/6.0.2",
"url": "https://github.com/phpredis/phpredis",
"license": {
"type": "file",
"path": [
"LICENSE",
"COPYING"
]
}
}
}
```

View File

@@ -30,7 +30,7 @@ use Symfony\Component\Console\Application;
*/
final class ConsoleApplication extends Application
{
public const VERSION = '2.3.3';
public const VERSION = '2.3.4';
public function __construct()
{

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('gmssl')]
class gmssl extends Extension
{
public function patchBeforeBuildconf(): bool
{
if (str_contains(file_get_contents(SOURCE_PATH . '/php-src/ext/gmssl/config.w32'), 'CHECK_LIB(')) {
return false;
}
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gmssl/config.w32', 'AC_DEFINE(', 'CHECK_LIB("gmssl.lib", "gmssl", PHP_GMSSL);' . PHP_EOL . 'AC_DEFINE(');
return true;
}
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class gmssl extends LinuxLibraryBase
{
use \SPC\builder\unix\library\gmssl;
public const NAME = 'gmssl';
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class gmssl extends MacOSLibraryBase
{
use \SPC\builder\unix\library\gmssl;
public const NAME = 'gmssl';
}

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
trait gmssl
{
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void
{
// CMake needs a clean build directory
FileSystem::resetDir($this->source_dir . '/build');
// Start build
shell()->cd($this->source_dir . '/build')
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..")
->execWithEnv("cmake --build . -j {$this->builder->concurrency}")
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
}
}

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace SPC\builder\windows\library;
use SPC\store\FileSystem;
class gmssl extends WindowsLibraryBase
{
public const NAME = 'gmssl';
protected function build(): void
{
// reset cmake
FileSystem::resetDir($this->source_dir . '\builddir');
// start build
cmd()->cd($this->source_dir . '\builddir')
->execWithWrapper(
$this->builder->makeSimpleWrapper('cmake .. -G "NMake Makefiles" -DWIN32=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" -DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH),
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH
);
FileSystem::writeFile($this->source_dir . '\builddir\cmake_install.cmake', 'set(CMAKE_INSTALL_PREFIX "' . str_replace('\\', '/', BUILD_ROOT_PATH) . '")' . PHP_EOL . FileSystem::readFile($this->source_dir . '\builddir\cmake_install.cmake'));
cmd()->cd($this->source_dir . '\builddir')
->execWithWrapper(
$this->builder->makeSimpleWrapper('nmake'),
'install XCFLAGS=/MT'
);
}
}

View File

@@ -118,20 +118,26 @@ class LicenseDumper
/**
* @throws RuntimeException
*/
private function loadSourceFile(string $source_name, int $index, ?string $in_path, ?string $custom_base_path = null): string
private function loadSourceFile(string $source_name, int $index, null|array|string $in_path, ?string $custom_base_path = null): string
{
if (is_null($in_path)) {
throw new RuntimeException('source [' . $source_name . '] license file is not set, please check config/source.json');
}
if (file_exists(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $in_path)) {
return file_get_contents(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $in_path);
if (!is_array($in_path)) {
$in_path = [$in_path];
}
foreach ($in_path as $item) {
if (file_exists(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $item)) {
return file_get_contents(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $item);
}
}
if (file_exists(BUILD_ROOT_PATH . '/source-licenses/' . $source_name . '/' . $index . '.txt')) {
return file_get_contents(BUILD_ROOT_PATH . '/source-licenses/' . $source_name . '/' . $index . '.txt');
}
throw new RuntimeException('source [' . $source_name . '] license file [' . $in_path . '] not exist');
throw new RuntimeException('Cannot find any license file in source [' . $source_name . '] directory!');
}
}

View File

@@ -0,0 +1,8 @@
<?php
declare(strict_types=1);
assert(function_exists('gmssl_rand_bytes'));
assert(function_exists('gmssl_sm3'));
assert(bin2hex(gmssl_sm3('123456')) === '207cf410532f92a47dee245ce9b11ff71f578ebd763eb3bbea44ebd043d018fb');

View File

@@ -0,0 +1,7 @@
<?php
declare(strict_types=1);
assert(function_exists('msgpack_pack'));
assert(function_exists('msgpack_unpack'));
assert(msgpack_unpack(msgpack_pack(['foo', 'bar'])) === ['foo', 'bar']);

View File

@@ -19,13 +19,13 @@ $upx = true;
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'imap,swoole-hook-sqlite,swoole',
'Windows' => 'igbinary,redis,session',
'Linux', 'Darwin' => 'gmssl',
'Windows' => 'gmssl',
};
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
$with_libs = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => '',
'Linux', 'Darwin' => 'liblz4',
'Windows' => '',
};