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

@ -59,6 +59,6 @@ class libpng extends LinuxLibraryBase
->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la")
->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX);
$this->cleanLaFiles();
$this->patchLaDependencyPrefix();
}
}

View File

@ -59,7 +59,6 @@ class libpng extends MacOSLibraryBase
->cd(BUILD_LIB_PATH)
->exec('ln -sf libpng16.a libpng.a');
$this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX);
$this->patchLaDependencyPrefix(['libpng16.la']);
$this->cleanLaFiles();
$this->patchLaDependencyPrefix();
}
}

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') ?: '';

View File

@ -38,7 +38,5 @@ trait freetype
' -L/lib ',
' -L' . BUILD_ROOT_PATH . '/lib '
);
$this->cleanLaFiles();
}
}

View File

@ -34,6 +34,6 @@ trait gettext
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec('make install');
$this->patchLaDependencyPrefix(['libintl.la']);
$this->patchLaDependencyPrefix();
}
}

View File

@ -78,10 +78,6 @@ trait imagemagick
'includearchdir=${prefix}/include/ImageMagick-7'
);
}
$this->patchLaDependencyPrefix([
'libMagick++-7.Q16HDRI.la',
'libMagickCore-7.Q16HDRI.la',
'libMagickWand-7.Q16HDRI.la',
]);
$this->patchLaDependencyPrefix();
}
}

View File

@ -48,6 +48,6 @@ trait ldap
FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/ldap.pc', 'Libs: -L${libdir} -lldap', 'Libs: -L${libdir} -lldap -llber');
$this->patchPkgconfPrefix(['ldap.pc', 'lber.pc']);
$this->patchLaDependencyPrefix(['libldap.la', 'liblber.la']);
$this->patchLaDependencyPrefix();
}
}

View File

@ -23,6 +23,5 @@ trait libavif
->build();
// patch pkgconfig
$this->patchPkgconfPrefix(['libavif.pc']);
$this->cleanLaFiles();
}
}

View File

@ -21,6 +21,6 @@ trait libiconv
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
$this->patchLaDependencyPrefix(['libiconv.la']);
$this->patchLaDependencyPrefix();
}
}

View File

@ -26,6 +26,5 @@ trait libjpeg
->build();
// patch pkgconfig
$this->patchPkgconfPrefix(['libjpeg.pc', 'libturbojpeg.pc']);
$this->cleanLaFiles();
}
}

View File

@ -24,8 +24,6 @@ trait libwebp
// patch pkgconfig
$this->patchPkgconfPrefix(['libsharpyuv.pc', 'libwebp.pc', 'libwebpdecoder.pc', 'libwebpdemux.pc', 'libwebpmux.pc'], PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR);
$this->patchPkgconfPrefix(['libsharpyuv.pc'], PKGCONF_PATCH_CUSTOM, ['/^includedir=.*$/m', 'includedir=${prefix}/include/webp']);
$this->cleanLaFiles();
// fix imagemagick binary linking issue
$this->patchPkgconfPrefix(['libwebp.pc'], PKGCONF_PATCH_CUSTOM, ['/-lwebp$/m', '-lwebp -lsharpyuv']);
}
}

View File

@ -47,8 +47,8 @@ trait libxslt
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . escapeshellarg(BUILD_ROOT_PATH));
$this->patchPkgconfPrefix(['libexslt.pc']);
$this->patchLaDependencyPrefix(['libxslt.la', 'libexslt.la']);
$this->patchPkgconfPrefix(['libxslt.pc', 'libexslt.pc']);
$this->patchLaDependencyPrefix();
shell()->cd(BUILD_LIB_PATH)
->exec("ar -t libxslt.a | grep '\\.a$' | xargs -n1 ar d libxslt.a")
->exec("ar -t libexslt.a | grep '\\.a$' | xargs -n1 ar d libexslt.a");

View File

@ -54,6 +54,6 @@ trait nghttp2
->exec("make -j{$this->builder->concurrency}")
->exec("make install DESTDIR={$destdir}");
$this->patchPkgconfPrefix(['libnghttp2.pc']);
$this->patchLaDependencyPrefix(['libnghttp2.la']);
$this->patchLaDependencyPrefix();
}
}

View File

@ -28,6 +28,6 @@ trait nghttp3
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['libnghttp3.pc']);
$this->patchLaDependencyPrefix(['libnghttp3.la']);
$this->patchLaDependencyPrefix();
}
}

View File

@ -44,7 +44,7 @@ trait ngtcp2
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['libngtcp2.pc', 'libngtcp2_crypto_ossl.pc']);
$this->patchLaDependencyPrefix(['libngtcp2.la', 'libngtcp2_crypto_ossl.la']);
$this->patchLaDependencyPrefix();
// on macOS, the static library may contain other static libraries?
// ld: archive member 'libssl.a' not a mach-o file in libngtcp2_crypto_ossl.a

View File

@ -31,6 +31,6 @@ trait unixodbc
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']);
$this->cleanLaFiles();
$this->patchLaDependencyPrefix();
}
}

View File

@ -30,6 +30,6 @@ trait xz
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['liblzma.pc']);
$this->patchLaDependencyPrefix(['liblzma.la']);
$this->patchLaDependencyPrefix();
}
}