mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-14 04:15:35 +08:00
Define HAVE_OMP_PAUSE_RESOURCE_ALL to 0, add additional file system func
This commit is contained in:
@@ -5,16 +5,20 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\extension;
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
use SPC\builder\Extension;
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
#[CustomExt('imagick')]
|
#[CustomExt('imagick')]
|
||||||
class imagick extends Extension
|
class imagick extends Extension
|
||||||
{
|
{
|
||||||
public function patchBeforeBuildconf(): bool
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
// destroy imagick build conf to avoid libgomp build error
|
// replace php_config.h HAVE_OMP_PAUSE_RESOURCE_ALL line to #define HAVE_OMP_PAUSE_RESOURCE_ALL 0
|
||||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/imagick/config.m4', '#include <omp.h>', '#include <NEVER_INCLUDE_OMP_H>');
|
FileSystem::replaceFileLineContainsString(SOURCE_PATH . '/php-src/main/php_config.h', 'HAVE_OMP_PAUSE_RESOURCE_ALL', '#define HAVE_OMP_PAUSE_RESOURCE_ALL 0');
|
||||||
return true;
|
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 RuntimeException
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
|
|||||||
Reference in New Issue
Block a user