refactor: move getLibExtra* to Package base, add ToolPackage support to executors and builders

- Move getLibExtraCFlags/getLibExtraCxxFlags/getLibExtraLdFlags/getLibExtraLibs from LibraryPackage to Package base class so ToolPackage can also use them
- Full ToolPackage implementation: getBuildRootPath, getIncludeDir, getLibDir, getBinDir, getToolField with platform suffix support
- Update PackageBuilder to support building ToolPackage (not just LibraryPackage)
- Update PackageInstaller: support ToolPackage in download/extract/install pipeline, auto-install build-time tools, record installed versions
- Allow LibraryPackage|ToolPackage union type in all Executor classes and UnixShell::initializeEnv
This commit is contained in:
crazywhalecc
2026-07-06 15:10:08 +08:00
parent 90846ab149
commit 1bdbdfc08c
10 changed files with 235 additions and 93 deletions

View File

@@ -6,6 +6,7 @@ namespace StaticPHP\Runtime\Shell;
use StaticPHP\Exception\SPCInternalException;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Package\ToolPackage;
use StaticPHP\Runtime\SystemTarget;
use ZM\Logger\ConsoleColor;
@@ -40,9 +41,9 @@ class UnixShell extends Shell
/**
* Init the environment variable that common build will be used.
*
* @param LibraryPackage $library Library package
* @param LibraryPackage|ToolPackage $library Library or tool package
*/
public function initializeEnv(LibraryPackage $library): UnixShell
public function initializeEnv(LibraryPackage|ToolPackage $library): UnixShell
{
$this->setEnv([
'CFLAGS' => $library->getLibExtraCFlags(),