2023-08-18 18:17:52 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
2023-08-20 19:51:45 +08:00
|
|
|
use SPC\exception\RuntimeException;
|
2023-08-18 18:17:52 +08:00
|
|
|
use SPC\store\FileSystem;
|
|
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('glfw')]
|
|
|
|
|
class glfw extends Extension
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
2023-08-18 18:17:52 +08:00
|
|
|
public function patchBeforeBuildconf(): bool
|
|
|
|
|
{
|
2023-11-01 01:35:15 +08:00
|
|
|
if (file_exists(SOURCE_PATH . '/php-src/ext/glfw')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-08-18 18:17:52 +08:00
|
|
|
FileSystem::copyDir(SOURCE_PATH . '/ext-glfw', SOURCE_PATH . '/php-src/ext/glfw');
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-01 01:35:15 +08:00
|
|
|
public function patchBeforeConfigure(): bool
|
|
|
|
|
{
|
|
|
|
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lglfw ', '-lglfw3 ');
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-18 18:17:52 +08:00
|
|
|
public function getUnixConfigureArg(): string
|
|
|
|
|
{
|
|
|
|
|
return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH;
|
|
|
|
|
}
|
2024-01-10 21:08:25 +08:00
|
|
|
|
|
|
|
|
public function getWindowsConfigureArg(): string
|
|
|
|
|
{
|
|
|
|
|
return '--enable-glfw=static';
|
|
|
|
|
}
|
2023-08-18 18:17:52 +08:00
|
|
|
}
|