Skip to content

Commit eb65643

Browse files
committed
merge code
2 parents f89fdd2 + 5c29113 commit eb65643

File tree

13 files changed

+122
-67
lines changed

13 files changed

+122
-67
lines changed

docs/extensions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@
5050
| protobuf |||||
5151
| uuid |||||
5252
| mailparse |||||
53-
| gettext || |||
53+
| gettext || |||
5454
| xslwriter |||||
55+
| odbc |||||
56+
| pdo_odbc |||||
5557

5658
## 查看 新增的扩展 和 移除的扩展
5759

sapi/quickstart/clean-folder.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ __PROJECT__=$(
1111
)
1212
cd ${__PROJECT__}
1313

14-
if [ ! "$BASH_VERSION" ] ; then
15-
echo "Please use bash to run this script (bash $0)" 1>&2
16-
exit 1
14+
if [ ! "$BASH_VERSION" ]; then
15+
echo "Please use bash to run this script (bash $0)" 1>&2
16+
exit 1
1717
fi
1818

1919
if [[ -f /.dockerenv ]]; then
@@ -24,17 +24,17 @@ GIT_BRANCH=$(git branch | grep '* ' | awk '{print $2}')
2424
echo $GIT_BRANCH
2525
ACTION="none"
2626
case $GIT_BRANCH in
27-
'build_native_php' | 'build_native_php_t' )
27+
'build_native_php' | 'build_native_php_t')
2828
ACTION="delete"
2929
;;
30-
'build_php_8.2' | 'build_php_8.1' | 'build_php_8.0' | 'build_php_7.4' | 'build_php_7.3' )
30+
'build_php_8.2' | 'build_php_8.1' | 'build_php_8.0' | 'build_php_7.4' | 'build_php_7.3')
3131
ACTION="delete"
3232
;;
3333
'build_native_php_sfx_micro')
3434
ACTION="delete"
3535
;;
3636
*)
37-
if git ls-files --error-unmatch "sapi/quickstart/clean-folder.sh" > /dev/null 2>&1 ; then
37+
if git ls-files --error-unmatch "sapi/quickstart/clean-folder.sh" >/dev/null 2>&1; then
3838
ACTION="delete"
3939
else
4040
echo 'no need delete ext '
@@ -43,8 +43,6 @@ case $GIT_BRANCH in
4343

4444
esac
4545

46-
47-
4846
if [[ $ACTION = "delete" ]]; then
4947
cd ${__PROJECT__}
5048
test -d ext/ && rm -rf ext/*
@@ -74,5 +72,16 @@ if [[ $ACTION = "delete" ]]; then
7472
test -f conftest.c && rm -rf conftest.c
7573
test -d scripts && rm -rf scripts
7674
test -d sapi/cli && rm -rf sapi/cli/
75+
test -f APP_VERSION && rm -f APP_VERSION
76+
test -f composer.lock && rm -f composer.lock
77+
test -f .gitmodules && rm -f .gitmodules
78+
test -f cppflags.log && rm -f cppflags.log
79+
test -f ldflags.log && rm -f ldflags.log
80+
test -f libs.log && rm -f libs.log
81+
test -f make.sh && rm -f make.sh
82+
test -f make-env.sh && rm -f make-env.sh
83+
test -f make-export-variables.sh && rm -f make-export-variables.sh
84+
test -f make-install-deps.sh && rm -f make-install-deps.sh
85+
test -f libs.log && rm -f libs.log
7786
echo $?
7887
fi

sapi/quickstart/linux/alpine-init.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,14 @@ apk update
4343
apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c coreutils gcc g++
4444
apk add bash zip unzip flex pkgconf ca-certificates
4545
apk add tar gzip zip unzip bzip2
46+
apk add 7zip
4647
apk add gettext gettext-dev
47-
48-
apk add bash 7zip
49-
# apk add bash p7zip
50-
5148
apk add wget git curl
5249
apk add libc++-static libltdl-static
5350
apk add yasm nasm
5451
apk add ninja python3 py3-pip
5552
apk add diffutils
56-
apk add netcat-openbsd socat
53+
apk add socat
5754
apk add python3-dev
5855
apk add mercurial
5956
apk add pigz parallel

sapi/src/Preprocessor.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,19 @@ public function withPreInstallCommand(string $os, string $preInstallCommand): st
785785
return $this;
786786
}
787787

788+
protected array $frameworks = [];
789+
790+
public function withFramework(string $framework): static
791+
{
792+
if (!$this->isMacos()) {
793+
throw new RuntimeException('frameworks only support macOS');
794+
}
795+
if (!in_array($framework, $this->frameworks)) {
796+
$this->frameworks[] = $framework;
797+
}
798+
return $this;
799+
}
800+
788801
public function getExtension(string $name): ?Extension
789802
{
790803
if (!isset($this->extensionMap[$name])) {

sapi/src/builder/enabled_extensions.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@
4646
'pgsql',
4747
'pdo_pgsql',
4848
'xlswriter',
49+
'gettext',
50+
'phpy'
4951
];
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
use SwooleCli\Preprocessor;
4+
use SwooleCli\Extension;
5+
6+
return function (Preprocessor $p) {
7+
$unixODBC_prefix = UNIX_ODBC_PREFIX;
8+
$p->addExtension(
9+
(new Extension('odbc'))
10+
->withHomePage('https://www.php.net/manual/zh/ref.pdo-odbc.php')
11+
->withLicense('https://github.com/php/php-src/blob/master/LICENSE', Extension::LICENSE_PHP)
12+
->withOptions('--with-unixODBC=' . $unixODBC_prefix)
13+
->withDependentLibraries('unix_odbc')
14+
);
15+
};

sapi/src/builder/extension/opentelemetry.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
use SwooleCli\Extension;
66

77
return function (Preprocessor $p) {
8-
return null;//待改进
9-
//PHP 构建选项
108
$options = ' --enable-opentelemetry ';
11-
129
$ext = (new Extension('opentelemetry'))
1310
->withOptions($options)
1411
->withHomePage('https://opentelemetry.io/')
@@ -24,5 +21,15 @@
2421
2522
EOF
2623
);
24+
$p->withBeforeConfigureScript('opentelemetry', function (Preprocessor $p) {
25+
$workDir = $p->getPhpSrcDir();
26+
$cmd=<<<EOF
27+
cd {$workDir}/ext/opentelemetry/
28+
29+
sed -i '' 's/static void check_conflicts()/static void check_conflicts(void)/' opentelemetry.c
30+
sed -i '' 's/static otel_observer \*create_observer()/static otel_observer \*create_observer(void)/' otel_observer.c
31+
EOF;
32+
return $cmd;
33+
});
2734
$p->addExtension($ext);
2835
};

sapi/src/builder/extension/phpy.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,26 @@
88
// anaconda 安装包
99
// https://repo.anaconda.com/archive/
1010

11-
# $options .= ' --with-python-version=3.12';
12-
# $options .= ' --with-python-dir=/opt/anaconda3';
11+
// $options .= ' --with-python-version=3.12';
12+
// $options .= ' --with-python-dir=/opt/anaconda3';
1313

1414
$tag = 'v1.0.11';
1515

16-
1716
$python3_prefix = PYTHON3_PREFIX;
1817
$options = [];
1918
$options[] = '--enable-phpy';
2019
$options[] = ' --with-python-version=3.12.2';
2120
$options[] = ' --with-python-dir=' . $python3_prefix;
2221
$options[] = ' --with-python-config=' . $python3_prefix . '/bin/python3-config';
2322

24-
2523
$dependentLibraries = ['python3'];
2624
$dependentExtensions = [];
2725

28-
2926
$ext = (new Extension('phpy'))
3027
->withOptions(implode(' ', $options))
3128
->withLicense('https://github.com/swoole/phpy/blob/main/LICENSE', Extension::LICENSE_APACHE2)
3229
->withHomePage('https://github.com/swoole/phpy/')
3330
->withManual('https://github.com/swoole/phpy/')
34-
->withBuildCached(false)
3531
->withFile('phpy-latest.tar.gz')
3632
->withDownloadScript(
3733
'phpy', # 待打包目录名称
@@ -44,21 +40,7 @@
4440
->withDependentLibraries(...$dependentLibraries);
4541
$p->addExtension($ext);
4642

47-
$p->withBeforeConfigureScript('phpy', function (Preprocessor $p) {
48-
$workDir = $p->getPhpSrcDir();
49-
$cmd = <<<EOF
50-
51-
cd {$workDir}/
52-
sed -i.backup "s/ -z now/ /g" ext/phpy/config.m4
53-
rm -f ext/phpy/config.m4.backup
54-
EOF;
55-
56-
return $cmd;
57-
});
58-
59-
6043
$libs = $p->isMacos() ? '-lc++' : ' -lstdc++ ';
6144
$p->withVariable('LIBS', '$LIBS ' . $libs);
62-
//$p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $p->getWorkDir() . '/ext/phpy/include');
6345
$p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $p->getPhpSrcDir() . '/ext/phpy/include');
6446
};

sapi/src/builder/extension/swoole.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// v5.1.x 不支持 PHP 8.4
1515
// swoole 支持计划 https://wiki.swoole.com/zh-cn/#/version/supported?id=%e6%94%af%e6%8c%81%e8%ae%a1%e5%88%92
1616

17-
$swoole_tag = 'v6.0.1';
17+
$swoole_tag = 'v6.0.2';
1818
$file = "swoole-{$swoole_tag}.tar.gz";
1919

2020
$url = "https://github.com/swoole/swoole-src/archive/refs/tags/{$swoole_tag}.tar.gz";
@@ -67,6 +67,35 @@
6767
->withDependentLibraries(...$dependentLibraries)
6868
->withDependentExtensions(...$dependentExtensions));
6969

70+
$p->withBeforeConfigureScript('swoole', function (Preprocessor $p) {
71+
$cmd = '';
72+
if ($p->isMacos()) {
73+
$workDir = $p->getPhpSrcDir() ;
74+
$cmd = <<<EOF
75+
cd {$workDir}/
76+
sed -i '' 's/pthread_barrier_init/pthread_barrier_init_x_fake/' ext/swoole/config.m4
77+
EOF;
78+
}
79+
return $cmd;
80+
81+
});
82+
if ($p->isMacos()) {
83+
# 测试 macos 专有特性
84+
# 定义 _GNU_SOURCE 会隐式启用 _POSIX_C_SOURCE=200112L 和 _XOPEN_SOURCE=600
85+
# export CFLAGS="$CFLAGS " # -D_DARWIN_C_SOURCE=1 -D_XOPEN_SOURCE=700 -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L
86+
# export LIBS="-Wl,--start-group -pthread -Wl,--end-group"
87+
# export LIBS="-Wl,--whole-archive -pthread -Wl,--no-whole-archive "
88+
89+
# 新版macos getdtablesize 函数缺失
90+
# sed -i '' 's/getdtablesize();/sysconf(_SC_OPEN_MAX);/' ext/standard/php_fopen_wrapper.c
91+
$libc = $p->isMacos() ? '-lc++' : '-lstdc++';
92+
93+
# cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread
94+
# 或者
95+
# cd /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/sys/_pthread
96+
# grep -r 'pthread_barrier_init' .
97+
# grep -r 'pthread_barrier_t' .
98+
}
7099
$p->withVariable('LIBS', '$LIBS ' . ($p->isMacos() ? '-lc++' : '-lstdc++'));
71100
$p->withExportVariable('CARES_CFLAGS', '$(pkg-config --cflags --static libcares)');
72101
$p->withExportVariable('CARES_LIBS', '$(pkg-config --libs --static libcares)');

sapi/src/builder/library/gettext.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
return function (Preprocessor $p) {
77

88
// gettext 包含 libintl 库
9-
//在常见的 Linux 发行版里,libintl 是由 libc 提供的,此时 gettext 编译的时候就不会附带 libintl;
10-
//而如果在 macOS 上,由于 macOS 的 libc 没有 libintl 的 API,所以 gettext 编译的时候就要附带 libintl
11-
//详情: https://jia.je/devops/2023/07/08/gentoo-prefix-m1/#libintl
9+
// 在常见的 Linux 发行版里,libintl 是由 libc 提供的,此时 gettext 编译的时候就不会附带 libintl;
10+
// 而如果在 macOS 上,由于 macOS 的 libc 没有 libintl 的 API,所以 gettext 编译的时候就要附带 libintl
11+
// 详情: https://jia.je/devops/2023/07/08/gentoo-prefix-m1/#libintl
1212
$gettext_prefix = GETTEXT_PREFIX;
1313
$libunistring_prefix = LIBUNISTRING_PREFIX;
1414
$iconv_prefix = ICONV_PREFIX;
@@ -24,11 +24,9 @@
2424
->withHomePage('https://www.gnu.org/software/gettext/')
2525
->withLicense('https://www.gnu.org/licenses/licenses.html', Library::LICENSE_GPL)
2626
->withManual('https://www.gnu.org/software/gettext/')
27-
//->withUrl('https://ftp.gnu.org/gnu/gettext/gettext-0.22.5.tar.gz')
2827
->withUrl('https://ftpmirror.gnu.org/gettext/gettext-0.22.5.tar.gz')
2928
->withFileHash('sha256', "ec1705b1e969b83a9f073144ec806151db88127f5e40fe5a94cb6c8fa48996a0")
3029
->withPrefix($gettext_prefix)
31-
//->withInstallCached(false)
3230
->withConfigure(
3331
<<<EOF
3432
@@ -75,6 +73,6 @@
7573
$p->withVariable('LDFLAGS', '$LDFLAGS -L' . $gettext_prefix . '/lib');
7674
$p->withVariable('LIBS', '$LIBS -lintl ');
7775
if ($p->isMacos()) {
78-
$p->withVariable('LDFLAGS', '$LDFLAGS -framework CoreFoundation ');
76+
$p->withFramework('CoreFoundation');
7977
}
8078
};

0 commit comments

Comments
 (0)