mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 08:15:39 +08:00
refactor to pkg-config and add some add-on libs for gd
This commit is contained in:
@@ -19,7 +19,7 @@ class ConfigValidator
|
||||
foreach ($data as $name => $src) {
|
||||
isset($src['type']) || throw new ValidationException("source {$name} must have prop: [type]");
|
||||
is_string($src['type']) || throw new ValidationException("source {$name} type prop must be string");
|
||||
in_array($src['type'], ['filelist', 'git', 'ghtagtar', 'ghtar', 'ghrel', 'url']) || throw new ValidationException("source {$name} type [{$src['type']}] is invalid");
|
||||
in_array($src['type'], ['filelist', 'git', 'ghtagtar', 'ghtar', 'ghrel', 'url', 'custom']) || throw new ValidationException("source {$name} type [{$src['type']}] is invalid");
|
||||
switch ($src['type']) {
|
||||
case 'filelist':
|
||||
isset($src['url'], $src['regex']) || throw new ValidationException("source {$name} needs [url] and [regex] props");
|
||||
|
||||
@@ -204,9 +204,6 @@ class Patcher
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public static function patchUnixLibpng(): void
|
||||
{
|
||||
FileSystem::replaceFile(
|
||||
@@ -217,6 +214,22 @@ class Patcher
|
||||
);
|
||||
}
|
||||
|
||||
public static function patchCurlMacOS(): void
|
||||
{
|
||||
FileSystem::replaceFile(
|
||||
SOURCE_PATH . '/curl/CMakeLists.txt',
|
||||
REPLACE_FILE_PREG,
|
||||
'/NOT COREFOUNDATION_FRAMEWORK/m',
|
||||
'FALSE'
|
||||
);
|
||||
FileSystem::replaceFile(
|
||||
SOURCE_PATH . '/curl/CMakeLists.txt',
|
||||
REPLACE_FILE_PREG,
|
||||
'/NOT SYSTEMCONFIGURATION_FRAMEWORK/m',
|
||||
'FALSE'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,8 @@ class UnixShell
|
||||
|
||||
private bool $debug;
|
||||
|
||||
private array $env = [];
|
||||
|
||||
public function __construct(?bool $debug = null)
|
||||
{
|
||||
$this->debug = $debug ?? defined('DEBUG_MODE');
|
||||
@@ -54,4 +56,24 @@ class UnixShell
|
||||
exec($cmd, $out, $code);
|
||||
return [$code, $out];
|
||||
}
|
||||
|
||||
public function setEnv(array $env): UnixShell
|
||||
{
|
||||
$this->env = array_merge($this->env, $env);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execWithEnv(string $cmd): UnixShell
|
||||
{
|
||||
return $this->exec($this->getEnvString() . ' ' . $cmd);
|
||||
}
|
||||
|
||||
private function getEnvString(): string
|
||||
{
|
||||
$str = '';
|
||||
foreach ($this->env as $k => $v) {
|
||||
$str .= ' ' . $k . '="' . $v . '"';
|
||||
}
|
||||
return trim($str);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user