Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/linux-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
mkdir -p bin/
mkdir -p runtime/
test -f runtime/php && rm -f runtime/php
if [ ! -f runtime/php/php ] ; then
if [ ! -f runtime/php/pie ] ; then
bash setup-php-runtime.sh
fi
bash sapi/download-box/download-box-get-archive-from-server.sh
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux-glibc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
mkdir -p bin/
mkdir -p runtime/
test -f runtime/php && rm -f runtime/php
if [ ! -f runtime/php/php ] ; then
if [ ! -f runtime/php/pie ] ; then
bash setup-php-runtime.sh
fi
bash sapi/download-box/download-box-get-archive-from-server.sh
Expand All @@ -99,7 +99,7 @@ jobs:
composer install --no-interaction --no-autoloader --no-scripts --profile
composer dump-autoload --optimize --profile

php prepare.php --with-libavif
php prepare.php --with-libavif --without-docker

sudo apt update
bash ./sapi/scripts/install-deps-on-ubuntu.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
mkdir -p bin/
mkdir -p runtime/
test -f runtime/php && rm -f runtime/php
if [ ! -f runtime/php/php ] ; then
if [ ! -f runtime/php/pie ] ; then
bash setup-php-runtime.sh
fi
bash sapi/download-box/download-box-get-archive-from-server.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
mkdir -p bin/
mkdir -p runtime/
test -f runtime/php && rm -f runtime/php
if [ ! -f runtime/php/php ] ; then
if [ ! -f runtime/php/pie ] ; then
bash setup-php-runtime.sh
fi
bash sapi/download-box/download-box-get-archive-from-server.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
mkdir -p bin/
mkdir -p runtime/
test -f runtime/php && rm -f runtime/php
if [ ! -f runtime/php/php ] ; then
if [ ! -f runtime/php/pie ] ; then
bash setup-php-runtime.sh
fi
bash sapi/download-box/download-box-get-archive-from-server.sh
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 @@ -47,7 +47,8 @@ jobs:
- name: prepare build environment
shell: msys2 {0}
run: |
bash ./sapi/quickstart/windows/msys2-build/install-msys2.sh
bash sapi/quickstart/windows/msys2-build/install-msys2.sh
bash sapi/download-box/download-box-get-archive-from-server.sh

- name: install deps lib with source code
shell: msys2 {0}
Expand Down
2 changes: 1 addition & 1 deletion prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Download swoole-src
if (!is_dir(__DIR__ . '/ext/swoole')) {
shell_exec(__DIR__ . '/sapi/scripts/download-swoole-src-archive.sh');
//shell_exec(__DIR__ . '/sapi/scripts/download-swoole-src-archive.sh');
}

// Compile directly on the host machine, not in the docker container
Expand Down
2 changes: 1 addition & 1 deletion sapi/SWOOLE-VERSION.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6.1.3
v6.1.6
16 changes: 16 additions & 0 deletions sapi/src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class Extension extends Project
public string $options = '';
public string $peclVersion = '';

public string $pieVersion = '';
public string $pieName = '';

public array $dependentExtensions = [];

public function withOptions(string $options): static
Expand All @@ -26,4 +29,17 @@ public function withDependentExtensions(string ...$extensions): static
$this->dependentExtensions += $extensions;
return $this;
}

public function withPieVersion(string $pieVersion): static
{
$this->pieVersion = $pieVersion;
return $this;
}

public function withPieName(string $pieName): static
{
$this->pieName = $pieName;
return $this;
}

}
89 changes: 70 additions & 19 deletions sapi/src/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,10 @@ public function doNotInstallLibrary(): void
* @param string $file
* @param object|null $project [ $lib or $ext ]
*/
protected function downloadFile(string $url, string $file, ?object $project = null)
protected function downloadFile(?object $project = null)
{
$url = $project->url;
$file = $project->path;
$retry_number = DOWNLOAD_FILE_RETRY_NUMBE;
$wait_retry = DOWNLOAD_FILE_WAIT_RETRY;
$connect_timeout = DOWNLOAD_FILE_CONNECTION_TIMEOUT;
Expand All @@ -324,19 +326,39 @@ protected function downloadFile(string $url, string $file, ?object $project = nu
echo PHP_EOL;
echo `$cmd`;
echo PHP_EOL;
if (is_file($file) && (filesize($file) == 0)) {
unlink($file);
}
// 下载失败
if (!is_file($file) or filesize($file) == 0) {
throw new Exception("Downloading file[" . basename($file) . "] from url[$url] failed");
}
// 下载文件的 hash 不一致
if (!$this->skipHashVerify and $project->enableHashVerify) {
if (!$project->hashVerify($file)) {
throw new Exception("The {$project->hashAlgo} of downloaded file[$file] is inconsistent with the configuration");
}
}
}

public function downloadFileWithPie(?object $project = null): void
{
$pieName = $project->pieName;
$pieVersion = $project->pieVersion;
$file = $project->file;
$path = $project->path;
$workdir = $this->getWorkDir();
$cmd = <<<EOF
test -f {$workdir}/runtime/php/php && export PATH={$workdir}/runtime/php/:\$PATH ;
export PIE_WORKING_DIRECTORY={$workdir}/var/ext/pie/
test -d \$PIE_WORKING_DIRECTORY || mkdir -p \$PIE_WORKING_DIRECTORY ;
cd {$workdir}/var/ext/
TEMP_FILE=$(mktemp) && echo "TEMP_FILE: \${TEMP_FILE}" ;
{ pie download {$pieName}:{$pieVersion} ; } > \${TEMP_FILE} 2>&1
cat \${TEMP_FILE}
SOURCE_CODE_DIR=\$(cat \${TEMP_FILE} | grep 'source to: ' | awk -F 'source to: ' '{ print $2 }')
rm -f \${TEMP_FILE}
echo "{$pieName}:{$pieVersion} source code: \${SOURCE_CODE_DIR}"
pie info {$pieName}:{$pieVersion};
cd \${SOURCE_CODE_DIR}
tar -czf "{$workdir}/var/ext/{$file}" .
cp -f {$workdir}/var/ext/{$file} {$path}
cd {$workdir}
EOF;
echo $cmd;
echo PHP_EOL;
echo '------------RUNNING START-------------';
echo PHP_EOL;
echo `$cmd`;
echo '------------RUNNING END-------------';
echo PHP_EOL;
}

/**
Expand All @@ -363,7 +385,18 @@ public function addLibrary(Library $lib): void
if (!$skip_download) {
if (!is_file($lib->path) or filesize($lib->path) === 0) {
echo "[Library] {$lib->file} not found, downloading: " . $lib->url . PHP_EOL;
$this->downloadFile($lib->url, $lib->path, $lib);
$this->downloadFile($lib);
$file = $lib->path;
// 下载失败
if (!is_file($file) or filesize($file) == 0) {
throw new Exception("with Downloading file[" . basename($file) . "] from failed");
}
// 下载文件的 hash 不一致
if (!$this->skipHashVerify and $lib->enableHashVerify) {
if (!$lib->hashVerify($file)) {
throw new Exception("The {$lib->hashAlgo} of downloaded file[$file] is inconsistent with the configuration");
}
}
} else {
echo "[Library] file cached: " . $lib->file . PHP_EOL;
}
Expand Down Expand Up @@ -396,8 +429,10 @@ public function addLibrary(Library $lib): void

public function addExtension(Extension $ext): void
{
if ($ext->peclVersion) {
$ext->file = $ext->name . '-' . $ext->peclVersion . '.tgz';
if ($ext->peclVersion || $ext->pieVersion) {
$extensionVersion = !empty($ext->peclVersion) ? $ext->peclVersion : $ext->pieVersion;
$downloadType = $ext->peclVersion ? 'pecl' : 'pie';
$ext->file = $ext->name . '-' . $extensionVersion . '.tgz';
$ext->path = $this->extensionDir . '/' . $ext->file;
$ext->url = "https://pecl.php.net/get/{$ext->file}";

Expand All @@ -411,8 +446,24 @@ public function addExtension(Extension $ext): void
}
if (!$this->getInputOption('skip-download')) {
if (!is_file($ext->path) or filesize($ext->path) === 0) {
echo "[Extension] {$ext->file} not found, downloading: " . $ext->url . PHP_EOL;
$this->downloadFile($ext->url, $ext->path, $ext);
if ($downloadType === 'pecl') {
echo "[Extension] {$ext->file} not found, downloading: " . $ext->url . PHP_EOL;
$this->downloadFile($ext);
} else {
echo "[Extension] {$ext->file} not found, downloading with pie.phar https://packagist.org/packages/" . $ext->pieName . PHP_EOL;
$this->downloadFileWithPie($ext);
}
$file = $ext->path;
// 下载失败
if (!is_file($file) or filesize($file) == 0) {
throw new Exception("with Downloading file[" . basename($file) . "] from failed");
}
// 下载文件的 hash 不一致
if (!$this->skipHashVerify and $ext->enableHashVerify) {
if (!$ext->hashVerify($file)) {
throw new Exception("The {$ext->hashAlgo} of downloaded file[$file] is inconsistent with the configuration");
}
}
} else {
echo "[Extension] file cached: " . $ext->file . PHP_EOL;
}
Expand Down
22 changes: 13 additions & 9 deletions sapi/src/builder/extension/swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@
$p->withExportVariable('URING_CFLAGS', '$(pkg-config --cflags --static liburing)');
$p->withExportVariable('URING_LIBS', '$(pkg-config --libs --static liburing)');
}

$p->addExtension((new Extension('swoole'))
->withHomePage('https://github.com/swoole/swoole-src')
->withLicense('https://github.com/swoole/swoole-src/blob/master/LICENSE', Extension::LICENSE_APACHE2)
->withManual('https://wiki.swoole.com/#/')
->withOptions(implode(' ', $options))
->withBuildCached(false)
->withDependentLibraries(...$dependentLibraries)
->withDependentExtensions(...$dependentExtensions));
$swoole_version = trim(file_get_contents(__DIR__ . '/../../../SWOOLE-VERSION.conf'));
$p->addExtension(
(new Extension('swoole'))
->withHomePage('https://github.com/swoole/swoole-src')
->withLicense('https://github.com/swoole/swoole-src/blob/master/LICENSE', Extension::LICENSE_APACHE2)
->withManual('https://wiki.swoole.com/#/')
->withOptions(implode(' ', $options))
->withBuildCached(false)
->withDependentLibraries(...$dependentLibraries)
->withDependentExtensions(...$dependentExtensions)
->withPieName('swoole/swoole')
->withPieVersion($swoole_version)
);

$p->withVariable('LIBS', '$LIBS ' . ($p->isMacos() ? '-lc++' : '-lstdc++'));
$p->withExportVariable('CARES_CFLAGS', '$(pkg-config --cflags --static libcares)');
Expand Down
2 changes: 1 addition & 1 deletion setup-php-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ esac
APP_VERSION='v5.1.3'
APP_NAME='swoole-cli'
VERSION='v5.1.3.0'
PIE_VERSION="1.2.1"
PIE_VERSION="1.3.5"
# 查看pie最新版本 https://github.com/php/pie/releases/latest

cd ${__PROJECT__}
Expand Down
Loading