From 7406386022bd017c4c1188c546e56c707f0cc8db Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 9 May 2024 13:17:35 +0800 Subject: [PATCH 1/2] add parallel windows support --- config/ext.json | 5 +++- config/lib.json | 6 ++++ config/source.json | 9 ++++++ .../builder/windows/library/pthreads4w.php | 29 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/SPC/builder/windows/library/pthreads4w.php diff --git a/config/ext.json b/config/ext.json index b52076c2..fe75c790 100644 --- a/config/ext.json +++ b/config/ext.json @@ -190,7 +190,10 @@ "parallel": { "type": "external", "source": "parallel", - "arg-type-windows": "with" + "arg-type-windows": "with", + "lib-depends-windows": [ + "pthreads4w" + ] }, "ldap": { "type": "builtin", diff --git a/config/lib.json b/config/lib.json index b7a92d04..82f4cf91 100644 --- a/config/lib.json +++ b/config/lib.json @@ -125,6 +125,12 @@ "gmp.h" ] }, + "pthreads4w": { + "source": "pthreads4w", + "static-libs-windows": [ + "libpthreadVC3.lib" + ] + }, "icu": { "source": "icu", "cpp-library": true, diff --git a/config/source.json b/config/source.json index 595389bc..d704d3f6 100644 --- a/config/source.json +++ b/config/source.json @@ -52,6 +52,15 @@ "path": "COPYING" } }, + "pthreads4w": { + "type": "git", + "rev": "master", + "url": "https://git.code.sf.net/p/pthreads4w/code", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-ds": { "type": "url", "url": "https://pecl.php.net/get/ds", diff --git a/src/SPC/builder/windows/library/pthreads4w.php b/src/SPC/builder/windows/library/pthreads4w.php new file mode 100644 index 00000000..66707cbb --- /dev/null +++ b/src/SPC/builder/windows/library/pthreads4w.php @@ -0,0 +1,29 @@ +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'); + } +} From 30bca1a9669660b4ff96634af3a2c56a4cfdef32 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 9 May 2024 13:21:52 +0800 Subject: [PATCH 2/2] add parallel test --- .github/workflows/tests.yml | 2 +- config/ext.json | 16 +++++++------- config/lib.json | 12 +++++------ config/source.json | 38 ++++++++++++++++----------------- src/globals/test-extensions.php | 9 +++++--- 5 files changed, 40 insertions(+), 37 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 83ae9cc9..74394e26 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/config/ext.json b/config/ext.json index fe75c790..f3529fc2 100644 --- a/config/ext.json +++ b/config/ext.json @@ -187,14 +187,6 @@ "icu" ] }, - "parallel": { - "type": "external", - "source": "parallel", - "arg-type-windows": "with", - "lib-depends-windows": [ - "pthreads4w" - ] - }, "ldap": { "type": "builtin", "arg-type": "with-prefix", @@ -288,6 +280,14 @@ "zlib" ] }, + "parallel": { + "type": "external", + "source": "parallel", + "arg-type-windows": "with", + "lib-depends-windows": [ + "pthreads4w" + ] + }, "password-argon2": { "type": "builtin", "arg-type": "with-prefix", diff --git a/config/lib.json b/config/lib.json index 82f4cf91..d2364a3a 100644 --- a/config/lib.json +++ b/config/lib.json @@ -125,12 +125,6 @@ "gmp.h" ] }, - "pthreads4w": { - "source": "pthreads4w", - "static-libs-windows": [ - "libpthreadVC3.lib" - ] - }, "icu": { "source": "icu", "cpp-library": true, @@ -534,6 +528,12 @@ "zstd" ] }, + "pthreads4w": { + "source": "pthreads4w", + "static-libs-windows": [ + "libpthreadVC3.lib" + ] + }, "qdbm": { "source": "qdbm", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index d704d3f6..b666ca6c 100644 --- a/config/source.json +++ b/config/source.json @@ -52,15 +52,6 @@ "path": "COPYING" } }, - "pthreads4w": { - "type": "git", - "rev": "master", - "url": "https://git.code.sf.net/p/pthreads4w/code", - "license": { - "type": "file", - "path": "LICENSE" - } - }, "ext-ds": { "type": "url", "url": "https://pecl.php.net/get/ds", @@ -488,16 +479,6 @@ "path": "LICENSE" } }, - "parallel": { - "type": "url", - "url": "https://pecl.php.net/get/parallel", - "path": "php-src/ext/parallel", - "filename": "parallel.tgz", - "license": { - "type": "file", - "path": "LICENSE" - } - }, "ncurses": { "type": "filelist", "url": "https://ftp.gnu.org/pub/gnu/ncurses/", @@ -534,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", @@ -570,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", diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 96001af2..0dfc8312 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -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 => '', };