Provide libevent, libiconv-win, libsodium, libwebp, libyaml, ncurses, readline, unixodbc, xz pre-built libs

This commit is contained in:
crazywhalecc
2024-07-09 15:05:53 +08:00
parent 80effd029f
commit 57dd174aff
5 changed files with 84 additions and 3 deletions

View File

@@ -291,6 +291,7 @@
"repo": "libevent/libevent", "repo": "libevent/libevent",
"match": "libevent.+\\.tar\\.gz", "match": "libevent.+\\.tar\\.gz",
"prefer-stable": true, "prefer-stable": true,
"provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "LICENSE"
@@ -329,6 +330,7 @@
"type": "git", "type": "git",
"rev": "master", "rev": "master",
"url": "https://github.com/static-php/libiconv-win.git", "url": "https://github.com/static-php/libiconv-win.git",
"provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "source/COPYING" "path": "source/COPYING"
@@ -386,6 +388,7 @@
"repo": "jedisct1/libsodium", "repo": "jedisct1/libsodium",
"match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz", "match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz",
"prefer-stable": true, "prefer-stable": true,
"provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "LICENSE"
@@ -437,6 +440,7 @@
"libwebp": { "libwebp": {
"type": "url", "type": "url",
"url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz", "url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz",
"provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "COPYING" "path": "COPYING"
@@ -464,6 +468,7 @@
"repo": "yaml/libyaml", "repo": "yaml/libyaml",
"match": "yaml-.+\\.tar\\.gz", "match": "yaml-.+\\.tar\\.gz",
"prefer-stable": true, "prefer-stable": true,
"provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "License" "path": "License"
@@ -514,6 +519,7 @@
"type": "filelist", "type": "filelist",
"url": "https://ftp.gnu.org/pub/gnu/ncurses/", "url": "https://ftp.gnu.org/pub/gnu/ncurses/",
"regex": "/href=\"(?<file>ncurses-(?<version>[^\"]+)\\.tar\\.gz)\"/", "regex": "/href=\"(?<file>ncurses-(?<version>[^\"]+)\\.tar\\.gz)\"/",
"provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "COPYING" "path": "COPYING"
@@ -629,6 +635,7 @@
"type": "filelist", "type": "filelist",
"url": "https://ftp.gnu.org/pub/gnu/readline/", "url": "https://ftp.gnu.org/pub/gnu/readline/",
"regex": "/href=\"(?<file>readline-(?<version>[^\"]+)\\.tar\\.gz)\"/", "regex": "/href=\"(?<file>readline-(?<version>[^\"]+)\\.tar\\.gz)\"/",
"provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "COPYING" "path": "COPYING"
@@ -716,6 +723,7 @@
"unixodbc": { "unixodbc": {
"type": "url", "type": "url",
"url": "https://www.unixodbc.org/unixODBC-2.3.12.tar.gz", "url": "https://www.unixodbc.org/unixODBC-2.3.12.tar.gz",
"provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "COPYING" "path": "COPYING"
@@ -746,6 +754,7 @@
"repo": "tukaani-project/xz", "repo": "tukaani-project/xz",
"match": "xz.+\\.tar\\.xz", "match": "xz.+\\.tar\\.xz",
"prefer-stable": true, "prefer-stable": true,
"provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "COPYING" "path": "COPYING"

View File

@@ -10,12 +10,36 @@ use SPC\store\FileSystem;
trait libevent trait libevent
{ {
public function beforePack(): void
{
if (file_exists(BUILD_LIB_PATH . '/cmake/libevent/LibeventTargets-static.cmake')) {
FileSystem::replaceFileRegex(
BUILD_LIB_PATH . '/cmake/libevent/LibeventTargets-static.cmake',
'/set\(_IMPORT_PREFIX .*\)/m',
'set(_IMPORT_PREFIX "{BUILD_ROOT_PATH}")'
);
FileSystem::replaceFileRegex(
BUILD_LIB_PATH . '/cmake/libevent/LibeventTargets-static.cmake',
'/INTERFACE_INCLUDE_DIRECTORIES ".*"/m',
'INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"'
);
FileSystem::replaceFileRegex(
BUILD_LIB_PATH . '/cmake/libevent/LibeventTargets-static.cmake',
'/INTERFACE_LINK_LIBRARIES "libevent::core;.*"/m',
'INTERFACE_LINK_LIBRARIES "libevent::core;${_IMPORT_PREFIX}/lib/libssl.a;${_IMPORT_PREFIX}/lib/libcrypto.a"'
);
}
}
/** /**
* @throws RuntimeException * @throws RuntimeException
* @throws FileSystemException * @throws FileSystemException
*/ */
protected function build(): void protected function build(): void
{ {
[$lib, $include, $destdir] = SEPARATED_PATH;
// CMake needs a clean build directory // CMake needs a clean build directory
FileSystem::resetDir($this->source_dir . '/build'); FileSystem::resetDir($this->source_dir . '/build');
// Start build // Start build
@@ -36,5 +60,25 @@ trait libevent
) )
->execWithEnv("cmake --build . -j {$this->builder->concurrency}") ->execWithEnv("cmake --build . -j {$this->builder->concurrency}")
->exec('make install'); ->exec('make install');
$this->patchPkgconfPrefix(['libevent.pc', 'libevent_core.pc', 'libevent_extra.pc', 'libevent_openssl.pc']);
$this->patchPkgconfPrefix(
['libevent_openssl.pc'],
PKGCONF_PATCH_CUSTOM,
[
'/Libs.private:.*/m',
'Libs.private: -lssl -lcrypto',
]
);
}
protected function install(): void
{
FileSystem::replaceFileStr(
BUILD_LIB_PATH . '/cmake/libevent/LibeventTargets-static.cmake',
'{BUILD_ROOT_PATH}',
BUILD_ROOT_PATH
);
} }
} }

View File

@@ -8,11 +8,12 @@ trait libsodium
{ {
protected function build(): void protected function build(): void
{ {
$root = BUILD_ROOT_PATH;
shell()->cd($this->source_dir) shell()->cd($this->source_dir)
->exec("./configure --enable-static --disable-shared --prefix={$root}") ->exec('./configure --enable-static --disable-shared --prefix=')
->exec('make clean') ->exec('make clean')
->exec("make -j{$this->builder->concurrency}") ->exec("make -j{$this->builder->concurrency}")
->exec('make install'); ->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['libsodium.pc'], PKGCONF_PATCH_PREFIX);
} }
} }

View File

@@ -4,10 +4,13 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\store\FileSystem;
trait ncurses trait ncurses
{ {
protected function build(): void protected function build(): void
{ {
$filelist = FileSystem::scanDirFiles(BUILD_BIN_PATH, relative: true);
shell()->cd($this->source_dir) shell()->cd($this->source_dir)
->exec( ->exec(
'./configure ' . './configure ' .
@@ -32,5 +35,22 @@ trait ncurses
->exec('make clean') ->exec('make clean')
->exec("make -j{$this->builder->concurrency}") ->exec("make -j{$this->builder->concurrency}")
->exec('make install'); ->exec('make install');
$final = FileSystem::scanDirFiles(BUILD_BIN_PATH, relative: true);
// Remove the new files
$new_files = array_diff($final, $filelist);
foreach ($new_files as $file) {
@unlink(BUILD_BIN_PATH . '/' . $file);
}
shell()->cd(BUILD_ROOT_PATH)->exec('rm -rf share/terminfo');
shell()->cd(BUILD_ROOT_PATH)->exec('rm -rf lib/terminfo');
$pkgconf_list = ['form.pc', 'menu.pc', 'ncurses++.pc', 'ncurses.pc', 'panel.pc', 'tic.pc'];
$this->patchPkgconfPrefix($pkgconf_list);
foreach ($pkgconf_list as $pkgconf) {
FileSystem::replaceFileStr(BUILD_LIB_PATH . '/pkgconfig/' . $pkgconf, '-L' . BUILD_LIB_PATH, '-L${libdir}');
}
} }
} }

View File

@@ -41,5 +41,12 @@ class libwebp extends WindowsLibraryBase
$this->builder->makeSimpleWrapper('cmake'), $this->builder->makeSimpleWrapper('cmake'),
"--build build --config Release --target install -j{$this->builder->concurrency}" "--build build --config Release --target install -j{$this->builder->concurrency}"
); );
// Actually we don't need pkgconf in windows, but for packing, we still need patching prefix.
// for libsharpyuv, libwebp, libwebpdecoder, libwebpdemux
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '\pkgconfig\libsharpyuv.pc', '/^prefix=.*/m', 'prefix=${pcfiledir}/../..');
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '\pkgconfig\libwebp.pc', '/^prefix=.*/m', 'prefix=${pcfiledir}/../..');
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '\pkgconfig\libwebpdecoder.pc', '/^prefix=.*/m', 'prefix=${pcfiledir}/../..');
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '\pkgconfig\libwebpdemux.pc', '/^prefix=.*/m', 'prefix=${pcfiledir}/../..');
} }
} }