mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 05:14:52 +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": {
|
"ffi": {
|
||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"lib-depends": [
|
"lib-depends-unix": [
|
||||||
"libffi"
|
"libffi"
|
||||||
|
],
|
||||||
|
"lib-depends-windows": [
|
||||||
|
"libffi-win"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"fileinfo": {
|
"fileinfo": {
|
||||||
|
|||||||
@ -233,6 +233,17 @@
|
|||||||
"ffitarget.h"
|
"ffitarget.h"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"libffi-win": {
|
||||||
|
"source": "libffi-win",
|
||||||
|
"static-libs-windows": [
|
||||||
|
"libffi.lib"
|
||||||
|
],
|
||||||
|
"headers-windows": [
|
||||||
|
"ffi.h",
|
||||||
|
"ffitarget.h",
|
||||||
|
"fficonfig.h"
|
||||||
|
]
|
||||||
|
},
|
||||||
"libiconv": {
|
"libiconv": {
|
||||||
"source": "libiconv",
|
"source": "libiconv",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
|
|||||||
@ -245,6 +245,15 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"libffi-win": {
|
||||||
|
"type": "git",
|
||||||
|
"rev": "master",
|
||||||
|
"url": "https://github.com/static-php/libffi-win.git",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"libiconv": {
|
"libiconv": {
|
||||||
"type": "filelist",
|
"type": "filelist",
|
||||||
"url": "https://ftp.gnu.org/gnu/libiconv/",
|
"url": "https://ftp.gnu.org/gnu/libiconv/",
|
||||||
|
|||||||
@ -14,4 +14,9 @@ class ffi extends Extension
|
|||||||
{
|
{
|
||||||
return '--with-ffi --enable-zend-signals';
|
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`).
|
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||||
$extensions = match (PHP_OS_FAMILY) {
|
$extensions = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => 'pgsql,pdo_pgsql',
|
'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`).
|
// 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