mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-07 08:45:40 +08:00
Forward-port #1095
This commit is contained in:
46
src/Package/Library/libmpdec.php
Normal file
46
src/Package/Library/libmpdec.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('libmpdec')]
|
||||
class libmpdec
|
||||
{
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($lib)
|
||||
->configure('--disable-cxx --disable-shared --enable-static')
|
||||
->make();
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(LibraryPackage $lib): void
|
||||
{
|
||||
$makefileDir = $lib->getSourceDir() . DIRECTORY_SEPARATOR . 'libmpdec';
|
||||
|
||||
cmd()->cd($makefileDir)
|
||||
->exec('copy /y Makefile.vc Makefile')
|
||||
->exec('nmake /nologo clean')
|
||||
->exec('nmake /nologo MACHINE=x64');
|
||||
|
||||
// Copy static lib (rename from versioned name to libmpdec_a.lib)
|
||||
$libs = glob($makefileDir . DIRECTORY_SEPARATOR . 'libmpdec-*.lib');
|
||||
foreach ($libs as $libFile) {
|
||||
if (!str_contains($libFile, '.dll.')) {
|
||||
FileSystem::copy($libFile, $lib->getLibDir() . DIRECTORY_SEPARATOR . 'libmpdec_a.lib');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FileSystem::copy($makefileDir . DIRECTORY_SEPARATOR . 'mpdecimal.h', $lib->getIncludeDir() . DIRECTORY_SEPARATOR . 'mpdecimal.h');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user