mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 05:14:52 +08:00
* add opentelemetry extension support * config sort * cleanup build args * Update docs * Adjust custom extension overrides for opentelemetry * Add tests * Update README.md and remove windows limitation * Fix windows static build for opentelemetry --------- Co-authored-by: crazywhalecc <jesse2061@outlook.com>
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
use SPC\builder\Extension;
|
|
use SPC\store\FileSystem;
|
|
use SPC\util\CustomExt;
|
|
use SPC\util\GlobalEnvManager;
|
|
|
|
#[CustomExt('opentelemetry')]
|
|
class opentelemetry extends Extension
|
|
{
|
|
public function validate(): void
|
|
{
|
|
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
|
throw new \RuntimeException('The opentelemetry extension requires PHP 8.0 or later');
|
|
}
|
|
}
|
|
|
|
public function patchBeforeBuildconf(): bool
|
|
{
|
|
if (PHP_OS_FAMILY === 'Windows') {
|
|
FileSystem::replaceFileStr(
|
|
SOURCE_PATH . '/php-src/ext/opentelemetry/config.w32',
|
|
"EXTENSION('opentelemetry', 'opentelemetry.c otel_observer.c', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');",
|
|
"EXTENSION('opentelemetry', 'opentelemetry.c otel_observer.c', PHP_OPENTELEMETRY_SHARED, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');"
|
|
);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public function patchBeforeMake(): bool
|
|
{
|
|
// add -Wno-strict-prototypes
|
|
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
|
|
return true;
|
|
}
|
|
}
|