mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-08 01:15:37 +08:00
Add curl extension and enhance Windows build process
This commit is contained in:
@@ -155,6 +155,43 @@ class PhpExtensionPackage extends Package
|
||||
return $this->extension_config['display-name'] ?? $this->getExtensionName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run smoke test for the extension on Unix CLI.
|
||||
* Override this method in a subclass.
|
||||
*/
|
||||
public function runSmokeTestCliWindows(): void
|
||||
{
|
||||
if (($this->extension_config['smoke-test'] ?? true) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$distName = $this->getDistName();
|
||||
// empty display-name → no --ri check (e.g. password_argon2)
|
||||
if ($distName === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
[$ret] = cmd()->execWithResult(BUILD_BIN_PATH . '\php.exe -n --ri "' . $distName . '"', false);
|
||||
if ($ret !== 0) {
|
||||
throw new ValidationException(
|
||||
"extension {$this->getName()} failed compile check: php-cli returned {$ret}",
|
||||
validation_module: 'Extension ' . $this->getName() . ' sanity check'
|
||||
);
|
||||
}
|
||||
|
||||
$test_file = ROOT_DIR . '/src/globals/ext-tests/' . $this->getExtensionName() . '.php';
|
||||
if (file_exists($test_file)) {
|
||||
$test = self::escapeInlineTestWindows(file_get_contents($test_file));
|
||||
[$ret, $out] = cmd()->execWithResult(BUILD_BIN_PATH . '\php.exe -n -r "' . trim($test) . '"');
|
||||
if ($ret !== 0) {
|
||||
throw new ValidationException(
|
||||
"extension {$this->getName()} failed sanity check. Code: {$ret}, output: " . implode("\n", $out),
|
||||
validation_module: 'Extension ' . $this->getName() . ' function check'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run smoke test for the extension on Unix CLI.
|
||||
* Override this method in a subclass.
|
||||
@@ -394,4 +431,17 @@ class PhpExtensionPackage extends Package
|
||||
$code
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape PHP test file content for inline `-r` usage on Windows cmd.
|
||||
* Strips <?php / declare, replaces newlines and special cmd characters.
|
||||
*/
|
||||
private static function escapeInlineTestWindows(string $code): string
|
||||
{
|
||||
return str_replace(
|
||||
['<?php', 'declare(strict_types=1);', "\n", '"', '$'],
|
||||
['', '', '', '\"', '$'],
|
||||
$code
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user