mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Use diff to detect and deploy-patch new shared extensions that built with php
This commit is contained in:
parent
f4b03ae835
commit
987ad4b846
@ -8,6 +8,7 @@ use SPC\builder\unix\UnixBuilderBase;
|
|||||||
use SPC\exception\PatchException;
|
use SPC\exception\PatchException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
|
use SPC\store\DirDiff;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\store\SourcePatcher;
|
use SPC\store\SourcePatcher;
|
||||||
use SPC\util\GlobalEnvManager;
|
use SPC\util\GlobalEnvManager;
|
||||||
@ -270,6 +271,9 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
return Config::getExt($ext->getName(), 'build-with-php') === true;
|
return Config::getExt($ext->getName(), 'build-with-php') === true;
|
||||||
});
|
});
|
||||||
$install_modules = $sharedExts ? 'install-modules' : '';
|
$install_modules = $sharedExts ? 'install-modules' : '';
|
||||||
|
|
||||||
|
// detect changes in module path
|
||||||
|
$diff = new DirDiff(BUILD_MODULES_PATH, true);
|
||||||
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
||||||
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
|
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
@ -286,6 +290,12 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
$this->processLibphpSoFile($libphpSo);
|
$this->processLibphpSoFile($libphpSo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process shared extensions build-with-php
|
||||||
|
$increment_files = $diff->getChangedFiles();
|
||||||
|
foreach ($increment_files as $increment_file) {
|
||||||
|
$this->deployBinary($increment_file, $increment_file, false);
|
||||||
|
}
|
||||||
|
|
||||||
// process libphp.a for static embed
|
// process libphp.a for static embed
|
||||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
|
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
|
||||||
$AR = getenv('AR') ?: 'ar';
|
$AR = getenv('AR') ?: 'ar';
|
||||||
|
|||||||
@ -8,6 +8,7 @@ use SPC\builder\macos\library\MacOSLibraryBase;
|
|||||||
use SPC\builder\unix\UnixBuilderBase;
|
use SPC\builder\unix\UnixBuilderBase;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
|
use SPC\store\DirDiff;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\store\SourcePatcher;
|
use SPC\store\SourcePatcher;
|
||||||
use SPC\util\GlobalEnvManager;
|
use SPC\util\GlobalEnvManager;
|
||||||
@ -262,9 +263,25 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
$install_modules = $sharedExts ? 'install-modules' : '';
|
$install_modules = $sharedExts ? 'install-modules' : '';
|
||||||
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
||||||
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
|
$concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : '';
|
||||||
|
|
||||||
|
$diff = new DirDiff(BUILD_MODULES_PATH, true);
|
||||||
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
|
->exec('sed -i "" "s|^EXTENSION_DIR = .*|EXTENSION_DIR = /' . basename(BUILD_MODULES_PATH) . '|" Makefile')
|
||||||
->exec("make {$concurrency} INSTALL_ROOT=" . BUILD_ROOT_PATH . " {$vars} install-sapi {$install_modules} install-build install-headers install-programs");
|
->exec("make {$concurrency} INSTALL_ROOT=" . BUILD_ROOT_PATH . " {$vars} install-sapi {$install_modules} install-build install-headers install-programs");
|
||||||
|
|
||||||
|
$libphp = BUILD_LIB_PATH . '/libphp.dylib';
|
||||||
|
if (file_exists($libphp)) {
|
||||||
|
$this->deployBinary($libphp, $libphp, false);
|
||||||
|
// macOS currently have no -release option for dylib, so we just rename it here
|
||||||
|
}
|
||||||
|
|
||||||
|
// process shared extensions build-with-php
|
||||||
|
$increment_files = $diff->getChangedFiles();
|
||||||
|
foreach ($increment_files as $increment_file) {
|
||||||
|
$this->deployBinary($increment_file, $increment_file, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
|
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
|
||||||
$AR = getenv('AR') ?: 'ar';
|
$AR = getenv('AR') ?: 'ar';
|
||||||
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
|
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
|
||||||
|
|||||||
@ -118,6 +118,8 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
*/
|
*/
|
||||||
public function deployBinary(string $src, string $dst, bool $executable = true): string
|
public function deployBinary(string $src, string $dst, bool $executable = true): string
|
||||||
{
|
{
|
||||||
|
logger()->debug('Deploying binary from ' . $src . ' to ' . $dst);
|
||||||
|
|
||||||
// UPX for linux
|
// UPX for linux
|
||||||
$upx_option = (bool) $this->getOption('with-upx-pack', false);
|
$upx_option = (bool) $this->getOption('with-upx-pack', false);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user