Add curl extension and enhance Windows build process

This commit is contained in:
crazywhalecc
2026-03-31 15:10:47 +08:00
parent 844bb69f0d
commit b96586e4d3
10 changed files with 1492 additions and 762 deletions

View File

@@ -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
);
}
}