diff --git a/.github/workflows/linux-aarch64.yml b/.github/workflows/linux-aarch64.yml index d25111e95b..03b2e2327b 100644 --- a/.github/workflows/linux-aarch64.yml +++ b/.github/workflows/linux-aarch64.yml @@ -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 diff --git a/.github/workflows/linux-glibc.yml b/.github/workflows/linux-glibc.yml index 28e9b59f78..3580cfe5a6 100644 --- a/.github/workflows/linux-glibc.yml +++ b/.github/workflows/linux-glibc.yml @@ -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 @@ -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 diff --git a/.github/workflows/linux-x86_64.yml b/.github/workflows/linux-x86_64.yml index b0034b33f0..0e4ab704f7 100644 --- a/.github/workflows/linux-x86_64.yml +++ b/.github/workflows/linux-x86_64.yml @@ -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 diff --git a/.github/workflows/macos-aarch64.yml b/.github/workflows/macos-aarch64.yml index 61226e828b..31b3cefb40 100644 --- a/.github/workflows/macos-aarch64.yml +++ b/.github/workflows/macos-aarch64.yml @@ -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 diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index 625dc09231..75d442a37d 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -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 diff --git a/.github/workflows/windows-msys2.yml b/.github/workflows/windows-msys2.yml index 82bbdb0118..5b8116bdae 100644 --- a/.github/workflows/windows-msys2.yml +++ b/.github/workflows/windows-msys2.yml @@ -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} diff --git a/prepare.php b/prepare.php index 1e65a07d55..1d1707bbc6 100755 --- a/prepare.php +++ b/prepare.php @@ -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'); } @@ -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') diff --git a/sapi/SWOOLE-VERSION.conf b/sapi/SWOOLE-VERSION.conf index b2c63a1c1b..4871c222ec 100644 --- a/sapi/SWOOLE-VERSION.conf +++ b/sapi/SWOOLE-VERSION.conf @@ -1 +1 @@ -v6.1.3 +v6.1.6 diff --git a/sapi/src/Extension.php b/sapi/src/Extension.php index fc9d681898..c056cc3f8b 100644 --- a/sapi/src/Extension.php +++ b/sapi/src/Extension.php @@ -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 @@ -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; + } + } diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index 3da0fd4d0a..63a51cc2ca 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -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 = << \${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 @@ -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}"; @@ -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; } diff --git a/sapi/src/builder/extension/swoole.php b/sapi/src/builder/extension/swoole.php index 6213b213f4..100c049e01 100644 --- a/sapi/src/builder/extension/swoole.php +++ b/sapi/src/builder/extension/swoole.php @@ -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)'); diff --git a/setup-php-runtime.sh b/setup-php-runtime.sh index 17931779a1..0621068ff8 100644 --- a/setup-php-runtime.sh +++ b/setup-php-runtime.sh @@ -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__}