Skip to content

Commit

Permalink
merge code
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingxyk committed Jul 9, 2024
2 parents 54bee6a + 98f7dea commit 4400f6d
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 42 deletions.
84 changes: 44 additions & 40 deletions sapi/scripts/cygwin/cygwin-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,51 @@ cd ${__PROJECT__}
./buildconf --force
test -f Makefile && make clean
./configure --prefix=/usr --disable-all \
--disable-fiber-asm \
--enable-opcache \
--without-pcre-jit \
--with-openssl --enable-openssl \
--with-curl \
--with-iconv \
--enable-intl \
--with-bz2 \
--enable-bcmath \
--enable-filter \
--enable-session \
--enable-tokenizer \
--enable-mbstring \
--enable-ctype \
--with-zlib \
--with-zip \
--enable-posix \
--enable-sockets \
--enable-pdo \
--with-sqlite3 \
--enable-phar \
--enable-pcntl \
--enable-mysqlnd \
--with-mysqli \
--enable-fileinfo \
--with-pdo_mysql \
--enable-soap \
--with-xsl \
--with-gmp \
--enable-exif \
--with-sodium \
--enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \
--enable-gd --with-jpeg --with-freetype \
--enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares \
--enable-swoole-pgsql \
--enable-swoole-sqlite \
--enable-redis \
--with-imagick \
--with-yaml \
--with-readline
--disable-fiber-asm \
--without-pcre-jit \
--with-openssl --enable-openssl \
--with-curl \
--with-iconv \
--enable-intl \
--with-bz2 \
--enable-bcmath \
--enable-filter \
--enable-session \
--enable-tokenizer \
--enable-mbstring \
--enable-ctype \
--with-zlib \
--with-zip \
--enable-posix \
--enable-sockets \
--enable-pdo \
--with-sqlite3 \
--enable-phar \
--enable-pcntl \
--enable-mysqlnd \
--with-mysqli \
--enable-fileinfo \
--with-pdo_mysql \
--enable-soap \
--with-xsl \
--with-gmp \
--enable-exif \
--with-sodium \
--enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \
--enable-gd --with-jpeg --with-freetype \
--enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares \
--enable-swoole-pgsql \
--enable-swoole-sqlite \
--enable-swoole-thread \
--enable-zts \
--enable-redis \
--with-imagick \
--with-yaml \
--with-readline


# --with-pdo-pgsql \
# --with-pgsql
# --with-pdo-sqlite \
# --enable-opcache \

2 changes: 1 addition & 1 deletion sapi/src/UnitTest/MainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testExtesnions(): void
$this->assertContains('swoole', $exts);
$this->assertContains('gd', $exts);
$this->assertContains('imagick', $exts);
$this->assertContains('opcache', $exts);
# $this->assertContains('opcache', $exts);
$this->assertContains('redis', $exts);
$this->assertContains('mongodb', $exts);
}
Expand Down
83 changes: 83 additions & 0 deletions sapi/src/builder/extension/swoole_v6.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

use SwooleCli\Preprocessor;
use SwooleCli\Extension;

return function (Preprocessor $p) {

$swoole_tag = 'v6.0';
$file = "swoole-{$swoole_tag}.tar.gz";

$url = "https://github.com/swoole/swoole-src/archive/refs/tags/{$swoole_tag}.tar.gz";

$dependentLibraries = ['curl', 'openssl', 'cares', 'zlib', 'brotli', 'nghttp2', 'sqlite3', 'unix_odbc', 'pgsql'];
$dependentExtensions = ['curl', 'openssl', 'sockets', 'mysqlnd', 'pdo'];
$options = ' --enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares ';
$options .= ' --enable-swoole-coro-time ';
# $options .= ' --enable-thread-context ';
$options .= ' --with-brotli-dir=' . BROTLI_PREFIX;
$options .= ' --with-nghttp2-dir=' . NGHTTP2_PREFIX;
$options .= ' --enable-swoole-pgsql ';
$options .= ' --enable-swoole-sqlite ';
$options .= ' --with-swoole-odbc=unixODBC,' . UNIX_ODBC_PREFIX . ' ';
$options .= ' --enable-swoole-thread ';
$options .= ' --enable-zts ';

//linux 环境下 启用 opcache 扩展时构建报错,需要禁用 opcache

if ($p->isLinux() && 0) {
// 构建报错
$options .= ' --enable-iouring ';
$dependentLibraries[] = 'liburing';
$p->withExportVariable('URING_CFLAGS', '$(pkg-config --cflags --static liburing)');
$p->withExportVariable('URING_LIBS', '$(pkg-config --libs --static liburing)');
}


$ext = (new Extension('swoole_v6'))
->withHomePage('https://github.com/swoole/swoole-src')
->withLicense('https://github.com/swoole/swoole-src/blob/master/LICENSE', Extension::LICENSE_APACHE2)
->withManual('https://wiki.swoole.com/#/')
->withOptions($options)
->withBuildCached(false)
->withDependentLibraries(...$dependentLibraries)
->withDependentExtensions(...$dependentExtensions);

$p->addExtension($ext);

$libs = $p->isMacos() ? '-lc++' : ' -lstdc++ ';
$p->withVariable('LIBS', '$LIBS ' . $libs);

$p->withExportVariable('CARES_CFLAGS', '$(pkg-config --cflags --static libcares)');
$p->withExportVariable('CARES_LIBS', '$(pkg-config --libs --static libcares)');


// 使用扩展钩子 下载 swoole v6 源码
$p->withBeforeConfigureScript('swoole_v6', function (Preprocessor $p) {
$workdir = $p->getWorkDir();
$cmd = <<<EOF
cd {$workdir}
if [ -d {$workdir}/ext/swoole ] ; then
rm -rf {$workdir}/ext/swoole
fi
mkdir -p {$workdir}/ext/
mkdir -p {$workdir}/var/cache/ext/
cd {$workdir}/var/cache/ext/
test -d swoole && rm -rf swoole
if [ -f {$workdir}/pool/ext/swoole-v6.0.0.tar.gz ] ; then
mkdir swoole
tar --strip-components=1 -C swoole -xf {$workdir}/pool/ext/swoole-v6.0.0.tar.gz
else
git clone -b master https://github.com/swoole/swoole-src.git swoole
cd swoole
tar -zcf {$workdir}/pool/ext/swoole-v6.0.0.tar.gz ./
cd {$workdir}/var/cache/ext/
fi
cd {$workdir}/var/cache/ext/
mv swoole {$workdir}/ext/
EOF;

//return $cmd;
return '';
});
};
1 change: 0 additions & 1 deletion sapi/src/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,3 @@

define("EXAMPLE_PREFIX", $p->getGlobalPrefix() . '/example');


0 comments on commit 4400f6d

Please sign in to comment.