mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
Define HAVE_OMP_PAUSE_RESOURCE_ALL to 0, add additional file system func
This commit is contained in:
parent
88ce2eafab
commit
936413a6d9
@ -5,16 +5,20 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('imagick')]
|
||||
class imagick extends Extension
|
||||
{
|
||||
public function patchBeforeBuildconf(): bool
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
// destroy imagick build conf to avoid libgomp build error
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/imagick/config.m4', '#include <omp.h>', '#include <NEVER_INCLUDE_OMP_H>');
|
||||
// replace php_config.h HAVE_OMP_PAUSE_RESOURCE_ALL line to #define HAVE_OMP_PAUSE_RESOURCE_ALL 0
|
||||
FileSystem::replaceFileLineContainsString(SOURCE_PATH . '/php-src/main/php_config.h', 'HAVE_OMP_PAUSE_RESOURCE_ALL', '#define HAVE_OMP_PAUSE_RESOURCE_ALL 0');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -461,6 +461,23 @@ class FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public static function replaceFileLineContainsString(string $file, string $find, string $line): false|int
|
||||
{
|
||||
$lines = file($file);
|
||||
if ($lines === false) {
|
||||
throw new FileSystemException('Cannot read file: ' . $file);
|
||||
}
|
||||
foreach ($lines as $key => $value) {
|
||||
if (str_contains($value, $find)) {
|
||||
$lines[$key] = $line . PHP_EOL;
|
||||
}
|
||||
}
|
||||
return file_put_contents($file, implode('', $lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user