Merge pull request #831 from crazywhalecc/fix/varname-placeholder

Change variable name for placeholder
This commit is contained in:
Marc 2025-07-23 16:24:56 +07:00 committed by GitHub
commit c8cc0131da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 12 deletions

View File

@ -317,26 +317,26 @@ abstract class LibraryBase
protected function install(): void
{
// replace placeholders if BUILD_ROOT_PATH/.spc-extract-placeholder.json exists
$placeholder_file = BUILD_ROOT_PATH . '/.spc-extract-placeholder.json';
if (!file_exists($placeholder_file)) {
$replace_item_file = BUILD_ROOT_PATH . '/.spc-extract-placeholder.json';
if (!file_exists($replace_item_file)) {
return;
}
$placeholder = json_decode(file_get_contents($placeholder_file), true);
if (!is_array($placeholder)) {
throw new RuntimeException('Invalid placeholder file: ' . $placeholder_file);
$replace_items = json_decode(file_get_contents($replace_item_file), true);
if (!is_array($replace_items)) {
throw new RuntimeException('Invalid placeholder file: ' . $replace_item_file);
}
$placeholder = get_pack_placehoder();
$placeholders = get_pack_replace();
// replace placeholders in BUILD_ROOT_PATH
foreach ($placeholder as $item) {
foreach ($replace_items as $item) {
$filepath = BUILD_ROOT_PATH . "/{$item}";
FileSystem::replaceFileStr(
$filepath,
array_values($placeholder),
array_keys($placeholder),
array_values($placeholders),
array_keys($placeholders),
);
}
// remove placeholder file
unlink($placeholder_file);
unlink($replace_item_file);
}
/**

View File

@ -53,7 +53,7 @@ class PackLibCommand extends BuildCommand
$origin_files = [];
// get pack placehoder defines
$placehoder = get_pack_placehoder();
$placehoder = get_pack_replace();
foreach ($builder->getLibs() as $lib) {
if ($lib->getName() !== $lib_name) {

View File

@ -233,7 +233,7 @@ function ac_with_args(string $arg_name, bool $use_value = false): array
return $use_value ? ["--with-{$arg_name}=yes", "--with-{$arg_name}=no"] : ["--with-{$arg_name}", "--without-{$arg_name}"];
}
function get_pack_placehoder(): array
function get_pack_replace(): array
{
return [
BUILD_LIB_PATH => '@build_lib_path@',