diff --git a/docs/en/guide/build-on-windows.md b/docs/en/guide/build-on-windows.md index e3cf1c4e3..dc20e29dc 100644 --- a/docs/en/guide/build-on-windows.md +++ b/docs/en/guide/build-on-windows.md @@ -159,7 +159,8 @@ You can try to use the following commands: - `--with-clean`: clean up old make files before compiling PHP - `--enable-zts`: Make compiled PHP thread-safe version (default is NTS version) -- `--with-libs=XXX,YYY`: Compile the specified dependent library before compiling PHP, and activate some extension optional functions +- `--with-libs=XXX,YYY`: Compile the specified dependent library before compiling PHP, and activate some extension optional functions +- `--with-config-file-path=XXX`: Set the path in which to look for php.ini - `-I xxx=yyy`: Hard compile INI options into PHP before compiling (support multiple options, alias is `--with-hardcoded-ini`) - `--with-micro-fake-cli`: When compiling micro, let micro's `PHP_SAPI` pretend to be `cli` (for compatibility with some programs that check `PHP_SAPI`) - `--disable-opcache-jit`: Disable opcache jit (enabled by default) diff --git a/docs/en/guide/manual-build.md b/docs/en/guide/manual-build.md index 487d33294..8e52cc988 100644 --- a/docs/en/guide/manual-build.md +++ b/docs/en/guide/manual-build.md @@ -304,6 +304,7 @@ You can try to use the following commands: - `--enable-zts`: Make compiled PHP thread-safe version (default is NTS version) - `--no-strip`: Do not run `strip` after compiling the PHP library to trim the binary file to reduce its size (the macOS binary file without trim can use dynamically linked third-party extensions) - `--with-libs=XXX,YYY`: Compile the specified dependent library before compiling PHP, and activate some extended optional functions (such as libavif of the gd library, etc.) +- `--with-config-file-path=XXX`: Set the path in which to look for php.ini - `-I xxx=yyy`: Hard compile INI options into PHP before compiling (support multiple options, alias is `--with-hardcoded-ini`) - `--with-micro-fake-cli`: When compiling micro, let micro's `PHP_SAPI` pretend to be `cli` (for compatibility with some programs that check `PHP_SAPI`) - `--disable-opcache-jit`: Disable opcache jit (enabled by default) diff --git a/docs/zh/guide/manual-build.md b/docs/zh/guide/manual-build.md index 98f939a78..f5f1ac1f3 100644 --- a/docs/zh/guide/manual-build.md +++ b/docs/zh/guide/manual-build.md @@ -265,6 +265,7 @@ bin/spc build mysqlnd,pdo_mysql --build-all --debug - `--enable-zts`: 让编译的 PHP 为线程安全版本(默认为 NTS 版本) - `--no-strip`: 编译 PHP 库后不运行 `strip` 裁剪二进制文件缩小体积(不裁剪的 macOS 二进制文件可使用动态链接的第三方扩展) - `--with-libs=XXX,YYY`: 编译 PHP 前先编译指定的依赖库,激活部分扩展的可选功能(例如 gd 库的 libavif 等) +- `--with-config-file-path=XXX`: 指定 PHP 配置文件的路径 - `-I xxx=yyy`: 编译前将 INI 选项硬编译到 PHP 内(支持多个选项,别名是 `--with-hardcoded-ini`) - `--with-micro-fake-cli`: 在编译 micro 时,让 micro 的 SAPI 伪装为 `cli`(用于兼容一些检查 `PHP_SAPI` 的程序) - `--disable-opcache-jit`: 禁用 opcache jit(默认启用) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 1e07a6240..669ec5602 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -134,6 +134,9 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void } $disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : ''; + $config_file_path = $this->getOption('with-config-file-path', false) ? + ('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : ''; + $enable_cli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; $enable_fpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enable_micro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; @@ -163,6 +166,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void ($enable_fpm ? '--enable-fpm ' : '--disable-fpm ') . ($enable_embed ? '--enable-embed=static ' : '--disable-embed ') . ($enable_micro ? '--enable-micro=all-static ' : '--disable-micro ') . + $config_file_path . $disable_jit . $json_74 . $zts . diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index a29e99546..a9fa8349f 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -137,6 +137,9 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; + $config_file_path = $this->getOption('with-config-file-path', false) ? + ('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : ''; + $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; @@ -164,6 +167,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . ($enableMicro ? '--enable-micro ' : '--disable-micro ') . + $config_file_path . $json_74 . $zts . $this->makeExtensionArgs() . ' ' . diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 2356e96f4..18660603e 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -32,6 +32,7 @@ public function configure(): void $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); $this->addOption('enable-zts', null, null, 'enable ZTS support'); $this->addOption('disable-opcache-jit', null, null, 'disable opcache jit'); + $this->addOption('with-config-file-path', null, InputOption::VALUE_REQUIRED, 'Set the path in which to look for php.ini'); $this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI'); $this->addOption('with-micro-fake-cli', null, null, 'Let phpmicro\'s PHP_SAPI use "cli" instead of "micro"'); $this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs'); @@ -114,6 +115,9 @@ public function handle(): int 'Strip Binaries' => $builder->getOption('no-strip') ? 'no' : 'yes', 'Enable ZTS' => $builder->getOption('enable-zts') ? 'yes' : 'no', ]; + if (!empty($this->input->getOption('with-config-file-path'))) { + $indent_texts['Config File Path'] = $this->input->getOption('with-config-file-path'); + } if (!empty($this->input->getOption('with-hardcoded-ini'))) { $indent_texts['Hardcoded INI'] = $this->input->getOption('with-hardcoded-ini'); }