forked from crazywhalecc/static-php-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglfw.php
More file actions
44 lines (35 loc) · 1.18 KB
/
glfw.php
File metadata and controls
44 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('glfw')]
class glfw extends Extension
{
public function patchBeforeBuildconf(): bool
{
if (file_exists(SOURCE_PATH . '/php-src/ext/glfw')) {
return false;
}
FileSystem::copyDir(SOURCE_PATH . '/ext-glfw', SOURCE_PATH . '/php-src/ext/glfw');
return true;
}
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lglfw ', '-lglfw3 ');
// ogt_vox_c_wrapper.cpp requires the C++ standard library
$cxxLib = PHP_OS_FAMILY === 'Darwin' ? '-lc++' : '-lstdc++';
$extraLibs = trim($this->builder->getOption('extra-libs', '') . ' ' . $cxxLib);
$this->builder->setOption('extra-libs', $extraLibs);
return true;
}
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH;
}
public function getWindowsConfigureArg(bool $shared = false): string
{
return '--enable-glfw=static';
}
}