mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Add ffi support for windows x64 (#357)
* add ffi support for windows x64 * add ffi test
This commit is contained in:
parent
254764761d
commit
842e0add29
@ -63,8 +63,11 @@
|
||||
"ffi": {
|
||||
"arg-type": "custom",
|
||||
"type": "builtin",
|
||||
"lib-depends": [
|
||||
"lib-depends-unix": [
|
||||
"libffi"
|
||||
],
|
||||
"lib-depends-windows": [
|
||||
"libffi-win"
|
||||
]
|
||||
},
|
||||
"fileinfo": {
|
||||
|
||||
@ -233,6 +233,17 @@
|
||||
"ffitarget.h"
|
||||
]
|
||||
},
|
||||
"libffi-win": {
|
||||
"source": "libffi-win",
|
||||
"static-libs-windows": [
|
||||
"libffi.lib"
|
||||
],
|
||||
"headers-windows": [
|
||||
"ffi.h",
|
||||
"ffitarget.h",
|
||||
"fficonfig.h"
|
||||
]
|
||||
},
|
||||
"libiconv": {
|
||||
"source": "libiconv",
|
||||
"static-libs-unix": [
|
||||
|
||||
@ -245,6 +245,15 @@
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libffi-win": {
|
||||
"type": "git",
|
||||
"rev": "master",
|
||||
"url": "https://github.com/static-php/libffi-win.git",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"libiconv": {
|
||||
"type": "filelist",
|
||||
"url": "https://ftp.gnu.org/gnu/libiconv/",
|
||||
|
||||
@ -14,4 +14,9 @@ class ffi extends Extension
|
||||
{
|
||||
return '--with-ffi --enable-zend-signals';
|
||||
}
|
||||
|
||||
public function getWindowsConfigureArg(): string
|
||||
{
|
||||
return '--with-ffi';
|
||||
}
|
||||
}
|
||||
|
||||
46
src/SPC/builder/windows/library/libffi_win.php
Normal file
46
src/SPC/builder/windows/library/libffi_win.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\windows\library;
|
||||
|
||||
use SPC\builder\windows\SystemUtil;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class libffi_win extends WindowsLibraryBase
|
||||
{
|
||||
public const NAME = 'libffi-win';
|
||||
|
||||
protected function build()
|
||||
{
|
||||
$vs_ver_dir = match (SystemUtil::findVisualStudio()['version']) {
|
||||
'vs17' => '/win32/vs17_x64',
|
||||
'vs16' => '/win32/vs16_x64',
|
||||
default => throw new RuntimeException('Current VS version is not supported yet!'),
|
||||
};
|
||||
|
||||
// start build
|
||||
cmd()->cd($this->source_dir . $vs_ver_dir)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('msbuild'),
|
||||
'libffi-msvc.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64'
|
||||
);
|
||||
FileSystem::createDir(BUILD_LIB_PATH);
|
||||
FileSystem::createDir(BUILD_INCLUDE_PATH);
|
||||
copy($this->source_dir . $vs_ver_dir . '\x64\Release\libffi.lib', BUILD_LIB_PATH . '\libffi.lib');
|
||||
copy($this->source_dir . $vs_ver_dir . '\x64\Release\libffi.pdb', BUILD_LIB_PATH . '\libffi.pdb');
|
||||
copy($this->source_dir . '\include\ffi.h', BUILD_INCLUDE_PATH . '\ffi.h');
|
||||
|
||||
FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '\ffi.h', '#define LIBFFI_H', "#define LIBFFI_H\n#define FFI_BUILDING");
|
||||
copy($this->source_dir . '\src\x86\ffitarget.h', BUILD_INCLUDE_PATH . '\ffitarget.h');
|
||||
copy($this->source_dir . '\fficonfig.h', BUILD_INCLUDE_PATH . '\fficonfig.h');
|
||||
|
||||
// copy($this->source_dir . '\msvc_build\out\static-Release\X64\libffi.lib', BUILD_LIB_PATH . '\libffi.lib');
|
||||
// copy($this->source_dir . '\msvc_build\include\ffi.h', BUILD_INCLUDE_PATH . '\ffi.h');
|
||||
// copy($this->source_dir . '\msvc_build\include\fficonfig.h', BUILD_INCLUDE_PATH . '\fficonfig.h');
|
||||
// copy($this->source_dir . '\src\x86\ffitarget.h', BUILD_INCLUDE_PATH . '\ffitarget.h');
|
||||
|
||||
// FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '\ffi.h', '..\..\src\x86\ffitarget.h', 'ffitarget.h');
|
||||
}
|
||||
}
|
||||
@ -14,7 +14,7 @@ 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' => 'pgsql,pdo_pgsql',
|
||||
'Windows' => 'mbstring,pdo_sqlite,mbregex',
|
||||
'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi',
|
||||
};
|
||||
|
||||
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user