Skip to content

Commit

Permalink
Merge pull request #672 from jingjingxyk/experiment_v4.8.x
Browse files Browse the repository at this point in the history
Experiment v4.8.x
  • Loading branch information
jingjingxyk committed Jul 6, 2024
2 parents 8b260f1 + 51d29d5 commit b246374
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 10 deletions.
3 changes: 1 addition & 2 deletions build-release-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if [ "$OS" = 'linux' ] ; then
if [ ! "$BASH_VERSION" ] ; then
echo "Please use bash to run this script ($0) " 1>&2
echo "fix : " 1>&2
echo "apk add bash OR sh sapi/quickstart/linux/alpine-init-mini.sh " 1>&2
echo "apk add bash OR sh sapi/quickstart/linux/alpine-init-minimal.sh " 1>&2
exit 1
fi
fi
Expand Down Expand Up @@ -218,7 +218,6 @@ fi

# 定制构建选项
OPTIONS="${OPTIONS} +apcu +ds +xlswriter +ssh2 +uuid "
OPTIONS="${OPTIONS} --with-libavif=1"
OPTIONS="${OPTIONS} --with-global-prefix=${LIBRARY_INSTALL_PREFIX}"
# OPTIONS="${OPTIONS} @macos"

Expand Down
3 changes: 3 additions & 0 deletions docs/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@
| inotify |||||
| protobuf |||||
| uuid |||||
| mailparse |||||
| mongodb |||||



2 changes: 1 addition & 1 deletion sapi/quickstart/linux/alpine-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ apk add libc++-static libltdl-static
apk add yasm nasm
apk add ninja python3 py3-pip
apk add diffutils
apk add netcat-openbsd
apk add netcat-openbsd socat
apk add python3-dev
apk add mercurial
apk add gettext-dev
Expand Down
2 changes: 1 addition & 1 deletion sapi/quickstart/linux/debian-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ apt install -y gcc g++ musl-tools libtool-bin autopoint
apt install -y python3 python3-pip ninja-build diffutils
apt install -y yasm nasm
apt install -y meson
apt install -y netcat-openbsd
apt install -y netcat-openbsd socat

case "$MIRROR" in
china | tuna | ustc)
Expand Down
2 changes: 1 addition & 1 deletion sapi/quickstart/linux/install-docker.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -exu
set -ex
__DIR__=$(
cd "$(dirname "$0")"
pwd
Expand Down
29 changes: 29 additions & 0 deletions sapi/quickstart/macos/macos-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,32 @@ brew uninstall --ignore-dependencies --force snappy
brew uninstall --ignore-dependencies --force capstone




brew install xz zip unzip gzip bzip2 7zip p7zip
brew install git ca-certificates

brew install yasm nasm
brew install ninja python3
brew install diffutils
brew install netcat socat
brew install mercurial


case "$MIRROR" in
china | tuna | ustc)
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
test "$MIRROR" = "ustc" && pip3 config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple
;;
tencentyun | huaweicloud)
test "$MIRROR" = "tencentyun" && pip3 config set global.index-url https://mirrors.tencentyun.com/pypi/simple/
test "$MIRROR" = "huaweicloud" && pip3 config set global.index-url https://repo.huaweicloud.com/pypi/simple/
esac

pip3 install meson


brew uninstall --ignore-dependencies --force snappy
brew uninstall --ignore-dependencies --force capstone


37 changes: 36 additions & 1 deletion sapi/src/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ public function setLogicalProcessors(string $logicalProcessors): static
return $this;
}

/**
* @param string $buildType 构建类型 [ release | dev | debug ]
* @return $this
*
*/
public function setBuildType(string $buildType): static
{
$this->buildType = $buildType;
Expand All @@ -351,33 +356,63 @@ public function getBuildType(): string
return $this->buildType;
}

/**
* 生成代理配置
* @param string $shell (http_proxy 代理配置 + no_proxy配置 )
* @param string $httpProxy (http 代理配置 )
* @return $this
*/
public function setProxyConfig(string $shell = '', string $httpProxy = ''): static
{
$this->proxyConfig = $shell;
$this->httpProxy = $httpProxy;
$proxyInfo = parse_url($httpProxy);
if (!empty($proxyInfo['scheme']) && !empty($proxyInfo['host']) && !empty($proxyInfo['port'])) {
$proto = '';
$socat_proxy_proto = '';

switch (strtolower($proxyInfo['scheme'])) {
case 'socks5':
case "socks5h":
$proto = 5;
$socat_proxy_proto = 'socks4a';
break;
case "socks4a":
case 'socks4':
$proto = 4;
$socat_proxy_proto = 'socks4a';
break;
default:
$proto = "connect";
$socat_proxy_proto = 'proxy';
break;
}

/*
* sockat 代理例子
* http://www.dest-unreach.org/socat/doc/socat.html
* socat - socks4a:<socks-server>::%h:%p,socksport=2000
* socat - proxy:<proxy-server>:%h:%p,proxyport=2000
*/

$socat_proxy_cmd = '';
if ($socat_proxy_proto == 'socks4a') {
$socat_proxy_cmd = "socat - socks4a:{$proxyInfo['host']}:\\$1:\\$2,socksport={$proxyInfo['port']}";
} else {
$socat_proxy_cmd = "socat - proxy:{$proxyInfo['host']}:\\$1:\\$2,proxyport={$proxyInfo['port']}";
}

$this->gitProxyConfig = <<<__GIT_PROXY_CONFIG_EOF
export GIT_PROXY_COMMAND=/tmp/git-proxy;
cat > \$GIT_PROXY_COMMAND <<___EOF___
#!/bin/bash
nc -X {$proto} -x {$proxyInfo['host']}:{$proxyInfo['port']} "\\$1" "\\$2"
# macos环境下 nc 不可用, 使用 socat 代替
# nc -X {$proto} -x {$proxyInfo['host']}:{$proxyInfo['port']} "\\$1" "\\$2"
{$socat_proxy_cmd};
___EOF___
chmod +x \$GIT_PROXY_COMMAND;
Expand Down
16 changes: 16 additions & 0 deletions sapi/src/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,34 @@ public function hashVerify(string $file): bool
return $this->hashVerify;
}

/**
* https 下载地址
* @param string $url
* @return $this
*/
public function withUrl(string $url): static
{
$this->url = $url;
return $this;
}

/**
* 指定下载的源码包名称
* @param string $file
* @return $this
*/
public function withFile(string $file): static
{
$this->file = $file;
return $this;
}

/**
* 使用脚本下载源码包
* @param string $downloadDirName 被打包压缩的的目录
* @param string $script 待执行的下载脚本
* @return $this
*/
public function withDownloadScript(string $downloadDirName, string $script): static
{
$this->enableDownloadScript = true;
Expand Down
12 changes: 10 additions & 2 deletions sapi/src/builder/extension/aaa_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

//默认这个名称应该和扩展名称一致、和本文件名称一致 ;
$ext = (new Extension('aaa_example'))

/*

//设置别名 ; 定义的名字和扩展名字不一致时,需要设置别名为扩展名称
Expand All @@ -37,7 +36,6 @@
->withLicense('https://github.com/swoole/swoole-src/blob/master/LICENSE', Extension::LICENSE_APACHE2)
->withHomePage('https://github.com/swoole/swoole-src')
->withManual('https://wiki.swoole.com/#/')

/*

//明确申明 使用源地址下载
Expand Down Expand Up @@ -135,4 +133,14 @@

return $cmd;
});

//导入环境变量

$p->withExportVariable('FREETYPE2_CFLAGS', '$(pkg-config --cflags --static libbrotlicommon libbrotlidec libbrotlienc freetype2 zlib libpng)');
$p->withExportVariable('FREETYPE2_LIBS', '$(pkg-config --libs --static libbrotlicommon libbrotlidec libbrotlienc freetype2 zlib libpng)');

$libiconv_prefix = ICONV_PREFIX;
$p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $libiconv_prefix . '/include');
$p->withVariable('LDFLAGS', '$LDFLAGS -L' . $libiconv_prefix . '/lib');
$p->withVariable('LIBS', '$LIBS -liconv');
};
16 changes: 16 additions & 0 deletions sapi/src/builder/extension/mailparse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use SwooleCli\Preprocessor;
use SwooleCli\Extension;

return function (Preprocessor $p) {
$p->addExtension(
(new Extension('mailparse'))
->withHomePage('https://pecl.php.net/package/mailparse')
->withLicense('https://github.com/php/pecl-mail-mailparse/blob/v3.1.6/LICENSE', Extension::LICENSE_BSD)
->withManual('https://github.com/php/pecl-mail-mailparse.git')
->withPeclVersion('3.1.6')
->withOptions(' --enable-mailparse ')
->withDependentExtensions('mbstring')
);
};
1 change: 1 addition & 0 deletions sapi/src/builder/extension/swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
->withBuildCached(false)
->withDependentLibraries(...$dependentLibraries)
->withDependentExtensions(...$dependentExtensions);

$p->addExtension($ext);

$libs = $p->isMacos() ? '-lc++' : ' -lstdc++ ';
Expand Down
4 changes: 2 additions & 2 deletions sapi/src/builder/library/pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
(new Library('pgsql'))
->withHomePage('https://www.postgresql.org/')
->withLicense('https://www.postgresql.org/about/licence/', Library::LICENSE_SPEC)
->withUrl('https://ftp.postgresql.org/pub/source/v16.0/postgresql-16.0.tar.gz')
->withUrl('https://ftp.postgresql.org/pub/source/v16.3/postgresql-16.3.tar.gz')
->withManual('https://www.postgresql.org/docs/current/install-procedure.html#CONFIGURE-OPTIONS')
->withManual('https://www.postgresql.org/docs/current/install-procedure.html#CONFIGURE-OPTIONS#:~:text=Client-only%20installation')
->withFileHash('md5', '30baf5fda60a34230d89c1451119ff91')
->withFileHash('md5', '8a58db4009e1a50106c5e1a8c4b03bed')
->withPrefix($pgsql_prefix)
->withBuildScript(
<<<EOF
Expand Down

0 comments on commit b246374

Please sign in to comment.