Skip to content

Commit 79639de

Browse files
committed
解决macos 环境 线程屏障 pthread_barrierattr_t 找不到
1 parent 35ef9bb commit 79639de

File tree

1 file changed

+42
-28
lines changed

1 file changed

+42
-28
lines changed

sapi/src/builder/extension/swoole.php

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -98,39 +98,53 @@
9898
$p->withExportVariable('ZSTD_LIBS', '$(pkg-config --libs --static libzstd)');
9999

100100
$p->withExportVariable('SWOOLE_ODBC_LIBS', '$(pkg-config --libs-only-L --libs-only-l --static odbc odbccr odbcinst readline ncursesw ) ' . " -L{$libiconv_prefix}/lib -liconv ");
101+
/*
102+
$p->withBeforeConfigureScript('swoole', function () use ($p) {
103+
$workDir = $p->getWorkDir();
104+
$shell = "set -x ;cd {$workDir} ; WORKDIR={$workDir} ;" . PHP_EOL;
105+
$shell .= <<<'EOF'
106+
SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf")
107+
CURRENT_SWOOLE_VERSION=''
108+
109+
if [ -f "ext/swoole/CMakeLists.txt" ] ;then
110+
CURRENT_SWOOLE_VERSION=$(grep 'set(SWOOLE_VERSION' ext/swoole/CMakeLists.txt | awk '{ print $2 }' | sed 's/)//')
111+
if [[ "${CURRENT_SWOOLE_VERSION}" =~ "-dev" ]]; then
112+
echo 'swoole version master'
113+
if [ -n "${GITHUB_ACTION}" ]; then
114+
test -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz && rm -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz
115+
CURRENT_SWOOLE_VERSION=''
116+
fi
117+
fi
101118
102-
$p->withBeforeConfigureScript('swoole', function () use ($p) {
103-
$workDir = $p->getWorkDir();
104-
$shell = "set -x ;cd {$workDir} ; WORKDIR={$workDir} ;" . PHP_EOL;
105-
$shell .= <<<'EOF'
106-
/*
107-
SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf")
108-
CURRENT_SWOOLE_VERSION=''
109-
110-
if [ -f "ext/swoole/CMakeLists.txt" ] ;then
111-
CURRENT_SWOOLE_VERSION=$(grep 'set(SWOOLE_VERSION' ext/swoole/CMakeLists.txt | awk '{ print $2 }' | sed 's/)//')
112-
if [[ "${CURRENT_SWOOLE_VERSION}" =~ "-dev" ]]; then
113-
echo 'swoole version master'
114-
if [ -n "${GITHUB_ACTION}" ]; then
115-
test -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz && rm -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz
116-
CURRENT_SWOOLE_VERSION=''
119+
if [ "${SWOOLE_VERSION}" != "${CURRENT_SWOOLE_VERSION}" ] ;then
120+
test -d ext/swoole && rm -rf ext/swoole
121+
if [ ! -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz ] ;then
122+
test -d /tmp/swoole && rm -rf /tmp/swoole
123+
git clone -b "${SWOOLE_VERSION}" https://github.com/swoole/swoole-src.git /tmp/swoole
124+
cd /tmp/swoole
125+
rm -rf /tmp/swoole/.git/
126+
tar -czvf ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz .
117127
fi
118128
fi
129+
# swoole extension hook
130+
cd {$workDir}
131+
sed -i '' 's/pthread_barrier_init/pthread_barrier_init_x_fake/' ext/swoole/config.m4
119132
120-
if [ "${SWOOLE_VERSION}" != "${CURRENT_SWOOLE_VERSION}" ] ;then
121-
test -d ext/swoole && rm -rf ext/swoole
122-
if [ ! -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz ] ;then
123-
test -d /tmp/swoole && rm -rf /tmp/swoole
124-
git clone -b "${SWOOLE_VERSION}" https://github.com/swoole/swoole-src.git /tmp/swoole
125-
cd /tmp/swoole
126-
rm -rf /tmp/swoole/.git/
127-
tar -czvf ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz .
128-
fi
129-
fi
130-
*/
133+
EOF;
134+
135+
return $shell;
136+
});
137+
*/
138+
$p->withBeforeConfigureScript('swoole', function () use ($p) {
139+
$workDir = $p->getWorkDir();
140+
$shell = "set -x ;cd {$workDir} ; WORKDIR={$workDir} ; IS_MACOS={$p->isMacos()}" . PHP_EOL;
141+
142+
$shell .= <<<'EOF'
131143
# swoole extension hook
132-
cd {$workDir}
133-
sed -i '' 's/pthread_barrier_init/pthread_barrier_init_x_fake/' ext/swoole/config.m4
144+
cd ${WORKDIR}
145+
if [ ${IS_MACOS} -eq 1 ];then
146+
sed -i '' 's/pthread_barrier_init/pthread_barrier_init_x_fake/' ext/swoole/config.m4
147+
fi
134148

135149
EOF;
136150

0 commit comments

Comments
 (0)