Add getSourceRoot for artifacts

This commit is contained in:
crazywhalecc
2026-02-03 10:59:16 +08:00
parent 6688819605
commit a2409d9c0f
5 changed files with 33 additions and 7 deletions

View File

@@ -212,6 +212,19 @@ abstract class Package
throw new SPCInternalException("Source directory for package {$this->name} is not available because the source artifact is missing.");
}
/**
* Get source build root directory.
* It's only worked when 'source-root' is defined in artifact config.
* Normally it's equal to source dir.
*/
public function getSourceRoot(): string
{
if (($artifact = $this->getArtifact()) && $artifact->hasSource()) {
return $artifact->getSourceRoot();
}
throw new SPCInternalException("Source root for package {$this->name} is not available because the source artifact is missing.");
}
/**
* Check if the package has a binary available for current OS and architecture.
*/