Skip to content

Commit ec584bf

Browse files
mobot95andrea.esucrazywhalecc
authored
Add option to manually specify config file path (#511)
* Add Config File Path option * Fix Manual * quotation marks changes * php-cs-fixer * Remove windows config file path option * Add macOS config file path option * Add chinese docs --------- Co-authored-by: andrea.esu <KjsnM@@1_-2!> Co-authored-by: crazywhalecc <[email protected]>
1 parent ca8ec70 commit ec584bf

File tree

6 files changed

+16
-1
lines changed

6 files changed

+16
-1
lines changed

docs/en/guide/build-on-windows.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ You can try to use the following commands:
159159

160160
- `--with-clean`: clean up old make files before compiling PHP
161161
- `--enable-zts`: Make compiled PHP thread-safe version (default is NTS version)
162-
- `--with-libs=XXX,YYY`: Compile the specified dependent library before compiling PHP, and activate some extension optional functions
162+
- `--with-libs=XXX,YYY`: Compile the specified dependent library before compiling PHP, and activate some extension optional functions
163+
- `--with-config-file-path=XXX`: Set the path in which to look for php.ini
163164
- `-I xxx=yyy`: Hard compile INI options into PHP before compiling (support multiple options, alias is `--with-hardcoded-ini`)
164165
- `--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`)
165166
- `--disable-opcache-jit`: Disable opcache jit (enabled by default)

docs/en/guide/manual-build.md

+1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ You can try to use the following commands:
304304
- `--enable-zts`: Make compiled PHP thread-safe version (default is NTS version)
305305
- `--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)
306306
- `--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.)
307+
- `--with-config-file-path=XXX`: Set the path in which to look for php.ini
307308
- `-I xxx=yyy`: Hard compile INI options into PHP before compiling (support multiple options, alias is `--with-hardcoded-ini`)
308309
- `--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`)
309310
- `--disable-opcache-jit`: Disable opcache jit (enabled by default)

docs/zh/guide/manual-build.md

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ bin/spc build mysqlnd,pdo_mysql --build-all --debug
265265
- `--enable-zts`: 让编译的 PHP 为线程安全版本(默认为 NTS 版本)
266266
- `--no-strip`: 编译 PHP 库后不运行 `strip` 裁剪二进制文件缩小体积(不裁剪的 macOS 二进制文件可使用动态链接的第三方扩展)
267267
- `--with-libs=XXX,YYY`: 编译 PHP 前先编译指定的依赖库,激活部分扩展的可选功能(例如 gd 库的 libavif 等)
268+
- `--with-config-file-path=XXX`: 指定 PHP 配置文件的路径
268269
- `-I xxx=yyy`: 编译前将 INI 选项硬编译到 PHP 内(支持多个选项,别名是 `--with-hardcoded-ini`
269270
- `--with-micro-fake-cli`: 在编译 micro 时,让 micro 的 SAPI 伪装为 `cli`(用于兼容一些检查 `PHP_SAPI` 的程序)
270271
- `--disable-opcache-jit`: 禁用 opcache jit(默认启用)

src/SPC/builder/linux/LinuxBuilder.php

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
134134
}
135135
$disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : '';
136136

137+
$config_file_path = $this->getOption('with-config-file-path', false) ?
138+
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
139+
137140
$enable_cli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI;
138141
$enable_fpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM;
139142
$enable_micro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
@@ -163,6 +166,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
163166
($enable_fpm ? '--enable-fpm ' : '--disable-fpm ') .
164167
($enable_embed ? '--enable-embed=static ' : '--disable-embed ') .
165168
($enable_micro ? '--enable-micro=all-static ' : '--disable-micro ') .
169+
$config_file_path .
166170
$disable_jit .
167171
$json_74 .
168172
$zts .

src/SPC/builder/macos/MacOSBuilder.php

+4
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
137137
$json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : '';
138138
$zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : '';
139139

140+
$config_file_path = $this->getOption('with-config-file-path', false) ?
141+
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
142+
140143
$enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI;
141144
$enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM;
142145
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
@@ -164,6 +167,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
164167
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
165168
($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') .
166169
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
170+
$config_file_path .
167171
$json_74 .
168172
$zts .
169173
$this->makeExtensionArgs() . ' ' .

src/SPC/command/BuildCliCommand.php

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function configure(): void
3232
$this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions');
3333
$this->addOption('enable-zts', null, null, 'enable ZTS support');
3434
$this->addOption('disable-opcache-jit', null, null, 'disable opcache jit');
35+
$this->addOption('with-config-file-path', null, InputOption::VALUE_REQUIRED, 'Set the path in which to look for php.ini');
3536
$this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI');
3637
$this->addOption('with-micro-fake-cli', null, null, 'Let phpmicro\'s PHP_SAPI use "cli" instead of "micro"');
3738
$this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs');
@@ -114,6 +115,9 @@ public function handle(): int
114115
'Strip Binaries' => $builder->getOption('no-strip') ? 'no' : 'yes',
115116
'Enable ZTS' => $builder->getOption('enable-zts') ? 'yes' : 'no',
116117
];
118+
if (!empty($this->input->getOption('with-config-file-path'))) {
119+
$indent_texts['Config File Path'] = $this->input->getOption('with-config-file-path');
120+
}
117121
if (!empty($this->input->getOption('with-hardcoded-ini'))) {
118122
$indent_texts['Hardcoded INI'] = $this->input->getOption('with-hardcoded-ini');
119123
}

0 commit comments

Comments
 (0)