Skip to content

Commit

Permalink
规范 prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Cotch22 committed Oct 13, 2022
1 parent 6e81a6d commit 252bbc2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion ext/swoole
Submodule swoole updated 51 files
+35 −22 config.m4
+3 −5 ext-src/php_swoole.cc
+1 −1 ext-src/php_swoole_coroutine.h
+1 −12 ext-src/php_swoole_cxx.h
+0 −2 ext-src/php_swoole_private.h
+1 −1 ext-src/stubs/php_swoole_coroutine.stub.php
+1 −1 ext-src/stubs/php_swoole_coroutine_arginfo.h
+2 −2 ext-src/stubs/php_swoole_http_response.stub.php
+2 −2 ext-src/stubs/php_swoole_http_response_arginfo.h
+4 −0 ext-src/stubs/php_swoole_postgresql_coro.stub.php
+13 −1 ext-src/stubs/php_swoole_postgresql_coro_arginfo.h
+2 −2 ext-src/stubs/php_swoole_server.stub.php
+3 −3 ext-src/stubs/php_swoole_server_arginfo.h
+43 −0 ext-src/swoole_admin_server.cc
+12 −52 ext-src/swoole_coroutine.cc
+1 −1 ext-src/swoole_event.cc
+10 −2 ext-src/swoole_http_client_coro.cc
+13 −0 ext-src/swoole_http_response.cc
+314 −41 ext-src/swoole_postgresql_coro.cc
+28 −14 ext-src/swoole_server.cc
+0 −2 include/swoole_config.h
+1 −2 include/swoole_coroutine.h
+3 −2 include/swoole_coroutine_context.h
+1 −0 include/swoole_lock.h
+3 −0 include/swoole_socket.h
+2 −1 include/swoole_util.h
+1 −1 scripts/make.sh
+3 −13 src/core/log.cc
+3 −3 src/coroutine/context.cc
+6 −2 src/lock/mutex.cc
+2 −1 src/lock/rw_lock.cc
+1 −1 src/lock/spin_lock.cc
+9 −5 src/protocol/dtls.cc
+1 −1 src/server/manager.cc
+8 −0 src/server/master.cc
+2 −0 tests/include/api/syntax_error.txt
+5 −0 tests/pgsql.sql
+1 −1 tests/swoole_client_coro/connect_with_dns.phpt
+5 −1 tests/swoole_coroutine/bailout/error_in.phpt
+6 −1 tests/swoole_coroutine/bailout/error_out.phpt
+20 −0 tests/swoole_coroutine/exception/core_error.phpt
+7 −3 tests/swoole_coroutine/exception/error.phpt
+30 −0 tests/swoole_coroutine/exception/error2.phpt
+35 −0 tests/swoole_coroutine/exception/fatal_error.phpt
+1 −1 tests/swoole_curl/multi/bug4393.phpt
+106 −0 tests/swoole_http_server/bug_4857.phpt
+4 −12 tests/swoole_mysql_coro/another_coroutine.phpt
+110 −0 tests/swoole_pgsql_coro/lob.phpt
+15 −25 tests/swoole_server/taskWaitMulti.phpt
+28 −68 tests/swoole_server/taskwait_01.phpt
+30 −68 tests/swoole_server/taskwait_02.phpt
89 changes: 35 additions & 54 deletions prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,17 @@
use SwooleCli\Library;
use SwooleCli\Extension;

if (empty($argv[1])) {
switch (PHP_OS) {
default:
case 'Linux':
$type = 'linux';
break;
case 'Darwin':
$type = 'macos';
break;
case 'WINNT':
$type = 'win';
break;
}
} else {
$type = trim($argv[1]);
}

$p = new Preprocessor(__DIR__);
$p->setPhpSrcDir('/home/htf/soft/php-8.1.8');
$p->setDockerVersion('1.4');
$p->setSwooleDir('/home/htf/workspace/swoole');
if (!empty($argv[1])) {
$p->setOsType(trim($argv[1]));
}

$endCallbacks = [];

if ($type == 'macos') {
if ($p->osType == 'macos') {
$p->setWorkDir(__DIR__ . '/work');
$p->setExtraLdflags('-framework CoreFoundation -framework SystemConfiguration -undefined dynamic_lookup -lwebp -licudata -licui18n -licuio');
$endCallbacks[] = function() {
Expand All @@ -44,10 +30,9 @@

function install_openssl(Preprocessor $p)
{
global $type;
$p->addLibrary((new Library('openssl'))
$p->addLibrary((new Library('openssl', '/usr/openssl'))
->withUrl('https://www.openssl.org/source/openssl-1.1.1p.tar.gz')
->withConfigure('./config' . ($type === 'macos' ? '' : ' -static --static') . ' no-shared --prefix=/usr/openssl')
->withConfigure('./config' . ($p->osType === 'macos' ? '' : ' -static --static') . ' no-shared --prefix=/usr/openssl')
->withLicense('https://github.com/openssl/openssl/blob/master/LICENSE.txt', Library::LICENSE_APACHE2)
->withHomePage('https://www.openssl.org/')
);
Expand All @@ -56,7 +41,7 @@ function install_openssl(Preprocessor $p)
function install_libiconv(Preprocessor $p)
{
$p->addLibrary(
(new Library('libiconv'))
(new Library('libiconv', '/usr/libiconv'))
->withUrl('https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz')
->withPkgConfig('')
->withConfigure('./configure --prefix=/usr/libiconv enable_static=yes enable_shared=no')
Expand All @@ -69,7 +54,7 @@ function install_libiconv(Preprocessor $p)
function install_libxml2(Preprocessor $p)
{
$p->addLibrary(
(new Library('libxml2', '/usr'))
(new Library('libxml2'))
->withUrl('https://gitlab.gnome.org/GNOME/libxml2/-/archive/v2.9.10/libxml2-v2.9.10.tar.gz')
->withConfigure('./autogen.sh && ./configure --prefix=/usr --with-iconv=/usr/libiconv --enable-static=yes --enable-shared=no')
->withPkgName('libxml-2.0')
Expand All @@ -82,7 +67,7 @@ function install_libxml2(Preprocessor $p)
function install_libxslt(Preprocessor $p)
{
$p->addLibrary(
(new Library('libxslt', '/usr'))
(new Library('libxslt'))
->withUrl('https://gitlab.gnome.org/GNOME/libxslt/-/archive/v1.1.34/libxslt-v1.1.34.tar.gz')
->withConfigure('./autogen.sh && ./configure --prefix=/usr --enable-static=yes --enable-shared=no')
->withLicense('http://www.opensource.org/licenses/mit-license.html', Library::LICENSE_MIT)
Expand All @@ -92,7 +77,7 @@ function install_libxslt(Preprocessor $p)
function install_imagemagick(Preprocessor $p)
{
$p->addLibrary(
(new Library('imagemagick'))
(new Library('imagemagick', '/usr/imagemagick'))
->withUrl('https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.0-19.tar.gz')
->withConfigure('./configure --prefix=/usr/imagemagick --enable-static --disable-shared --with-zip=no --with-fontconfig=no --with-heic=no --with-lcms=no --with-lqr=no --with-openexr=no --with-openjp2=no --with-pango=no --with-raw=no --with-tiff=no')
->withPkgName('ImageMagick')
Expand All @@ -103,7 +88,7 @@ function install_imagemagick(Preprocessor $p)
function install_libmemcached(Preprocessor $p)
{
$p->addLibrary(
(new Library('libmemcached'))
(new Library('libmemcached', '/usr/libmemcached'))
->withUrl('https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz')
->withConfigure('./configure --prefix=/usr/libmemcached --enable-static --disable-shared')
->withLicense('https://imagemagick.org/script/license.php', Library::LICENSE_BSD)
Expand All @@ -113,7 +98,7 @@ function install_libmemcached(Preprocessor $p)
function install_gmp(Preprocessor $p)
{
$p->addLibrary(
(new Library('gmp'))
(new Library('gmp', '/usr/gmp'))
->withUrl('https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz')
->withConfigure('./configure --prefix=/usr/gmp --enable-static --disable-shared')
->withLicense('https://www.gnu.org/licenses/old-licenses/gpl-2.0.html', Library::LICENSE_GPL)
Expand All @@ -123,7 +108,7 @@ function install_gmp(Preprocessor $p)
function install_giflib(Preprocessor $p)
{
$p->addLibrary(
(new Library('giflib', '/usr'))
(new Library('giflib'))
->withUrl('https://nchc.dl.sourceforge.net/project/giflib/giflib-5.2.1.tar.gz')
->withMakeOptions('libgif.a')
->withLicense('http://giflib.sourceforge.net/intro.html', Library::LICENSE_SPEC)
Expand All @@ -133,7 +118,7 @@ function install_giflib(Preprocessor $p)
function install_libpng(Preprocessor $p)
{
$p->addLibrary(
(new Library('libpng'))
(new Library('libpng', '/usr/libpng'))
->withUrl('https://nchc.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.gz')
->withConfigure('./configure --prefix=/usr/libpng --enable-static --disable-shared')
->withLicense('http://www.libpng.org/pub/png/src/libpng-LICENSE.txt', Library::LICENSE_SPEC)
Expand All @@ -142,14 +127,13 @@ function install_libpng(Preprocessor $p)

function install_libjpeg(Preprocessor $p)
{
global $type;
$p->addLibrary(
(new Library('libjpeg', '/usr'))
(new Library('libjpeg'))
->withUrl('https://codeload.github.com/libjpeg-turbo/libjpeg-turbo/tar.gz/refs/tags/2.1.2')
->withConfigure('cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr .')
->withLdflags('-L/usr/lib64')
->withPkgConfig('/usr/lib64/pkgconfig')
->withClearDylib($type === 'macos')
->withClearDylib($p->osType === 'macos')
->withFile('libjpeg-turbo-2.1.2.tar.gz')
->withHomePage('https://libjpeg-turbo.org/')
->withLicense('https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/LICENSE.md', Library::LICENSE_BSD)
Expand All @@ -159,7 +143,7 @@ function install_libjpeg(Preprocessor $p)
function install_freetype(Preprocessor $p)
{
$p->addLibrary(
(new Library('freetype'))
(new Library('freetype', '/usr/freetype'))
->withUrl('https://mirror.yongbok.net/nongnu/freetype/freetype-2.10.4.tar.gz')
->withConfigure('./configure --prefix=/usr/freetype --enable-static --disable-shared')
->withHomePage('https://freetype.org/')
Expand All @@ -171,7 +155,7 @@ function install_freetype(Preprocessor $p)
function install_libwebp(Preprocessor $p)
{
$p->addLibrary(
(new Library('libwebp'))
(new Library('libwebp', '/usr/libwebp'))
->withUrl('https://codeload.github.com/webmproject/libwebp/tar.gz/refs/tags/v1.2.1')
->withConfigure('./autogen.sh && ./configure --prefix=/usr/libwebp --enable-static --disable-shared')
->withFile('libwebp-1.2.1.tar.gz')
Expand All @@ -183,7 +167,7 @@ function install_libwebp(Preprocessor $p)
function install_sqlite3(Preprocessor $p)
{
$p->addLibrary(
(new Library('sqlite3', '/usr'))
(new Library('sqlite3'))
->withUrl('https://www.sqlite.org/2021/sqlite-autoconf-3370000.tar.gz')
->withConfigure('./configure --prefix=/usr --enable-static --disable-shared')
->withHomePage('https://www.sqlite.org/index.html')
Expand All @@ -194,7 +178,7 @@ function install_sqlite3(Preprocessor $p)
function install_zlib(Preprocessor $p)
{
$p->addLibrary(
(new Library('zlib', '/usr'))
(new Library('zlib'))
->withUrl('https://udomain.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz')
->withConfigure('./configure --prefix=/usr --static')
->withHomePage('https://zlib.net/')
Expand All @@ -205,7 +189,7 @@ function install_zlib(Preprocessor $p)
function install_bzip2(Preprocessor $p)
{
$p->addLibrary(
(new Library('bzip2'))
(new Library('bzip2', '/usr/bzip2'))
->withUrl('https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz')
->withMakeOptions('PREFIX=/usr/bzip2')
->withMakeInstallOptions('PREFIX=/usr/bzip2')
Expand All @@ -218,7 +202,7 @@ function install_bzip2(Preprocessor $p)
function install_icu(Preprocessor $p)
{
$p->addLibrary(
(new Library('icu', '/usr'))
(new Library('icu'))
->withUrl('https://github.com/unicode-org/icu/releases/download/release-60-3/icu4c-60_3-src.tgz')
->withConfigure('source/runConfigureICU Linux --prefix=/usr --enable-static --disable-shared')
->withPkgName('icu-i18n')
Expand All @@ -230,7 +214,7 @@ function install_icu(Preprocessor $p)
function install_oniguruma(Preprocessor $p)
{
$p->addLibrary(
(new Library('oniguruma', '/usr'))
(new Library('oniguruma'))
->withUrl('https://codeload.github.com/kkos/oniguruma/tar.gz/refs/tags/v6.9.7')
->withConfigure('./autogen.sh && ./configure --prefix=/usr --enable-static --disable-shared')
->withFile('oniguruma-6.9.7.tar.gz')
Expand All @@ -242,7 +226,7 @@ function install_oniguruma(Preprocessor $p)
function install_zip(Preprocessor $p)
{
$p->addLibrary(
(new Library('zip', '/usr'))
(new Library('zip'))
->withUrl('https://libzip.org/download/libzip-1.8.0.tar.gz')
->withConfigure('cmake . -DBUILD_SHARED_LIBS=OFF -DOPENSSL_USE_STATIC_LIBS=TRUE -DCMAKE_INSTALL_PREFIX=/usr')
->withPkgName('libzip')
Expand All @@ -254,7 +238,7 @@ function install_zip(Preprocessor $p)
function install_cares(Preprocessor $p)
{
$p->addLibrary(
(new Library('cares', '/usr'))
(new Library('cares'))
->withUrl('https://c-ares.org/download/c-ares-1.18.1.tar.gz')
->withConfigure('./configure --prefix=/usr --enable-static --disable-shared')
->withPkgName('libcares')
Expand All @@ -266,7 +250,7 @@ function install_cares(Preprocessor $p)
function install_libedit(Preprocessor $p)
{
$p->addLibrary(
(new Library('libedit'))
(new Library('libedit', '/usr/libedit'))
->withUrl('https://thrysoee.dk/editline/libedit-20210910-3.1.tar.gz')
->withConfigure('./configure --prefix=/usr/libedit --enable-static --disable-shared')
->withLdflags('')
Expand All @@ -278,7 +262,7 @@ function install_libedit(Preprocessor $p)
function install_ncurses(Preprocessor $p)
{
$p->addLibrary(
(new Library('ncurses', '/usr'))
(new Library('ncurses'))
->withUrl('https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.3.tar.gz')
->withConfigure('./configure --prefix=/usr --enable-static --disable-shared')
->withLicense('https://github.com/projectceladon/libncurses/blob/master/README', Library::LICENSE_MIT)
Expand All @@ -289,7 +273,7 @@ function install_ncurses(Preprocessor $p)
function install_libsodium(Preprocessor $p)
{
$p->addLibrary(
(new Library('libsodium', '/usr'))
(new Library('libsodium'))
->withUrl('https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz')
->withConfigure('./configure --prefix=/usr --enable-static --disable-shared')
// ISC License, like BSD
Expand All @@ -301,7 +285,7 @@ function install_libsodium(Preprocessor $p)
function install_libyaml(Preprocessor $p)
{
$p->addLibrary(
(new Library('libyaml'))
(new Library('libyaml', '/usr/libyaml'))
->withUrl('http://pyyaml.org/download/libyaml/yaml-0.2.5.tar.gz')
->withConfigure('./configure --prefix=/usr/libyaml --enable-static --disable-shared')
->withPkgName('yaml-0.1')
Expand All @@ -312,13 +296,12 @@ function install_libyaml(Preprocessor $p)

function install_brotli(Preprocessor $p)
{
global $type;
$p->addLibrary(
(new Library('brotli'))
(new Library('brotli', '/usr/brotli'))
->withUrl('https://github.com/google/brotli/archive/refs/tags/v1.0.9.tar.gz')
->withFile('brotli-1.0.9.tar.gz')
->withConfigure("cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr/brotli .")
->withClearDylib($type === 'macos')
->withClearDylib($p->osType === 'macos')
->withPkgName('libbrotlicommon libbrotlidec libbrotlienc')
->withLicense('https://github.com/google/brotli/blob/master/LICENSE', Library::LICENSE_MIT)
->withHomePage('https://github.com/google/brotli')
Expand All @@ -328,7 +311,7 @@ function install_brotli(Preprocessor $p)
function install_curl(Preprocessor $p)
{
$p->addLibrary(
(new Library('curl'))
(new Library('curl', '/usr/curl'))
->withUrl('https://curl.se/download/curl-7.80.0.tar.gz')
->withConfigure("autoreconf -fi && ./configure --prefix=/usr/curl --enable-static --disable-shared --with-openssl=/usr/openssl " .
"--without-librtmp --without-brotli --without-libidn2 --disable-ldap --disable-rtsp --without-zstd --without-nghttp2 --without-nghttp3"
Expand Down Expand Up @@ -418,8 +401,7 @@ function install_curl(Preprocessor $p)
},
'swoole' => function ($p) {
$p->addExtension((new Extension('swoole'))
->withOptions('--enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares')
//->withOptions('--enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares --with-brotli-dir=/usr/brotli')
->withOptions('--enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares --disable-brotli')
->withLicense('https://github.com/swoole/swoole-src/blob/master/LICENSE', Extension::LICENSE_APACHE2)
->withHomePage('https://github.com/swoole/swoole-src')
);
Expand Down Expand Up @@ -467,10 +449,9 @@ function install_curl(Preprocessor $p)
];

$extCallback = [
'protobuf' => function () {
'protobuf' => function ($p) {
// compatible with redis
global $type;
if ($type === 'macos') {
if ($p->osType === 'macos') {
echo `sed -i '.bak' 's/arginfo_void,/arginfo_void_protobuf,/g' ext/protobuf/*.c ext/protobuf/*.h ext/protobuf/*.inc`;
echo `find ext/protobuf/ -name \*.bak | xargs rm -f`;
} else {
Expand Down
23 changes: 21 additions & 2 deletions sapi/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class Library extends Project
public string $prefix = '/usr';
public bool $clearDylib = false;

public function __construct(string $name, string $prefix = null)
public function __construct(string $name, string $prefix = '/usr')
{
$this->withPrefix($prefix ?? $this->prefix . '/' . $name);
$this->withPrefix($prefix);
parent::__construct($name);
}

Expand Down Expand Up @@ -148,6 +148,7 @@ function withPeclVersion(string $peclVersion): static

class Preprocessor
{
public string $osType;
protected array $libraryList = [];
protected array $extensionList = [];
protected string $rootDir;
Expand All @@ -167,6 +168,24 @@ function __construct(string $rootPath)
$this->rootDir = $rootPath;
$this->libraryDir = $rootPath . '/pool/lib';
$this->extensionDir = $rootPath . '/pool/ext';

switch (PHP_OS) {
default:
case 'Linux':
$this->setOsType('linux');
break;
case 'Darwin':
$this->setOsType('macos');
break;
case 'WINNT':
$this->setOsType('win');
break;
}
}

function setOsType(string $osType)
{
$this->osType = $osType;
}

function setPhpSrcDir(string $phpSrcDir)
Expand Down
2 changes: 1 addition & 1 deletion sapi/make.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
config_php() {
rm ./configure
./buildconf --force
<?php if (PHP_OS !== 'Darwin') : ?>
<?php if ($this->osType !== 'macos') : ?>
mv main/php_config.h.in /tmp/cnt
echo -ne '#ifndef __PHP_CONFIG_H\n#define __PHP_CONFIG_H\n' > main/php_config.h.in
cat /tmp/cnt >> main/php_config.h.in
Expand Down

0 comments on commit 252bbc2

Please sign in to comment.