mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-03 23:05:41 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9664709f21 | ||
|
|
b46655ecfe | ||
|
|
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": {
|
||||||
|
|||||||
@@ -147,7 +147,8 @@
|
|||||||
"libpng",
|
"libpng",
|
||||||
"libjpeg",
|
"libjpeg",
|
||||||
"libwebp",
|
"libwebp",
|
||||||
"freetype"
|
"freetype",
|
||||||
|
"libtiff"
|
||||||
],
|
],
|
||||||
"lib-suggests": [
|
"lib-suggests": [
|
||||||
"zstd",
|
"zstd",
|
||||||
@@ -233,6 +234,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": [
|
||||||
@@ -319,6 +331,12 @@
|
|||||||
"zlib"
|
"zlib"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"libtiff": {
|
||||||
|
"source": "libtiff",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libtiff.a"
|
||||||
|
]
|
||||||
|
},
|
||||||
"libuv": {
|
"libuv": {
|
||||||
"source": "libuv",
|
"source": "libuv",
|
||||||
"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/",
|
||||||
@@ -316,6 +325,15 @@
|
|||||||
"path": "COPYING"
|
"path": "COPYING"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"libtiff": {
|
||||||
|
"type": "filelist",
|
||||||
|
"url": "https://download.osgeo.org/libtiff/",
|
||||||
|
"regex": "/href=\"(?<file>tiff-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE.md"
|
||||||
|
}
|
||||||
|
},
|
||||||
"libuv": {
|
"libuv": {
|
||||||
"type": "ghtar",
|
"type": "ghtar",
|
||||||
"repo": "libuv/libuv",
|
"repo": "libuv/libuv",
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand;
|
|||||||
*/
|
*/
|
||||||
final class ConsoleApplication extends Application
|
final class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
public const VERSION = '2.1.1';
|
public const VERSION = '2.1.2';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/SPC/builder/linux/library/libtiff.php
Normal file
12
src/SPC/builder/linux/library/libtiff.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class libtiff extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libtiff;
|
||||||
|
|
||||||
|
public const NAME = 'libtiff';
|
||||||
|
}
|
||||||
12
src/SPC/builder/macos/library/libtiff.php
Normal file
12
src/SPC/builder/macos/library/libtiff.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class libtiff extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libtiff;
|
||||||
|
|
||||||
|
public const NAME = 'libtiff';
|
||||||
|
}
|
||||||
30
src/SPC/builder/unix/library/libtiff.php
Normal file
30
src/SPC/builder/unix/library/libtiff.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
|
||||||
|
trait libtiff
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec(
|
||||||
|
'./configure ' .
|
||||||
|
'--enable-static --disable-shared ' .
|
||||||
|
'--disable-cxx ' .
|
||||||
|
'--prefix='
|
||||||
|
)
|
||||||
|
->exec('make clean')
|
||||||
|
->exec("make -j{$this->builder->concurrency}")
|
||||||
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
|
$this->patchPkgconfPrefix(['libtiff-4.pc']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -85,6 +85,14 @@ class WindowsBuilder extends BuilderBase
|
|||||||
unlink($makefile . '.originfile');
|
unlink($makefile . '.originfile');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (($logo = $this->getOption('with-micro-logo')) !== null) {
|
||||||
|
// realpath
|
||||||
|
$logo = realpath($logo);
|
||||||
|
$micro_logo = '--enable-micro-logo=' . escapeshellarg($logo) . ' ';
|
||||||
|
} else {
|
||||||
|
$micro_logo = '';
|
||||||
|
}
|
||||||
|
|
||||||
cmd()->cd(SOURCE_PATH . '\php-src')
|
cmd()->cd(SOURCE_PATH . '\php-src')
|
||||||
->exec(
|
->exec(
|
||||||
"{$this->sdk_prefix} configure.bat --task-args \"" .
|
"{$this->sdk_prefix} configure.bat --task-args \"" .
|
||||||
@@ -94,7 +102,7 @@ class WindowsBuilder extends BuilderBase
|
|||||||
'--with-extra-includes=' . BUILD_INCLUDE_PATH . ' ' .
|
'--with-extra-includes=' . BUILD_INCLUDE_PATH . ' ' .
|
||||||
'--with-extra-libs=' . BUILD_LIB_PATH . ' ' .
|
'--with-extra-libs=' . BUILD_LIB_PATH . ' ' .
|
||||||
($enableCli ? '--enable-cli=yes ' : '--enable-cli=no ') .
|
($enableCli ? '--enable-cli=yes ' : '--enable-cli=no ') .
|
||||||
($enableMicro ? '--enable-micro=yes ' : '--enable-micro=no ') .
|
($enableMicro ? ('--enable-micro=yes ' . $micro_logo) : '--enable-micro=no ') .
|
||||||
($enableEmbed ? '--enable-embed=yes ' : '--enable-embed=no ') .
|
($enableEmbed ? '--enable-embed=yes ' : '--enable-embed=no ') .
|
||||||
"{$this->makeExtensionArgs()} " .
|
"{$this->makeExtensionArgs()} " .
|
||||||
$zts .
|
$zts .
|
||||||
|
|||||||
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,8 +37,8 @@ class BuildCliCommand extends BuildCommand
|
|||||||
$this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts');
|
$this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts');
|
||||||
$this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside');
|
$this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside');
|
||||||
$this->addOption('without-micro-ext-test', null, null, 'Disable phpmicro with extension test code');
|
$this->addOption('without-micro-ext-test', null, null, 'Disable phpmicro with extension test code');
|
||||||
|
|
||||||
$this->addOption('with-upx-pack', null, null, 'Compress / pack binary using UPX tool (linux/windows only)');
|
$this->addOption('with-upx-pack', null, null, 'Compress / pack binary using UPX tool (linux/windows only)');
|
||||||
|
$this->addOption('with-micro-logo', null, InputOption::VALUE_REQUIRED, 'Use custom .ico for micro.sfx (windows only)');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
@@ -63,6 +63,14 @@ class BuildCliCommand extends BuildCommand
|
|||||||
if ($rule === BUILD_TARGET_ALL) {
|
if ($rule === BUILD_TARGET_ALL) {
|
||||||
logger()->warning('--build-all option makes `--no-strip` always true, be aware!');
|
logger()->warning('--build-all option makes `--no-strip` always true, be aware!');
|
||||||
}
|
}
|
||||||
|
if (($rule & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO && $this->getOption('with-micro-logo')) {
|
||||||
|
$logo = $this->getOption('with-micro-logo');
|
||||||
|
if (!file_exists($logo)) {
|
||||||
|
logger()->error('Logo file ' . $logo . ' not exist !');
|
||||||
|
return static::FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check upx
|
// Check upx
|
||||||
$suffix = PHP_OS_FAMILY === 'Windows' ? '.exe' : '';
|
$suffix = PHP_OS_FAMILY === 'Windows' ? '.exe' : '';
|
||||||
if ($this->getOption('with-upx-pack')) {
|
if ($this->getOption('with-upx-pack')) {
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ 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' => 'imagick,zstd,bz2,zip,xml,dom',
|
||||||
'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`).
|
||||||
$with_libs = match (PHP_OS_FAMILY) {
|
$with_libs = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => '',
|
'Linux', 'Darwin' => 'xz',
|
||||||
'Windows' => '',
|
'Windows' => '',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) {
|
|||||||
// You can use `common`, `bulk`, `minimal` or `none`.
|
// You can use `common`, `bulk`, `minimal` or `none`.
|
||||||
// note: combination is only available for *nix platform. Windows must use `none` combination
|
// note: combination is only available for *nix platform. Windows must use `none` combination
|
||||||
$base_combination = match (PHP_OS_FAMILY) {
|
$base_combination = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => 'common',
|
'Linux', 'Darwin' => 'minimal',
|
||||||
'Windows' => 'none',
|
'Windows' => 'none',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -62,6 +62,7 @@ $final_libs = trim($with_libs, $trim_value);
|
|||||||
|
|
||||||
if (PHP_OS_FAMILY === 'Windows') {
|
if (PHP_OS_FAMILY === 'Windows') {
|
||||||
$final_extensions_cmd = '"' . $final_extensions . '"';
|
$final_extensions_cmd = '"' . $final_extensions . '"';
|
||||||
|
$final_libs = $final_libs === '' ? '' : ('"' . $final_libs . '"');
|
||||||
} else {
|
} else {
|
||||||
$final_extensions_cmd = $final_extensions;
|
$final_extensions_cmd = $final_extensions;
|
||||||
}
|
}
|
||||||
@@ -69,7 +70,7 @@ if (PHP_OS_FAMILY === 'Windows') {
|
|||||||
echo match ($argv[1]) {
|
echo match ($argv[1]) {
|
||||||
'extensions' => $final_extensions,
|
'extensions' => $final_extensions,
|
||||||
'libs' => $final_libs,
|
'libs' => $final_libs,
|
||||||
'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')),
|
'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)),
|
||||||
'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')),
|
'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)),
|
||||||
default => '',
|
default => '',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user