Add extension parallel support (#444)

* Add extension parallel support

* add parallel windows support

* add parallel test

* add zts limit for parallel

* sort config

* add parallel test

* add dev-php test

* use macos-13 instead of macos-latest

* revert dev-php tests
This commit is contained in:
Jerry Ma 2024-05-11 14:46:36 +08:00 committed by GitHub
parent e6c308c242
commit 1632c25223
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 101 additions and 5 deletions

View File

@ -113,7 +113,7 @@ jobs:
- "8.3"
os:
- ubuntu-latest
- macos-latest
- macos-13
- windows-latest
- macos-14
fail-fast: false
@ -168,4 +168,4 @@ jobs:
bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=3
- name: "Run Build Tests (build)"
run: bin/spc build "$(php src/globals/test-extensions.php extensions)" --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug
run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug

View File

@ -187,6 +187,11 @@
"icu"
]
},
"parallel": {
"type": "external",
"source": "parallel",
"arg-type-windows": "with"
},
"ldap": {
"type": "builtin",
"arg-type": "with-prefix",
@ -280,6 +285,14 @@
"zlib"
]
},
"parallel": {
"type": "external",
"source": "parallel",
"arg-type-windows": "with",
"lib-depends-windows": [
"pthreads4w"
]
},
"password-argon2": {
"type": "builtin",
"arg-type": "with-prefix",

View File

@ -528,6 +528,12 @@
"zstd"
]
},
"pthreads4w": {
"source": "pthreads4w",
"static-libs-windows": [
"libpthreadVC3.lib"
]
},
"qdbm": {
"source": "qdbm",
"static-libs-unix": [

View File

@ -515,6 +515,16 @@
"path": "LICENSE.txt"
}
},
"parallel": {
"type": "url",
"url": "https://pecl.php.net/get/parallel",
"path": "php-src/ext/parallel",
"filename": "parallel.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"pdo_sqlsrv": {
"type": "url",
"url": "https://pecl.php.net/get/pdo_sqlsrv",
@ -551,6 +561,15 @@
"path": "LICENSE"
}
},
"pthreads4w": {
"type": "git",
"rev": "master",
"url": "https://git.code.sf.net/p/pthreads4w/code",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"qdbm": {
"type": "git",
"url": "https://github.com/static-php/qdbm.git",

View File

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\WrongUsageException;
use SPC\util\CustomExt;
#[CustomExt('parallel')]
class parallel extends Extension
{
public function getConfigureArg(): string
{
if (!$this->builder->getOption('enable-zts')) {
throw new WrongUsageException('ext-parallel must be built with ZTS builds. Use "--enable-zts" option!');
}
return parent::getConfigureArg(); // TODO: Change the autogenerated stub
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace SPC\builder\windows\library;
class pthreads4w extends WindowsLibraryBase
{
public const NAME = 'pthreads4w';
protected function build(): void
{
cmd()->cd($this->source_dir)
->execWithWrapper(
$this->builder->makeSimpleWrapper(
'nmake /E /nologo /f Makefile ' .
'DESTROOT=' . BUILD_ROOT_PATH . ' ' .
'XCFLAGS="/MT" ' . // no dll
'EHFLAGS="/I. /DHAVE_CONFIG_H /Os /Ob2 /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED"'
),
'pthreadVC3.inlined_static_stamp'
);
copy($this->source_dir . '\libpthreadVC3.lib', BUILD_LIB_PATH . '\libpthreadVC3.lib');
copy($this->source_dir . '\_ptw32.h', BUILD_INCLUDE_PATH . '\_ptw32.h');
copy($this->source_dir . '\pthread.h', BUILD_INCLUDE_PATH . '\pthread.h');
copy($this->source_dir . '\sched.h', BUILD_INCLUDE_PATH . '\sched.h');
copy($this->source_dir . '\semaphore.h', BUILD_INCLUDE_PATH . '\semaphore.h');
}
}

View File

@ -11,10 +11,12 @@ declare(strict_types=1);
// --------------------------------- edit area ---------------------------------
$zts = 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' => 'readline,pgsql,xml,dom,mbstring,mbregex,pdo_pgsql',
'Windows' => 'mbstring,pdo_sqlite,mbregex',
'Linux', 'Darwin' => 'parallel',
'Windows' => 'mbstring,pdo_sqlite,mbregex,parallel',
};
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
@ -27,7 +29,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' => 'none',
'Linux', 'Darwin' => 'minimal',
'Windows' => 'none',
};
@ -71,5 +73,6 @@ echo match ($argv[1]) {
'libs' => $final_libs,
'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)),
'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)),
'zts' => $zts ? '--enable-zts' : '',
default => '',
};

View File

@ -0,0 +1,5 @@
<?php
declare(strict_types=1);
assert(class_exists('\parallel\Runtime'));