mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 00:05:42 +08:00
Add packing placeholder
This commit is contained in:
@@ -350,7 +350,27 @@ abstract class LibraryBase
|
||||
|
||||
protected function install(): void
|
||||
{
|
||||
// do something after extracting pre-built files, default do nothing. overwrite this method to do something
|
||||
// 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)) {
|
||||
return;
|
||||
}
|
||||
$placeholder = json_decode(file_get_contents($placeholder_file), true);
|
||||
if (!is_array($placeholder)) {
|
||||
throw new RuntimeException('Invalid placeholder file: ' . $placeholder_file);
|
||||
}
|
||||
$placeholder = get_pack_placehoder();
|
||||
// replace placeholders in BUILD_ROOT_PATH
|
||||
foreach ($placeholder as $item) {
|
||||
$filepath = BUILD_ROOT_PATH . "/{$item}";
|
||||
FileSystem::replaceFileStr(
|
||||
$filepath,
|
||||
array_values($placeholder),
|
||||
array_keys($placeholder),
|
||||
);
|
||||
}
|
||||
// remove placeholder file
|
||||
unlink($placeholder_file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@ trait icu
|
||||
|
||||
protected function install(): void
|
||||
{
|
||||
parent::install();
|
||||
$icu_config = BUILD_ROOT_PATH . '/bin/icu-config';
|
||||
FileSystem::replaceFileStr($icu_config, '{BUILD_ROOT_PATH}', BUILD_ROOT_PATH);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ trait libevent
|
||||
|
||||
protected function install(): void
|
||||
{
|
||||
parent::install();
|
||||
FileSystem::replaceFileStr(
|
||||
BUILD_LIB_PATH . '/cmake/libevent/LibeventTargets-static.cmake',
|
||||
'{BUILD_ROOT_PATH}',
|
||||
|
||||
Reference in New Issue
Block a user