Fix libuuid build source (#411)

* fix libuuid build source

* fix libuuid build source tests
This commit is contained in:
Jerry Ma 2024-04-12 21:05:51 +08:00 committed by GitHub
parent 847535721c
commit 4cb1764439
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 38 additions and 21 deletions

View File

@ -353,6 +353,9 @@
"source": "libuuid",
"static-libs-unix": [
"libuuid.a"
],
"headers": [
"uuid/uuid.h"
]
},
"libuv": {

View File

@ -385,7 +385,7 @@
},
"libuuid": {
"type": "git",
"url": "https://github.com/cloudbase/libuuid.git",
"url": "https://github.com/static-php/libuuid.git",
"rev": "master",
"license": {
"type": "file",

View File

@ -10,29 +10,37 @@ use SPC\store\FileSystem;
trait libuuid
{
public function patchBeforeBuild(): bool
{
FileSystem::replaceFileStr($this->source_dir . '/configure', '-${am__api_version}', '');
return true;
}
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void
{
shell()->cd($this->source_dir)
->exec('chmod +x configure')
->exec('chmod +x install-sh')
FileSystem::resetDir($this->source_dir . '/build');
shell()->cd($this->source_dir . '/build')
->exec(
'./configure ' .
'--enable-static --disable-shared ' .
'--prefix='
'cmake ' .
"{$this->builder->makeCmakeArgs()} " .
'..'
)
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['uuid.pc']);
->exec("cmake --build . -j {$this->builder->concurrency}");
copy($this->source_dir . '/build/libuuid.a', BUILD_LIB_PATH . '/libuuid.a');
FileSystem::createDir(BUILD_INCLUDE_PATH . '/uuid');
copy($this->source_dir . '/uuid.h', BUILD_INCLUDE_PATH . '/uuid/uuid.h');
$pc = FileSystem::readFile($this->source_dir . '/uuid.pc.in');
$pc = str_replace([
'@prefix@',
'@exec_prefix@',
'@libdir@',
'@includedir@',
'@LIBUUID_VERSION@',
], [
BUILD_ROOT_PATH,
'${prefix}',
'${prefix}/lib',
'${prefix}/include',
'1.0.3',
], $pc);
FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/uuid.pc', $pc);
}
}

View File

@ -13,14 +13,14 @@ declare(strict_types=1);
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'dba',
'Windows' => 'mbstring,pdo_sqlite,mbregex,dba',
'Linux', 'Darwin' => 'uuid',
'Windows' => 'mbstring,pdo_sqlite,mbregex',
};
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
$with_libs = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'qdbm',
'Windows' => 'qdbm',
'Linux', 'Darwin' => '',
'Windows' => '',
};
// Please change your test base combination. We recommend testing with `common`.

View File

@ -0,0 +1,6 @@
<?php
declare(strict_types=1);
assert(function_exists('uuid_create'));
assert(strlen(uuid_create(0)) === 36);