mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 05:14:52 +08:00
Add sanity check for pack:libs
This commit is contained in:
parent
83ab430b9a
commit
d6bea6295e
@ -5,8 +5,12 @@ declare(strict_types=1);
|
|||||||
namespace SPC\command\dev;
|
namespace SPC\command\dev;
|
||||||
|
|
||||||
use SPC\builder\BuilderProvider;
|
use SPC\builder\BuilderProvider;
|
||||||
|
use SPC\builder\LibraryBase;
|
||||||
use SPC\command\BuildCommand;
|
use SPC\command\BuildCommand;
|
||||||
use SPC\exception\ExceptionHandler;
|
use SPC\exception\ExceptionHandler;
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\util\DependencyUtil;
|
use SPC\util\DependencyUtil;
|
||||||
@ -53,6 +57,8 @@ class PackLibCommand extends BuildCommand
|
|||||||
$lib->tryBuild(true);
|
$lib->tryBuild(true);
|
||||||
// do something like patching pkg-conf files.
|
// do something like patching pkg-conf files.
|
||||||
$lib->beforePack();
|
$lib->beforePack();
|
||||||
|
// sanity check for libs (check if the libraries are built correctly)
|
||||||
|
$this->sanityCheckLib($lib);
|
||||||
// After build: load buildroot/ directory, and calculate increase files
|
// After build: load buildroot/ directory, and calculate increase files
|
||||||
$after_buildroot = FileSystem::scanDirFiles(BUILD_ROOT_PATH, relative: true);
|
$after_buildroot = FileSystem::scanDirFiles(BUILD_ROOT_PATH, relative: true);
|
||||||
$increase_files = array_diff($after_buildroot, $before_buildroot);
|
$increase_files = array_diff($after_buildroot, $before_buildroot);
|
||||||
@ -82,4 +88,20 @@ class PackLibCommand extends BuildCommand
|
|||||||
return static::FAILURE;
|
return static::FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws WrongUsageException
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
private function sanityCheckLib(LibraryBase $lib): void
|
||||||
|
{
|
||||||
|
logger()->info('Sanity check for library ' . $lib->getName());
|
||||||
|
// config
|
||||||
|
foreach ($lib->getStaticLibs() as $static_lib) {
|
||||||
|
if (!file_exists(FileSystem::convertPath(BUILD_LIB_PATH . '/' . $static_lib))) {
|
||||||
|
throw new RuntimeException('Static library ' . $static_lib . ' not found in ' . BUILD_LIB_PATH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user