@@ -84,6 +84,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
84
84
$ enableMicro = ($ build_target & BUILD_TARGET_MICRO ) === BUILD_TARGET_MICRO ;
85
85
$ enableEmbed = ($ build_target & BUILD_TARGET_EMBED ) === BUILD_TARGET_EMBED ;
86
86
$ enableFrankenphp = ($ build_target & BUILD_TARGET_FRANKENPHP ) === BUILD_TARGET_FRANKENPHP ;
87
+ $ enableCgi = ($ build_target & BUILD_TARGET_CGI ) === BUILD_TARGET_CGI ;
87
88
88
89
// prepare build php envs
89
90
// $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__';
@@ -110,6 +111,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
110
111
($ enableFpm ? '--enable-fpm ' . ($ this ->getLib ('libacl ' ) !== null ? '--with-fpm-acl ' : '' ) : '--disable-fpm ' ) .
111
112
($ enableEmbed ? "--enable-embed= {$ embed_type } " : '--disable-embed ' ) .
112
113
($ enableMicro ? '--enable-micro=all-static ' : '--disable-micro ' ) .
114
+ ($ enableCgi ? '--enable-cgi ' : '--disable-cgi ' ) .
113
115
$ config_file_path .
114
116
$ config_file_scan_dir .
115
117
$ json_74 .
@@ -131,6 +133,10 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
131
133
logger ()->info ('building fpm ' );
132
134
$ this ->buildFpm ();
133
135
}
136
+ if ($ enableCgi ) {
137
+ logger ()->info ('building cgi ' );
138
+ $ this ->buildCgi ();
139
+ }
134
140
if ($ enableMicro ) {
135
141
logger ()->info ('building micro ' );
136
142
$ this ->buildMicro ();
@@ -182,6 +188,25 @@ protected function buildCli(): void
182
188
$ this ->deployBinary (BUILD_TARGET_CLI );
183
189
}
184
190
191
+ protected function buildCgi (): void
192
+ {
193
+ $ vars = SystemUtil::makeEnvVarString ($ this ->getMakeExtraVars ());
194
+ $ SPC_CMD_PREFIX_PHP_MAKE = getenv ('SPC_CMD_PREFIX_PHP_MAKE ' ) ?: 'make ' ;
195
+ shell ()->cd (SOURCE_PATH . '/php-src ' )
196
+ ->exec ('sed -i "s|//lib|/lib|g" Makefile ' )
197
+ ->exec ("{$ SPC_CMD_PREFIX_PHP_MAKE } {$ vars } cgi " );
198
+
199
+ if (!$ this ->getOption ('no-strip ' , false )) {
200
+ shell ()->cd (SOURCE_PATH . '/php-src/sapi/cgi ' )->exec ('strip --strip-unneeded php-cgi ' );
201
+ }
202
+ if ($ this ->getOption ('with-upx-pack ' )) {
203
+ shell ()->cd (SOURCE_PATH . '/php-src/sapi/cgi ' )
204
+ ->exec (getenv ('UPX_EXEC ' ) . ' --best php-cgi ' );
205
+ }
206
+
207
+ $ this ->deployBinary (BUILD_TARGET_CGI );
208
+ }
209
+
185
210
/**
186
211
* Build phpmicro sapi
187
212
*/
0 commit comments