mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Add getSourceRoot for artifacts
This commit is contained in:
parent
6688819605
commit
a2409d9c0f
@ -436,7 +436,7 @@ trait unix
|
||||
*/
|
||||
private function makeVars(PackageInstaller $installer): array
|
||||
{
|
||||
$config = (new SPCConfigUtil(['libs_only_deps' => true]))->config(array_map(fn ($x) => $x->getName(), $installer->getResolvedPackages()));
|
||||
$config = new SPCConfigUtil(['libs_only_deps' => true])->config(array_map(fn ($x) => $x->getName(), $installer->getResolvedPackages()));
|
||||
$static = ApplicationContext::get(ToolchainInterface::class)->isStatic() ? '-all-static' : '';
|
||||
$pie = SystemTarget::getTargetOS() === 'Linux' ? '-pie' : '';
|
||||
|
||||
|
||||
@ -268,6 +268,19 @@ class Artifact
|
||||
return FileSystem::convertPath(SOURCE_PATH . '/' . $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 (isset($this->config['metadata']['source-root'])) {
|
||||
return $this->getSourceDir() . '/' . ltrim($this->config['metadata']['source-root'], '/');
|
||||
}
|
||||
return $this->getSourceDir();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get binary extraction directory and mode.
|
||||
*
|
||||
|
||||
@ -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.
|
||||
*/
|
||||
|
||||
@ -169,7 +169,7 @@ class UnixAutoconfExecutor extends Executor
|
||||
*/
|
||||
private function initShell(): void
|
||||
{
|
||||
$this->shell = shell()->cd($this->package->getSourceDir())->initializeEnv($this->package)->appendEnv([
|
||||
$this->shell = shell()->cd($this->package->getSourceRoot())->initializeEnv($this->package)->appendEnv([
|
||||
'CFLAGS' => "-I{$this->package->getIncludeDir()}",
|
||||
'CXXFLAGS' => "-I{$this->package->getIncludeDir()}",
|
||||
'LDFLAGS' => "-L{$this->package->getLibDir()}",
|
||||
@ -185,12 +185,12 @@ class UnixAutoconfExecutor extends Executor
|
||||
$callable();
|
||||
return $this;
|
||||
} catch (SPCException $e) {
|
||||
if (file_exists("{$this->package->getSourceDir()}/config.log")) {
|
||||
logger()->debug("Config log file found: {$this->package->getSourceDir()}/config.log");
|
||||
if (file_exists("{$this->package->getSourceRoot()}/config.log")) {
|
||||
logger()->debug("Config log file found: {$this->package->getSourceRoot()}/config.log");
|
||||
$log_file = "lib.{$this->package->getName()}.console.log";
|
||||
logger()->debug('Saved config log file to: ' . SPC_LOGS_DIR . "/{$log_file}");
|
||||
$e->addExtraLogFile("{$this->package->getName()} library config.log", $log_file);
|
||||
copy("{$this->package->getSourceDir()}/config.log", SPC_LOGS_DIR . "/{$log_file}");
|
||||
copy("{$this->package->getSourceRoot()}/config.log", SPC_LOGS_DIR . "/{$log_file}");
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ class UnixCMakeExecutor extends Executor
|
||||
private function initBuildDir(): void
|
||||
{
|
||||
if ($this->build_dir === null) {
|
||||
$this->build_dir = "{$this->package->getSourceDir()}/build";
|
||||
$this->build_dir = "{$this->package->getSourceRoot()}/build";
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ CMAKE;
|
||||
*/
|
||||
private function initShell(): void
|
||||
{
|
||||
$this->shell = shell()->cd($this->package->getSourceDir())->initializeEnv($this->package)->appendEnv([
|
||||
$this->shell = shell()->cd($this->package->getSourceRoot())->initializeEnv($this->package)->appendEnv([
|
||||
'CFLAGS' => "-I{$this->package->getIncludeDir()}",
|
||||
'CXXFLAGS' => "-I{$this->package->getIncludeDir()}",
|
||||
'LDFLAGS' => "-L{$this->package->getLibDir()}",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user