make patchLaDependencyPrefix argument optional, remove cleanLaFiles

This commit is contained in:
DubbleClick
2025-06-10 19:46:55 +07:00
parent 684b5d4534
commit 9ed62b02b6
17 changed files with 26 additions and 42 deletions

View File

@@ -84,13 +84,24 @@ trait UnixLibraryTrait
}
}
public function patchLaDependencyPrefix(array $files): void
public function patchLaDependencyPrefix(?array $files = null): void
{
logger()->info('Patching library [' . static::NAME . '] la files');
$throwOnMissing = true;
if ($files === null) {
$files = $this->getStaticLibs();
$files = array_map(fn ($name) => str_replace('.a', '.la', $name), $files);
$throwOnMissing = false;
}
foreach ($files as $name) {
$realpath = realpath(BUILD_LIB_PATH . '/' . $name);
if ($realpath === false) {
throw new RuntimeException('Cannot find library [' . static::NAME . '] la file [' . $name . '] !');
if ($throwOnMissing) {
throw new RuntimeException('Cannot find library [' . static::NAME . '] la file [' . $name . '] !');
} else {
logger()->warning('Cannot find library [' . static::NAME . '] la file [' . $name . '] !');
continue;
}
}
logger()->debug('Patching ' . $realpath);
// replace prefix
@@ -105,22 +116,6 @@ trait UnixLibraryTrait
}
}
/**
* remove libtool archive files
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function cleanLaFiles(): void
{
foreach ($this->getStaticLibs() as $lib) {
$filename = pathinfo($lib, PATHINFO_FILENAME) . '.la';
if (file_exists(BUILD_LIB_PATH . '/' . $filename)) {
unlink(BUILD_LIB_PATH . '/' . $filename);
}
}
}
public function getLibExtraCFlags(): string
{
$env = getenv($this->getSnakeCaseName() . '_CFLAGS') ?: '';