2024-03-01 20:10:48 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
|
|
|
|
use SPC\exception\FileSystemException;
|
|
|
|
|
use SPC\exception\RuntimeException;
|
2024-03-01 21:27:51 +08:00
|
|
|
use SPC\store\FileSystem;
|
2024-03-01 20:10:48 +08:00
|
|
|
|
|
|
|
|
trait libuuid
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
|
|
|
|
protected function build(): void
|
|
|
|
|
{
|
2024-04-12 21:05:51 +08:00
|
|
|
FileSystem::resetDir($this->source_dir . '/build');
|
|
|
|
|
shell()->cd($this->source_dir . '/build')
|
2024-03-01 20:10:48 +08:00
|
|
|
->exec(
|
2024-04-12 21:05:51 +08:00
|
|
|
'cmake ' .
|
|
|
|
|
"{$this->builder->makeCmakeArgs()} " .
|
|
|
|
|
'..'
|
2024-03-01 20:10:48 +08:00
|
|
|
)
|
2024-04-12 21:05:51 +08:00
|
|
|
->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);
|
2024-03-01 20:10:48 +08:00
|
|
|
}
|
|
|
|
|
}
|