Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions .github/workflows/linux-glibc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: build-swoole-cli-linux-glibc-x86_64

on: [ push, pull_request ]

jobs:
linux-glibc:
if: ${{ 0 && !contains(github.event.head_commit.message, '--filter=') || contains(github.event.head_commit.message, '[linux-glibc]') }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-22.04, ubuntu-22.04-arm ]
name: linux-glibc-${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Show Environment Info
run: |
echo $PATH
env
docker info
id -u
id -g
who
cat /etc/os-release
hostnamectl
uname -s
uname -m
uname -r

cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
cat /proc/cpuinfo | grep "cpu cores" | uniq
cat /proc/cpuinfo| grep "processor"| wc -l
lscpu

export IPV6=$(ip -6 address show | grep inet6 | awk '{print $2}' | cut -d'/' -f1 | sed -n '2p')
export IPV4=$(ip -4 address show | grep inet | grep -v 127.0.0 | awk '{print $2}' | cut -d'/' -f1 | sed -n '1p')
echo $IPV4
echo $IPV6
echo "X_IPV6=${IPV6}" >> $GITHUB_ENV
echo "X_IPV4=${IPV4}" >> $GITHUB_ENV

- name: Prepare Build Environment
run: |
git submodule update --init

sudo mkdir -p /usr/local/swoole-cli
uid=$(id -u) && gid=$(id -g) && sudo chown -R ${uid}:${gid} /usr/local/swoole-cli

mkdir -p ${{ github.workspace }}/var/build-github-action-container/

- name: Cache PHP Runtime
uses: actions/cache@v4
id: php-runtime-cache-x86_64
with:
path: ${{ github.workspace }}/runtime
key: ${{ runner.os }}-x86_64-php-runtime

- name: Cache PHP Vendor
uses: actions/cache@v4
id: php-vendor-cache-x86_64
with:
path: ${{ github.workspace }}/vendor
key: ${{ runner.os }}-x86_64-php-vendor

- name: Cache Dependency Source Code Tarball
uses: actions/cache@v4
id: pool-cache
with:
path: ${{ github.workspace }}/pool/
key: source-code-tarball-pool

- name: Cache all-library
uses: actions/cache@v4
id: all-library-cache-x86_64
with:
path: /usr/local/swoole-cli
key: ${{ github.head_ref || github.ref_name }}-${{ runner.os }}-x86_64-all-library

- name: Prepare Runtime and Libraries and Extensions
run: |
set -x
mkdir -p pool/lib
mkdir -p pool/ext
mkdir -p bin/
mkdir -p runtime/
test -f runtime/php && rm -f runtime/php
if [ ! -f runtime/php/php ] ; then
bash setup-php-runtime.sh
fi
bash sapi/download-box/download-box-get-archive-from-server.sh
ls -A pool/lib/
ls -A /usr/local/swoole-cli/

- name: Build
run: |
set -eux
uname -m
composer install --no-interaction --no-autoloader --no-scripts --profile
composer dump-autoload --optimize --profile

php prepare.php --with-libavif

sudo apt update
bash ./sapi/scripts/install-deps-on-ubuntu.sh
bash ./ext/swoole/scripts/install-deps-on-ubuntu.sh
bash ./sapi/scripts/build-swoole-cli-with-linux-gcc.sh

./bin/swoole-cli -v
./bin/swoole-cli -m
./bin/swoole-cli --ri curl
./bin/swoole-cli --ri gd
./bin/swoole-cli --ri imagick
./bin/swoole-cli --ri swoole
{ ldd ./bin/swoole-cli ; } || { echo $? ; } ;
file ./bin/swoole-cli

- name: Make nfpm package
run: |
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
NFPM_ARCH="arm64"
else
NFPM_ARCH="amd64"
fi
wget https://github.com/goreleaser/nfpm/releases/download/v2.43.4/nfpm_2.43.4_${NFPM_ARCH}.deb
sudo dpkg -i nfpm_2.43.4_${NFPM_ARCH}.deb
strip ./bin/swoole-cli
./make.sh nfpm-pkg
ls -ls ./*.deb
ls -ls ./*.rpm

- name: upload artifacts to cloud object storage
if: ${{ (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }}
env:
OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }}
OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }}
run: |
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
FILE_ARCH="arm64"
else
FILE_ARCH="x64"
fi
SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf")
OS="linux"
bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-"${SWOOLE_VERSION}-${OS}-${FILE_ARCH}"-glibc.deb
bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-"${SWOOLE_VERSION}-${OS}-${FILE_ARCH}"-glibc.rpm
2 changes: 1 addition & 1 deletion .github/workflows/windows-cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Prepare
shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0}
run: |
bash ./sapi/scripts/cygwin/cygwin-config-ext.sh --php-version ${{ env.BUILD_PHP_VERSION }} --swoole-version master
bash ./sapi/scripts/cygwin/cygwin-config-ext.sh --php-version ${{ env.BUILD_PHP_VERSION }}

- name: Configure
shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/windows-msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ jobs:
shell: msys2 {0}
run: |
bash ./sapi/scripts/msys2/install-deps-lib.sh
bash sapi/download-box/download-box-get-archive-from-server.sh

- name: Prepare
shell: msys2 {0}
run: |
bash ./sapi/scripts/msys2/config-ext.sh --php-version ${{ env.BUILD_PHP_VERSION }} --swoole-version master
bash ./sapi/scripts/msys2/config-ext.sh --php-version ${{ env.BUILD_PHP_VERSION }}

- name: Configure
shell: msys2 {0}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,6 @@ php-fpm-*
!/runtime/.gitkeep
/APP_NAME
/APP_VERSION
*.deb
*.rpm
nfpm-pkg.yaml
3 changes: 1 addition & 2 deletions prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
// Sync code from php-src
$p->setPhpSrcDir($p->getWorkDir() . '/var/php-' . BUILD_PHP_VERSION);


// Compile directly on the host machine, not in the docker container
if ($p->getInputOption('without-docker') || ($p->isMacos())) {
$p->setWorkDir(__DIR__);
Expand All @@ -108,12 +109,10 @@
//设置PHP 安装目录
define("BUILD_PHP_INSTALL_PREFIX", $p->getRootDir() . '/bin/php-' . BUILD_PHP_VERSION);


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


if ($p->getInputOption('with-global-prefix')) {
$p->setGlobalPrefix($p->getInputOption('with-global-prefix'));
}
Expand Down
16 changes: 12 additions & 4 deletions sapi/scripts/build-swoole-cli-with-linux-gcc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
./configure --prefix=/usr --disable-all \
if [ ! -f ./configure ]; then
./buildconf --force
fi

./configure --prefix=/usr/local/swoole-cli \
--disable-all \
--enable-zts \
--without-pcre-jit \
--with-openssl --enable-openssl \
Expand Down Expand Up @@ -31,17 +36,20 @@
--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 \
--enable-swoole-curl \
--enable-cares \
--enable-swoole-pgsql \
--enable-swoole-sqlite \
--with-swoole-odbc=unixODBC,/usr \
--enable-swoole-thread \
--enable-swoole-stdext \
--enable-brotli \
--enable-zstd \
--enable-swoole-stdext \
--enable-redis \
--with-imagick \
--with-yaml \
--with-readline \
--enable-opcache

make -j "$(nproc)"
make -j "$(nproc)"
99 changes: 99 additions & 0 deletions sapi/scripts/copy-depend-libs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php
/**
* Copy shared library dependencies of swoole-cli to runtime/libs directory
*/

// Define paths
$binaryPath = __DIR__ . '/../../bin/swoole-cli';
$targetDir = __DIR__ . '/../../runtime/libs';

// Libraries that should be ignored (system/core libraries)
$ignoredLibraries = [
'libc.so',
'libm.so',
'libpthread.so',
'libdl.so',
'librt.so',
'ld-linux',
];

// Check if binary exists
if (!file_exists($binaryPath)) {
echo "Error: Binary file not found at $binaryPath\n";
exit(1);
}

// Create target directory if it doesn't exist
if (!is_dir($targetDir)) {
mkdir($targetDir, 0755, true) || die("Error: Failed to create directory $targetDir\n");
echo "Created directory: $targetDir\n";
}

$binaryPath = realpath($binaryPath);
$targetDir = realpath($targetDir);

// Get dependencies using ldd
echo "Getting dependencies for $binaryPath...\n";
$lddOutput = shell_exec('ldd ' . escapeshellarg($binaryPath));

if (empty($lddOutput)) {
echo "Error: Failed to get dependencies\n";
exit(1);
}

// Parse ldd output
$dependencies = [];
$lines = explode("\n", $lddOutput);

foreach ($lines as $line) {
// Match lines with => (typical ldd output)
if (preg_match('/^\s*.*\s+=>\s+(\/.*)\s+\(0x[0-9a-f]+\)$/', $line, $matches)) {
$libPath = trim($matches[1]);
if (file_exists($libPath)) {
$dependencies[] = $libPath;
}
}
// Match lines without => (statically linked or direct paths)
elseif (preg_match('/^\s+(\/.*)\s+\(0x[0-9a-f]+\)$/', $line, $matches)) {
$libPath = trim($matches[1]);
if (file_exists($libPath)) {
$dependencies[] = $libPath;
}
}
}

// Remove duplicates
$dependencies = array_unique($dependencies);

// Filter out ignored libraries
$filteredDependencies = [];
foreach ($dependencies as $libPath) {
$fileName = basename($libPath);
foreach ($ignoredLibraries as $ignoredLib) {
if (strpos($fileName, $ignoredLib) !== false) {
echo "Skipping system library: $fileName\n";
continue 2;
}
}
$filteredDependencies[] = $libPath;
}

echo "Found " . count($filteredDependencies) . " dependencies (excluding system libraries)\n";

// Copy each dependency to target directory
$successCount = 0;
foreach ($filteredDependencies as $libPath) {
$fileName = basename($libPath);
$targetPath = "$targetDir/$fileName";

echo "Copying $libPath to $targetPath... ";

if (copy($libPath, $targetPath)) {
echo "SUCCESS\n";
$successCount++;
} else {
echo "FAILED\n";
}
}

echo "Successfully copied $successCount out of " . count($filteredDependencies) . " dependencies\n";
48 changes: 48 additions & 0 deletions sapi/scripts/download-swoole-src-archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
__DIR__=$(
cd "$(dirname "$0")" || exit
pwd
)

WORKDIR=$(
cd "${__DIR__}"/../../ || exit
pwd
)

ORIGIN_SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf")
SWOOLE_VERSION=$(echo "${ORIGIN_SWOOLE_VERSION}" | sed 's/[^a-zA-Z0-9]/_/g')
CURRENT_SWOOLE_VERSION=''

cd "${WORKDIR}" || exit

TGZ_FILE="${WORKDIR}/pool/ext/swoole-${ORIGIN_SWOOLE_VERSION}.tgz"
SWOOLE_DIR="${WORKDIR}/ext/swoole/"

if [ -f "ext/swoole/CMakeLists.txt" ] ;then
CURRENT_SWOOLE_VERSION=$(grep 'set(SWOOLE_VERSION' ext/swoole/CMakeLists.txt | awk '{ print $2 }' | sed 's/)//')
if [[ "${CURRENT_SWOOLE_VERSION}" =~ "-dev" ]]; then
echo 'swoole version master'
if [ -n "${GITHUB_ACTION}" ]; then
test -f "$TGZ_FILE" && rm -f "$TGZ_FILE"
CURRENT_SWOOLE_VERSION=''
fi
fi
fi

if [ "${SWOOLE_VERSION}" != "${CURRENT_SWOOLE_VERSION}" ] ;then
if [ ! -f "$TGZ_FILE" ] ;then
echo "downloading swoole-${ORIGIN_SWOOLE_VERSION}.tgz"
test -d /tmp/swoole && rm -rf /tmp/swoole
git clone -b "${ORIGIN_SWOOLE_VERSION}" https://github.com/swoole/swoole-src.git /tmp/swoole
status=$?
if [[ $status -ne 0 ]]; then { echo $status ; exit 1 ; } fi
cd /tmp/swoole || exit
rm -rf /tmp/swoole/.git/
tar -czvf "$TGZ_FILE" .
fi

if [ ! -d "$SWOOLE_DIR" ] ;then
echo "unpacking swoole-${ORIGIN_SWOOLE_VERSION}.tgz"
mkdir -p "${SWOOLE_DIR}"
tar --strip-components=1 -C "${SWOOLE_DIR}" -xf "$TGZ_FILE"
fi
fi
Loading
Loading