Compare commits

..

3 Commits

Author SHA1 Message Date
henderkes
587aec3065 add -trimpath 2026-02-16 19:18:18 +07:00
henderkes
823b26fbb9 patch frankenphp build for new xcaddy release 2026-02-16 13:33:47 +07:00
henderkes
df0807f07c feat/xcaddy plugins 2026-02-16 13:09:34 +07:00
10 changed files with 55 additions and 62 deletions

View File

@@ -46,10 +46,6 @@ on:
description: Prefer pre-built binaries (reduce build time) description: Prefer pre-built binaries (reduce build time)
type: boolean type: boolean
default: true default: true
with-suggested-libs:
description: Build with suggested libs
type: boolean
default: false
debug: debug:
description: Show full build logs description: Show full build logs
type: boolean type: boolean
@@ -90,10 +86,6 @@ on:
description: Prefer pre-built binaries (reduce build time) description: Prefer pre-built binaries (reduce build time)
type: boolean type: boolean
default: true default: true
with-suggested-libs:
description: Include suggested libs
type: boolean
default: false
debug: debug:
description: Show full build logs description: Show full build logs
type: boolean type: boolean
@@ -165,9 +157,6 @@ jobs:
if [ ${{ inputs.prefer-pre-built }} == true ]; then if [ ${{ inputs.prefer-pre-built }} == true ]; then
DOWN_CMD="$DOWN_CMD --prefer-pre-built" DOWN_CMD="$DOWN_CMD --prefer-pre-built"
fi fi
if [ ${{ inputs.with-suggested-libs }} == true ]; then
BUILD_CMD="$BUILD_CMD --with-suggested-libs"
fi
if [ ${{ inputs.build-cli }} == true ]; then if [ ${{ inputs.build-cli }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-cli" BUILD_CMD="$BUILD_CMD --build-cli"
fi fi
@@ -213,14 +202,6 @@ jobs:
# if: ${{ failure() }} # if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3 # uses: mxschmitt/action-tmate@v3
# Upload debug logs
- if: ${{ inputs.debug && failure() }}
name: "Upload build logs on failure"
uses: actions/upload-artifact@v4
with:
name: spc-logs-${{ inputs.php-version }}-${{ inputs.os }}
path: log/*.log
# Upload cli executable # Upload cli executable
- if: ${{ inputs.build-cli == true }} - if: ${{ inputs.build-cli == true }}
name: "Upload PHP cli SAPI" name: "Upload PHP cli SAPI"

View File

@@ -58,6 +58,9 @@
"brotlicommon.lib", "brotlicommon.lib",
"brotlienc.lib", "brotlienc.lib",
"brotlidec.lib" "brotlidec.lib"
],
"headers": [
"brotli"
] ]
}, },
"bzip2": { "bzip2": {
@@ -370,15 +373,6 @@
], ],
"static-libs-windows": [ "static-libs-windows": [
"avif.lib" "avif.lib"
],
"lib-depends": [
"libaom"
],
"lib-suggests": [
"libwebp",
"libjpeg",
"libxml2",
"libpng"
] ]
}, },
"libcares": { "libcares": {
@@ -859,13 +853,17 @@
}, },
"openssl": { "openssl": {
"source": "openssl", "source": "openssl",
"pkg-configs": [ "static-libs-unix": [
"openssl" "libssl.a",
"libcrypto.a"
], ],
"static-libs-windows": [ "static-libs-windows": [
"libssl.lib", "libssl.lib",
"libcrypto.lib" "libcrypto.lib"
], ],
"headers": [
"openssl"
],
"lib-depends": [ "lib-depends": [
"zlib" "zlib"
] ]
@@ -967,10 +965,10 @@
}, },
"unixodbc": { "unixodbc": {
"source": "unixodbc", "source": "unixodbc",
"pkg-configs": [ "static-libs-unix": [
"odbc", "libodbc.a",
"odbccr", "libodbccr.a",
"odbcinst" "libodbcinst.a"
], ],
"lib-depends": [ "lib-depends": [
"libiconv" "libiconv"

View File

@@ -526,7 +526,7 @@
"libavif": { "libavif": {
"type": "ghtar", "type": "ghtar",
"repo": "AOMediaCodec/libavif", "repo": "AOMediaCodec/libavif",
"provide-pre-built": false, "provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "LICENSE"

View File

@@ -34,7 +34,7 @@ use Symfony\Component\Console\Application;
*/ */
final class ConsoleApplication extends Application final class ConsoleApplication extends Application
{ {
public const string VERSION = '2.8.3'; public const string VERSION = '2.8.2';
public function __construct() public function __construct()
{ {

View File

@@ -177,19 +177,18 @@ abstract class LibraryBase
if (file_exists($this->source_dir . '/.spc.patched')) { if (file_exists($this->source_dir . '/.spc.patched')) {
$this->patched = true; $this->patched = true;
} }
// extract first if not exists, needed for licenses of shared libraries
if (!is_dir($this->source_dir)) {
$this->getBuilder()->emitPatchPoint('before-library[' . static::NAME . ']-extract');
SourceManager::initSource(libs: [static::NAME], source_only: true);
$this->getBuilder()->emitPatchPoint('after-library[' . static::NAME . ']-extract');
}
// force means just build // force means just build
if ($force_build) { if ($force_build) {
$type = Config::getLib(static::NAME, 'type', 'lib'); $type = Config::getLib(static::NAME, 'type', 'lib');
logger()->info('Building required ' . $type . ' [' . static::NAME . ']'); logger()->info('Building required ' . $type . ' [' . static::NAME . ']');
// extract first if not exists
if (!is_dir($this->source_dir)) {
$this->getBuilder()->emitPatchPoint('before-library[' . static::NAME . ']-extract');
SourceManager::initSource(libs: [static::NAME], source_only: true);
$this->getBuilder()->emitPatchPoint('after-library[' . static::NAME . ']-extract');
}
if (!$this->patched && $this->patchBeforeBuild()) { if (!$this->patched && $this->patchBeforeBuild()) {
file_put_contents($this->source_dir . '/.spc.patched', 'PATCHED!!!'); file_put_contents($this->source_dir . '/.spc.patched', 'PATCHED!!!');
} }

View File

@@ -93,7 +93,7 @@ class LinuxBuilder extends UnixBuilderBase
$php_configure_env = SystemUtil::makeEnvVarString([ $php_configure_env = SystemUtil::makeEnvVarString([
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), 'CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . ' -Dsomethinghere', // . $musl_flag, 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . ' -Dsomethinghere', // . $musl_flag,
'LDFLAGS' => clean_spaces("{$this->arch_ld_flags} -L" . BUILD_LIB_PATH), 'LDFLAGS' => '-L' . BUILD_LIB_PATH,
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions! // 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
]); ]);

View File

@@ -365,7 +365,6 @@ abstract class UnixBuilderBase extends BuilderBase
$frankenphpAppPath = $this->getOption('with-frankenphp-app'); $frankenphpAppPath = $this->getOption('with-frankenphp-app');
if ($frankenphpAppPath) { if ($frankenphpAppPath) {
$frankenphpAppPath = trim($frankenphpAppPath, "\"'");
if (!is_dir($frankenphpAppPath)) { if (!is_dir($frankenphpAppPath)) {
throw new WrongUsageException("The path provided to --with-frankenphp-app is not a valid directory: {$frankenphpAppPath}"); throw new WrongUsageException("The path provided to --with-frankenphp-app is not a valid directory: {$frankenphpAppPath}");
} }
@@ -412,10 +411,17 @@ abstract class UnixBuilderBase extends BuilderBase
$nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : '';
$xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES'); $xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES');
$frankenphpSourceDir = getenv('FRANKENPHP_SOURCE_PATH') ?: SOURCE_PATH . '/frankenphp'; $frankenphpSourceDir = getenv('FRANKENPHP_SOURCE_PATH') ?: SOURCE_PATH . '/frankenphp';
FileSystem::replaceFileStr(
$frankenphpSourceDir . '/caddy/php-server.go',
'config, _, err := caddycmd.LoadConfig',
'config, _, _, err := caddycmd.LoadConfig'
);
$xcaddyModules = preg_replace('#--with github.com/dunglas/frankenphp\S*#', '', $xcaddyModules); $xcaddyModules = preg_replace('#--with github.com/dunglas/frankenphp\S*#', '', $xcaddyModules);
$xcaddyModules = "--with github.com/dunglas/frankenphp={$frankenphpSourceDir} " . $xcaddyModules = "--with github.com/dunglas/frankenphp={$frankenphpSourceDir} " .
"--with github.com/dunglas/frankenphp/caddy={$frankenphpSourceDir}/caddy {$xcaddyModules}"; "--with github.com/dunglas/frankenphp/caddy={$frankenphpSourceDir}/caddy " .
"--with github.com/caddyserver/caddy/v2=github.com/henderkes/caddy/v2@master " .
"{$xcaddyModules}";
if ($this->getLib('brotli') === null && str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) { if ($this->getLib('brotli') === null && str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) {
logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.'); logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.');
$xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules); $xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules);
@@ -454,7 +460,7 @@ abstract class UnixBuilderBase extends BuilderBase
'CGO_ENABLED' => '1', 'CGO_ENABLED' => '1',
'CGO_CFLAGS' => clean_spaces($cflags), 'CGO_CFLAGS' => clean_spaces($cflags),
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}", 'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie -trimpath ' .
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' .
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
"v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " . "v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .

View File

@@ -11,11 +11,6 @@ trait libavif
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)
->optionalLib('libaom', '-DAVIF_CODEC_AOM=SYSTEM', '-DAVIF_CODEC_AOM=OFF')
->optionalLib('libsharpyuv', '-DAVIF_LIBSHARPYUV=SYSTEM', '-DAVIF_LIBSHARPYUV=OFF')
->optionalLib('libjpeg', '-DAVIF_JPEG=SYSTEM', '-DAVIF_JPEG=OFF')
->optionalLib('libxml2', '-DAVIF_LIBXML2=SYSTEM', '-DAVIF_LIBXML2=OFF')
->optionalLib('libpng', '-DAVIF_LIBPNG=SYSTEM', '-DAVIF_LIBPNG=OFF')
->addConfigureArgs('-DAVIF_LIBYUV=OFF') ->addConfigureArgs('-DAVIF_LIBYUV=OFF')
->build(); ->build();
// patch pkgconfig // patch pkgconfig

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace SPC\store\pkg; namespace SPC\store\pkg;
use InvalidArgumentException;
use SPC\builder\linux\SystemUtil; use SPC\builder\linux\SystemUtil;
use SPC\store\Downloader; use SPC\store\Downloader;
use SPC\store\FileSystem; use SPC\store\FileSystem;
@@ -33,7 +34,7 @@ class GoXcaddy extends CustomPackage
$go_exec = "{$pkgroot}/go-xcaddy/bin/go"; $go_exec = "{$pkgroot}/go-xcaddy/bin/go";
$xcaddy_exec = "{$pkgroot}/go-xcaddy/bin/xcaddy"; $xcaddy_exec = "{$pkgroot}/go-xcaddy/bin/xcaddy";
if ($force) { if ($force) {
FileSystem::removeDir("{$pkgroot}/{$name}"); FileSystem::removeDir("{$pkgroot}/go-xcaddy");
} }
if (file_exists($go_exec) && file_exists($xcaddy_exec)) { if (file_exists($go_exec) && file_exists($xcaddy_exec)) {
return; return;
@@ -41,12 +42,12 @@ class GoXcaddy extends CustomPackage
$arch = match (explode('-', $name)[2]) { $arch = match (explode('-', $name)[2]) {
'x86_64' => 'amd64', 'x86_64' => 'amd64',
'aarch64' => 'arm64', 'aarch64' => 'arm64',
default => throw new \InvalidArgumentException('Unsupported architecture: ' . $name), default => throw new InvalidArgumentException('Unsupported architecture: ' . $name),
}; };
$os = match (explode('-', $name)[3]) { $os = match (explode('-', $name)[3]) {
'linux' => 'linux', 'linux' => 'linux',
'macos' => 'darwin', 'macos' => 'darwin',
default => throw new \InvalidArgumentException('Unsupported OS: ' . $name), default => throw new InvalidArgumentException('Unsupported OS: ' . $name),
}; };
[$go_version] = explode("\n", Downloader::curlExec('https://go.dev/VERSION?m=text')); [$go_version] = explode("\n", Downloader::curlExec('https://go.dev/VERSION?m=text'));
$config = [ $config = [
@@ -78,6 +79,18 @@ class GoXcaddy extends CustomPackage
} }
// install xcaddy without using musl tools, xcaddy build requires dynamic linking // install xcaddy without using musl tools, xcaddy build requires dynamic linking
// Clone the fork and install from local clone to avoid module path conflicts
$xcaddyClonePath = "{$pkgroot}/go/src/github.com/henderkes/xcaddy";
if (!is_dir($xcaddyClonePath)) {
shell()
->appendEnv([
'PATH' => "{$pkgroot}/go-xcaddy/bin:" . $sanitizedPath,
])
->exec("git clone https://github.com/henderkes/xcaddy {$xcaddyClonePath}");
} else {
shell()->cd($xcaddyClonePath)->exec('git fetch && git pull');
}
shell() shell()
->appendEnv([ ->appendEnv([
'PATH' => "{$pkgroot}/go-xcaddy/bin:" . $sanitizedPath, 'PATH' => "{$pkgroot}/go-xcaddy/bin:" . $sanitizedPath,
@@ -85,7 +98,8 @@ class GoXcaddy extends CustomPackage
'GOBIN' => "{$pkgroot}/go-xcaddy/bin", 'GOBIN' => "{$pkgroot}/go-xcaddy/bin",
'GOPATH' => "{$pkgroot}/go", 'GOPATH' => "{$pkgroot}/go",
]) ])
->exec('CC=cc go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest'); ->cd($xcaddyClonePath)
->exec('CC=cc go install ./cmd/xcaddy');
} }
public static function getEnvironment(): array public static function getEnvironment(): array

View File

@@ -26,10 +26,10 @@ $test_os = [
// 'macos-15-intel', // bin/spc for x86_64 // 'macos-15-intel', // bin/spc for x86_64
// 'macos-15', // bin/spc for arm64 // 'macos-15', // bin/spc for arm64
// 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64
// 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
// 'ubuntu-24.04', // bin/spc for x86_64 'ubuntu-24.04', // bin/spc for x86_64
// 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
// 'ubuntu-24.04-arm', // bin/spc for arm64 'ubuntu-24.04-arm', // bin/spc for arm64
// 'windows-2022', // .\bin\spc.ps1 // 'windows-2022', // .\bin\spc.ps1
// 'windows-2025', // 'windows-2025',
]; ];
@@ -50,7 +50,7 @@ $prefer_pre_built = false;
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) { $extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => '', 'Linux', 'Darwin' => 'pgsql',
'Windows' => 'com_dotnet', 'Windows' => 'com_dotnet',
}; };