@@ -84,6 +84,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
8484 $ enableMicro = ($ build_target & BUILD_TARGET_MICRO ) === BUILD_TARGET_MICRO ;
8585 $ enableEmbed = ($ build_target & BUILD_TARGET_EMBED ) === BUILD_TARGET_EMBED ;
8686 $ enableFrankenphp = ($ build_target & BUILD_TARGET_FRANKENPHP ) === BUILD_TARGET_FRANKENPHP ;
87+ $ enableCgi = ($ build_target & BUILD_TARGET_CGI ) === BUILD_TARGET_CGI ;
8788
8889 // prepare build php envs
8990 // $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__';
@@ -110,6 +111,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
110111 ($ enableFpm ? '--enable-fpm ' . ($ this ->getLib ('libacl ' ) !== null ? '--with-fpm-acl ' : '' ) : '--disable-fpm ' ) .
111112 ($ enableEmbed ? "--enable-embed= {$ embed_type } " : '--disable-embed ' ) .
112113 ($ enableMicro ? '--enable-micro=all-static ' : '--disable-micro ' ) .
114+ ($ enableCgi ? '--enable-cgi ' : '--disable-cgi ' ) .
113115 $ config_file_path .
114116 $ config_file_scan_dir .
115117 $ json_74 .
@@ -131,6 +133,10 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
131133 logger ()->info ('building fpm ' );
132134 $ this ->buildFpm ();
133135 }
136+ if ($ enableCgi ) {
137+ logger ()->info ('building cgi ' );
138+ $ this ->buildCgi ();
139+ }
134140 if ($ enableMicro ) {
135141 logger ()->info ('building micro ' );
136142 $ this ->buildMicro ();
@@ -182,6 +188,25 @@ protected function buildCli(): void
182188 $ this ->deployBinary (BUILD_TARGET_CLI );
183189 }
184190
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+
185210 /**
186211 * Build phpmicro sapi
187212 */
0 commit comments