add library, extension patches in separate classes

This commit is contained in:
crazywhalecc
2023-07-28 23:47:22 +08:00
committed by Jerry Ma
parent e909dd15b0
commit 51ce2befd8
12 changed files with 316 additions and 12 deletions

View File

@@ -20,14 +20,34 @@ declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\builder\linux\SystemUtil;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\SourcePatcher;
use SPC\store\FileSystem;
class libpng extends LinuxLibraryBase
{
public const NAME = 'libpng';
public function patchBeforeBuild(): bool
{
FileSystem::replaceFile(
SOURCE_PATH . '/libpng/configure',
REPLACE_FILE_STR,
'-lz',
BUILD_LIB_PATH . '/libz.a'
);
if (SystemUtil::getOSRelease()['dist'] === 'alpine') {
FileSystem::replaceFile(
SOURCE_PATH . '/libpng/configure',
REPLACE_FILE_STR,
'-lm',
'/usr/lib/libm.a'
);
}
return true;
}
/**
* @throws RuntimeException
* @throws FileSystemException
@@ -39,10 +59,6 @@ class libpng extends LinuxLibraryBase
'arm64' => '--enable-arm-neon ',
default => '',
};
// patch configure
SourcePatcher::patchUnixLibpng();
shell()->cd($this->source_dir)
->exec('chmod +x ./configure')
->exec('chmod +x ./install-sh')