Define HAVE_OMP_PAUSE_RESOURCE_ALL to 0, add additional file system func

This commit is contained in:
crazywhalecc 2025-03-30 14:01:31 +08:00
parent 88ce2eafab
commit 936413a6d9
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 24 additions and 3 deletions

View File

@ -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;
}

View File

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