Skip to content

Commit 169a7b0

Browse files
committed
merge code
2 parents 4849c41 + ddec7c6 commit 169a7b0

12 files changed

Lines changed: 417 additions & 9 deletions

.github/workflows/linux-glibc.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: build-swoole-cli-linux-glibc-x86_64
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
linux-glibc:
7+
if: ${{ !contains(github.event.head_commit.message, '--filter=') || contains(github.event.head_commit.message, '[linux-glibc]') }}
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os: [ ubuntu-22.04, ubuntu-22.04-arm ]
12+
name: linux-glibc-${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Show Environment Info
17+
run: |
18+
echo $PATH
19+
env
20+
docker info
21+
id -u
22+
id -g
23+
who
24+
cat /etc/os-release
25+
hostnamectl
26+
uname -s
27+
uname -m
28+
uname -r
29+
30+
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
31+
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
32+
cat /proc/cpuinfo | grep "cpu cores" | uniq
33+
cat /proc/cpuinfo| grep "processor"| wc -l
34+
lscpu
35+
36+
export IPV6=$(ip -6 address show | grep inet6 | awk '{print $2}' | cut -d'/' -f1 | sed -n '2p')
37+
export IPV4=$(ip -4 address show | grep inet | grep -v 127.0.0 | awk '{print $2}' | cut -d'/' -f1 | sed -n '1p')
38+
echo $IPV4
39+
echo $IPV6
40+
echo "X_IPV6=${IPV6}" >> $GITHUB_ENV
41+
echo "X_IPV4=${IPV4}" >> $GITHUB_ENV
42+
43+
- name: Prepare Build Environment
44+
run: |
45+
git submodule update --init
46+
47+
sudo mkdir -p /usr/local/swoole-cli
48+
uid=$(id -u) && gid=$(id -g) && sudo chown -R ${uid}:${gid} /usr/local/swoole-cli
49+
50+
mkdir -p ${{ github.workspace }}/var/build-github-action-container/
51+
52+
- name: Cache PHP Runtime
53+
uses: actions/cache@v4
54+
id: php-runtime-cache-x86_64
55+
with:
56+
path: ${{ github.workspace }}/runtime
57+
key: ${{ runner.os }}-x86_64-php-runtime
58+
59+
- name: Cache PHP Vendor
60+
uses: actions/cache@v4
61+
id: php-vendor-cache-x86_64
62+
with:
63+
path: ${{ github.workspace }}/vendor
64+
key: ${{ runner.os }}-x86_64-php-vendor
65+
66+
- name: Cache Dependency Source Code Tarball
67+
uses: actions/cache@v4
68+
id: pool-cache
69+
with:
70+
path: ${{ github.workspace }}/pool/
71+
key: source-code-tarball-pool
72+
73+
- name: Cache all-library
74+
uses: actions/cache@v4
75+
id: all-library-cache-x86_64
76+
with:
77+
path: /usr/local/swoole-cli
78+
key: ${{ github.head_ref || github.ref_name }}-${{ runner.os }}-x86_64-all-library
79+
80+
- name: Prepare Runtime and Libraries and Extensions
81+
run: |
82+
set -x
83+
mkdir -p pool/lib
84+
mkdir -p pool/ext
85+
mkdir -p bin/
86+
mkdir -p runtime/
87+
test -f runtime/php && rm -f runtime/php
88+
if [ ! -f runtime/php/php ] ; then
89+
bash setup-php-runtime.sh
90+
fi
91+
bash sapi/download-box/download-box-get-archive-from-server.sh
92+
ls -A pool/lib/
93+
ls -A /usr/local/swoole-cli/
94+
95+
- name: Build
96+
run: |
97+
set -eux
98+
uname -m
99+
composer install --no-interaction --no-autoloader --no-scripts --profile
100+
composer dump-autoload --optimize --profile
101+
102+
php prepare.php --with-libavif
103+
104+
sudo apt update
105+
bash ./sapi/scripts/install-deps-on-ubuntu.sh
106+
bash ./ext/swoole/scripts/install-deps-on-ubuntu.sh
107+
bash ./sapi/scripts/build-swoole-cli-with-linux-gcc.sh
108+
109+
./bin/swoole-cli -v
110+
./bin/swoole-cli -m
111+
./bin/swoole-cli --ri curl
112+
./bin/swoole-cli --ri gd
113+
./bin/swoole-cli --ri imagick
114+
./bin/swoole-cli --ri swoole
115+
{ ldd ./bin/swoole-cli ; } || { echo $? ; } ;
116+
file ./bin/swoole-cli
117+
118+
- name: Make nfpm package
119+
run: |
120+
ARCH=$(uname -m)
121+
if [ "$ARCH" = "aarch64" ]; then
122+
NFPM_ARCH="arm64"
123+
else
124+
NFPM_ARCH="amd64"
125+
fi
126+
wget https://github.com/goreleaser/nfpm/releases/download/v2.43.4/nfpm_2.43.4_${NFPM_ARCH}.deb
127+
sudo dpkg -i nfpm_2.43.4_${NFPM_ARCH}.deb
128+
strip ./bin/swoole-cli
129+
./make.sh nfpm-pkg
130+
ls -ls ./*.deb
131+
ls -ls ./*.rpm
132+
133+
- name: upload artifacts to cloud object storage
134+
if: ${{ (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }}
135+
env:
136+
OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
137+
OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
138+
OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }}
139+
OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }}
140+
run: |
141+
ARCH=$(uname -m)
142+
if [ "$ARCH" = "aarch64" ]; then
143+
FILE_ARCH="arm64"
144+
else
145+
FILE_ARCH="x64"
146+
fi
147+
SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf")
148+
OS="linux"
149+
bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-"${SWOOLE_VERSION}-${OS}-${FILE_ARCH}"-glibc.deb
150+
bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-"${SWOOLE_VERSION}-${OS}-${FILE_ARCH}"-glibc.rpm

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,6 @@ php-fpm-*
348348
!/runtime/.gitkeep
349349
/APP_NAME
350350
/APP_VERSION
351+
*.deb
352+
*.rpm
353+
nfpm-pkg.yaml

prepare.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@
3535
// Sync code from php-src
3636
$p->setPhpSrcDir($p->getWorkDir() . '/var/php-' . BUILD_PHP_VERSION);
3737

38+
3839
// Compile directly on the host machine, not in the docker container
3940
if ($p->getInputOption('without-docker') || ($p->isMacos())) {
4041
$p->setWorkDir(__DIR__);
4142
$p->setBuildDir(__DIR__ . '/thirdparty');
4243
}
4344

44-
4545
if ($p->getInputOption('with-override-default-enabled-ext')) {
4646
$p->setExtEnabled([]);
4747
}
4848

49-
5049
if ($p->getInputOption('with-global-prefix')) {
5150
$p->setGlobalPrefix($p->getInputOption('with-global-prefix'));
5251
}

sapi/SWOOLE-VERSION.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v6.1.1
1+
v6.1.3

sapi/scripts/build-swoole-cli-with-linux-gcc.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
./configure --prefix=/usr --disable-all \
1+
if [ ! -f ./configure ]; then
2+
./buildconf --force
3+
fi
4+
5+
./configure --prefix=/usr/local/swoole-cli \
6+
--disable-all \
27
--enable-zts \
38
--without-pcre-jit \
49
--with-openssl --enable-openssl \
@@ -31,17 +36,20 @@
3136
--with-sodium \
3237
--enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \
3338
--enable-gd --with-jpeg --with-freetype \
34-
--enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares \
39+
--enable-swoole \
40+
--enable-swoole-curl \
41+
--enable-cares \
3542
--enable-swoole-pgsql \
3643
--enable-swoole-sqlite \
44+
--with-swoole-odbc=unixODBC,/usr \
3745
--enable-swoole-thread \
46+
--enable-swoole-stdext \
3847
--enable-brotli \
3948
--enable-zstd \
40-
--enable-swoole-stdext \
4149
--enable-redis \
4250
--with-imagick \
4351
--with-yaml \
4452
--with-readline \
4553
--enable-opcache
4654

47-
make -j "$(nproc)"
55+
make -j "$(nproc)"

sapi/scripts/copy-depend-libs.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
/**
3+
* Copy shared library dependencies of swoole-cli to runtime/libs directory
4+
*/
5+
6+
// Define paths
7+
$binaryPath = __DIR__ . '/../../bin/swoole-cli';
8+
$targetDir = __DIR__ . '/../../runtime/libs';
9+
10+
// Libraries that should be ignored (system/core libraries)
11+
$ignoredLibraries = [
12+
'libc.so',
13+
'libm.so',
14+
'libpthread.so',
15+
'libdl.so',
16+
'librt.so',
17+
'ld-linux',
18+
];
19+
20+
// Check if binary exists
21+
if (!file_exists($binaryPath)) {
22+
echo "Error: Binary file not found at $binaryPath\n";
23+
exit(1);
24+
}
25+
26+
// Create target directory if it doesn't exist
27+
if (!is_dir($targetDir)) {
28+
mkdir($targetDir, 0755, true) || die("Error: Failed to create directory $targetDir\n");
29+
echo "Created directory: $targetDir\n";
30+
}
31+
32+
$binaryPath = realpath($binaryPath);
33+
$targetDir = realpath($targetDir);
34+
35+
// Get dependencies using ldd
36+
echo "Getting dependencies for $binaryPath...\n";
37+
$lddOutput = shell_exec('ldd ' . escapeshellarg($binaryPath));
38+
39+
if (empty($lddOutput)) {
40+
echo "Error: Failed to get dependencies\n";
41+
exit(1);
42+
}
43+
44+
// Parse ldd output
45+
$dependencies = [];
46+
$lines = explode("\n", $lddOutput);
47+
48+
foreach ($lines as $line) {
49+
// Match lines with => (typical ldd output)
50+
if (preg_match('/^\s*.*\s+=>\s+(\/.*)\s+\(0x[0-9a-f]+\)$/', $line, $matches)) {
51+
$libPath = trim($matches[1]);
52+
if (file_exists($libPath)) {
53+
$dependencies[] = $libPath;
54+
}
55+
}
56+
// Match lines without => (statically linked or direct paths)
57+
elseif (preg_match('/^\s+(\/.*)\s+\(0x[0-9a-f]+\)$/', $line, $matches)) {
58+
$libPath = trim($matches[1]);
59+
if (file_exists($libPath)) {
60+
$dependencies[] = $libPath;
61+
}
62+
}
63+
}
64+
65+
// Remove duplicates
66+
$dependencies = array_unique($dependencies);
67+
68+
// Filter out ignored libraries
69+
$filteredDependencies = [];
70+
foreach ($dependencies as $libPath) {
71+
$fileName = basename($libPath);
72+
foreach ($ignoredLibraries as $ignoredLib) {
73+
if (strpos($fileName, $ignoredLib) !== false) {
74+
echo "Skipping system library: $fileName\n";
75+
continue 2;
76+
}
77+
}
78+
$filteredDependencies[] = $libPath;
79+
}
80+
81+
echo "Found " . count($filteredDependencies) . " dependencies (excluding system libraries)\n";
82+
83+
// Copy each dependency to target directory
84+
$successCount = 0;
85+
foreach ($filteredDependencies as $libPath) {
86+
$fileName = basename($libPath);
87+
$targetPath = "$targetDir/$fileName";
88+
89+
echo "Copying $libPath to $targetPath... ";
90+
91+
if (copy($libPath, $targetPath)) {
92+
echo "SUCCESS\n";
93+
$successCount++;
94+
} else {
95+
echo "FAILED\n";
96+
}
97+
}
98+
99+
echo "Successfully copied $successCount out of " . count($filteredDependencies) . " dependencies\n";
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
__DIR__=$(
2+
cd "$(dirname "$0")" || exit
3+
pwd
4+
)
5+
6+
WORKDIR=$(
7+
cd "${__DIR__}"/../../ || exit
8+
pwd
9+
)
10+
11+
ORIGIN_SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf")
12+
SWOOLE_VERSION=$(echo "${ORIGIN_SWOOLE_VERSION}" | sed 's/[^a-zA-Z0-9]/_/g')
13+
CURRENT_SWOOLE_VERSION=''
14+
15+
cd "${WORKDIR}" || exit
16+
17+
TGZ_FILE="${WORKDIR}/pool/ext/swoole-${ORIGIN_SWOOLE_VERSION}.tgz"
18+
SWOOLE_DIR="${WORKDIR}/ext/swoole/"
19+
20+
if [ -f "ext/swoole/CMakeLists.txt" ] ;then
21+
CURRENT_SWOOLE_VERSION=$(grep 'set(SWOOLE_VERSION' ext/swoole/CMakeLists.txt | awk '{ print $2 }' | sed 's/)//')
22+
if [[ "${CURRENT_SWOOLE_VERSION}" =~ "-dev" ]]; then
23+
echo 'swoole version master'
24+
if [ -n "${GITHUB_ACTION}" ]; then
25+
test -f "$TGZ_FILE" && rm -f "$TGZ_FILE"
26+
CURRENT_SWOOLE_VERSION=''
27+
fi
28+
fi
29+
fi
30+
31+
if [ "${SWOOLE_VERSION}" != "${CURRENT_SWOOLE_VERSION}" ] ;then
32+
if [ ! -f "$TGZ_FILE" ] ;then
33+
echo "downloading swoole-${ORIGIN_SWOOLE_VERSION}.tgz"
34+
test -d /tmp/swoole && rm -rf /tmp/swoole
35+
git clone -b "${ORIGIN_SWOOLE_VERSION}" https://github.com/swoole/swoole-src.git /tmp/swoole
36+
status=$?
37+
if [[ $status -ne 0 ]]; then { echo $status ; exit 1 ; } fi
38+
cd /tmp/swoole || exit
39+
rm -rf /tmp/swoole/.git/
40+
tar -czvf "$TGZ_FILE" .
41+
fi
42+
43+
if [ ! -d "$SWOOLE_DIR" ] ;then
44+
echo "unpacking swoole-${ORIGIN_SWOOLE_VERSION}.tgz"
45+
mkdir -p "${SWOOLE_DIR}"
46+
tar --strip-components=1 -C "${SWOOLE_DIR}" -xf "$TGZ_FILE"
47+
fi
48+
fi

0 commit comments

Comments
 (0)