Add custom Windows micro logo support (#358)

* add custom windows micro logo option `--with-micro-logo`

* bump version 2.1.2
This commit is contained in:
Jerry Ma 2024-02-29 15:35:02 +08:00 committed by GitHub
parent 842e0add29
commit b46655ecfe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 2 deletions

View File

@ -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()
{ {

View File

@ -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 .

View File

@ -39,6 +39,10 @@ class BuildCliCommand extends BuildCommand
$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)');
if (PHP_OS_FAMILY === 'Windows') {
$this->addOption('with-micro-logo', null, InputOption::VALUE_REQUIRED, 'Use custom .ico for micro.sfx');
}
} }
public function handle(): int public function handle(): int
@ -63,6 +67,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')) {