Skip to content
Closed
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
11 changes: 8 additions & 3 deletions prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

// 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
if ($p->getInputOption('without-docker') || ($p->isMacos())) {
if ($p->getInputOption('without-docker') || ($p->isMacos()) || ($p->isLinux() && (!is_file('/.dockerenv')))) {
$p->setWorkDir(__DIR__);
$p->setBuildDir(__DIR__ . '/thirdparty');
}
Expand All @@ -46,7 +46,12 @@

if ($p->isMacos()) {
$p->setExtraLdflags('');
$homebrew_prefix = trim(shell_exec('brew --prefix'));
exec("brew --prefix 2>&1", $output, $result_code);
if ($result_code == 0) {
$homebrew_prefix = trim(implode(' ', $output));
} else {
$homebrew_prefix = "";
}
$p->withBinPath($homebrew_prefix . '/opt/flex/bin')
->withBinPath($homebrew_prefix . '/opt/bison/bin')
->withBinPath($homebrew_prefix . '/opt/libtool/bin')
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;
}

}
56 changes: 52 additions & 4 deletions sapi/src/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,46 @@ protected function downloadFile(string $url, string $file, ?object $project = nu
}
}

public function downloadFileWithPie(string $pieName, string $pieVersion, string $file, string $path, object $project): void
{
$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;
$file = $path;
// 下载失败
if (!is_file($file) or filesize($file) == 0) {
throw new Exception("with pie Downloading file[" . basename($file) . "] from 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");
}
}
}

/**
* @param Library $lib
* @throws Exception
Expand Down Expand Up @@ -396,8 +436,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 +453,14 @@ 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->url, $ext->path, $ext);
} else {
echo "[Extension] {$ext->file} not found, download with pie.phar " . $ext->homePage . PHP_EOL;
$this->downloadFileWithPie($ext->pieName, $ext->pieVersion, $ext->file, $ext->path, $ext);
}

} 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