Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build native php #693

Merged
merged 7 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# build static php-cli runtime
# build static php-cli runtime and php-fpm

构建静态 原生 php-cli 运行时
构建静态 原生 php-cli 运行时 和 fastcgi 进程管理器 php-fpm

## 说明

Expand Down
14 changes: 10 additions & 4 deletions prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
$p = Preprocessor::getInstance();
$p->parseArguments($argc, $argv);

$buildType = $p->getBuildType();
if ($p->getInputOption('with-build-type')) {
$buildType = $p->getInputOption('with-build-type');
$p->setBuildType($buildType);
}

# clean
# clean old make.sh
$p->cleanFile(__DIR__ . '/make.sh');
$p->cleanFile(__DIR__ . '/make-install-deps.sh');
Expand Down Expand Up @@ -78,6 +85,8 @@
echo "CUSTOM_PHP_VERSION_ID: " . BUILD_CUSTOM_PHP_VERSION_ID . PHP_EOL;
echo PHP_EOL;

// Sync code from php-src
$p->setPhpSrcDir($p->getWorkDir() . '/var/php-' . BUILD_PHP_VERSION);

// Compile directly on the host machine, not in the docker container
if ($p->getInputOption('without-docker') || ($p->isMacos())) {
Expand All @@ -102,6 +111,7 @@
$p->setExtEnabled([]);
}


if ($p->getInputOption('with-global-prefix')) {
$p->setGlobalPrefix($p->getInputOption('with-global-prefix'));
}
Expand Down Expand Up @@ -188,9 +198,5 @@

function install_libraries(Preprocessor $p): void
{
if ($p->getInputOption('with-c-compiler') == 'x86_64-linux-musl-gcc') {
$p->loadDependentLibrary('musl_cross_make');
}

$p->loadDependentLibrary('php');
}
9 changes: 7 additions & 2 deletions sapi/src/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ public function getWorkDir(): string
return $this->workDir;
}

public function getWorkExtDir(): string
{
return $this->workDir . '/ext/';
}

public function setExtraLdflags(string $flags)
{
$this->extraLdflags = $flags;
Expand Down Expand Up @@ -454,7 +459,7 @@ public function donotInstallLibrary(): void
/**
* @param string $url
* @param string $file
* @param object|null $project
* @param object|null $project [ $lib or $ext ]
* @param string $httpProxyConfig
* @return void
*/
Expand Down Expand Up @@ -1190,7 +1195,7 @@ public function execute(): void
$this->setExtensionDependency();

if ($this->getInputOption('skip-download')) {
$this->generateLibraryDownloadLinks();
$this->generateDownloadLinks();
}

$this->generateFile(__DIR__ . '/template/make-install-deps.php', $this->rootDir . '/make-install-deps.sh');
Expand Down
2 changes: 1 addition & 1 deletion sapi/src/PreprocessorTrait/DownloadBoxTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait DownloadBoxTrait

EOF;

protected function generateLibraryDownloadLinks(): void
protected function generateDownloadLinks(): void
{
$this->mkdirIfNotExists($this->getRootDir() . '/var/download-box/', 0755, true);

Expand Down
5 changes: 3 additions & 2 deletions sapi/src/builder/extension/aaa_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@

// 扩展钩子 写法
$p->withBeforeConfigureScript('swoole', function (Preprocessor $p) {
$workdir = $p->getWorkDir();
$workDir = $p->getWorkDir();
$workExtDir = $p->getWorkExtDir();
$cmd = <<<EOF
cd {$workdir}
cd {$workDir}
# 构建之前对 swoole 源码做一些特别处理
# 比如加载一个补丁等
# 比如修改 swoole 源码的构建文件
Expand Down
Loading