From 4cb176443981a81fcbc1cdb81a2f9005c8c885cf Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 12 Apr 2024 21:05:51 +0800 Subject: [PATCH] Fix libuuid build source (#411) * fix libuuid build source * fix libuuid build source tests --- config/lib.json | 3 ++ config/source.json | 2 +- src/SPC/builder/unix/library/libuuid.php | 40 ++++++++++++++---------- src/globals/test-extensions.php | 8 ++--- src/globals/tests/uuid.php | 6 ++++ 5 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 src/globals/tests/uuid.php diff --git a/config/lib.json b/config/lib.json index 6dc2caac..b7a92d04 100644 --- a/config/lib.json +++ b/config/lib.json @@ -353,6 +353,9 @@ "source": "libuuid", "static-libs-unix": [ "libuuid.a" + ], + "headers": [ + "uuid/uuid.h" ] }, "libuv": { diff --git a/config/source.json b/config/source.json index 0ecbb49d..9d5fb36e 100644 --- a/config/source.json +++ b/config/source.json @@ -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", diff --git a/src/SPC/builder/unix/library/libuuid.php b/src/SPC/builder/unix/library/libuuid.php index abbc4a9f..65ed02ac 100644 --- a/src/SPC/builder/unix/library/libuuid.php +++ b/src/SPC/builder/unix/library/libuuid.php @@ -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); } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index eb96a1e8..c7127f0d 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -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`. diff --git a/src/globals/tests/uuid.php b/src/globals/tests/uuid.php new file mode 100644 index 00000000..3ae30539 --- /dev/null +++ b/src/globals/tests/uuid.php @@ -0,0 +1,6 @@ +