mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
Add mpir for windows gmp support
This commit is contained in:
@@ -82,10 +82,13 @@ ext-gettext:
|
||||
arg-type: with-path
|
||||
ext-gmp:
|
||||
type: php-extension
|
||||
depends:
|
||||
depends@unix:
|
||||
- gmp
|
||||
depends@windows:
|
||||
- mpir
|
||||
php-extension:
|
||||
arg-type: with-path
|
||||
arg-type@windows: with
|
||||
ext-iconv:
|
||||
type: php-extension
|
||||
depends@unix:
|
||||
|
||||
9
config/pkg/lib/mpir.yml
Normal file
9
config/pkg/lib/mpir.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
mpir:
|
||||
type: library
|
||||
artifact:
|
||||
source:
|
||||
type: git
|
||||
url: 'https://github.com/winlibs/mpir.git'
|
||||
rev: master
|
||||
static-libs@windows:
|
||||
- mpir_a.lib
|
||||
44
src/Package/Library/mpir.php
Normal file
44
src/Package/Library/mpir.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Attribute\Package\Validate;
|
||||
use StaticPHP\DI\ApplicationContext;
|
||||
use StaticPHP\Exception\EnvironmentException;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
use StaticPHP\Util\System\WindowsUtil;
|
||||
|
||||
#[Library('mpir')]
|
||||
class mpir
|
||||
{
|
||||
#[Validate]
|
||||
public function validate(): void
|
||||
{
|
||||
$ver = WindowsUtil::findVisualStudio();
|
||||
$vs_ver_dir = match ($ver['major_version']) {
|
||||
'17' => '\build.vc17',
|
||||
'16' => '\build.vc16',
|
||||
default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"),
|
||||
};
|
||||
ApplicationContext::set('mpir_vs_ver_dir', $vs_ver_dir);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
{
|
||||
$vs_ver_dir = ApplicationContext::get('mpir_vs_ver_dir');
|
||||
cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}\\lib_mpir_gc")
|
||||
->exec('msbuild lib_mpir_gc.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64');
|
||||
FileSystem::createDir($lib->getLibDir());
|
||||
FileSystem::createDir($lib->getIncludeDir());
|
||||
FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\lib_mpir_gc\\x64\\Release\\mpir_a.lib", "{$lib->getLibDir()}\\mpir_a.lib");
|
||||
// mpir.h and gmp.h are generated by the prebuild step into the source root
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\mpir.h", "{$lib->getIncludeDir()}\\mpir.h");
|
||||
FileSystem::copy("{$lib->getSourceDir()}\\gmp.h", "{$lib->getIncludeDir()}\\gmp.h");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user