File tree Expand file tree Collapse file tree 5 files changed +24
-3
lines changed
Expand file tree Collapse file tree 5 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,8 @@ SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
7979SPC_CMD_PREFIX_PHP_CONFIGURE =" ${SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD} ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic"
8080; make command
8181SPC_CMD_PREFIX_PHP_MAKE =" make -j${CPU_COUNT}"
82+ ; embed type for php, static (libphp.a) or shared (libphp.so)
83+ SPC_CMD_VAR_PHP_EMBED_TYPE =" shared"
8284
8385; *** default build vars for building php ***
8486; CFLAGS for configuring php
@@ -115,6 +117,8 @@ SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
115117SPC_CMD_PREFIX_PHP_CONFIGURE =" ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg"
116118; make command
117119SPC_CMD_PREFIX_PHP_MAKE =" make -j${CPU_COUNT}"
120+ ; embed type for php, static or shared
121+ SPC_CMD_VAR_PHP_EMBED_TYPE =" static"
118122
119123; *** default build vars for building php ***
120124; CFLAGS for configuring php
Original file line number Diff line number Diff line change @@ -169,12 +169,13 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
169169 // micro latest needs do strip and upx pack later (strip, upx, cut binary manually supported)
170170 }
171171
172+ $ embed_type = getenv ('SPC_CMD_VAR_PHP_EMBED_TYPE ' ) ?: 'static ' ;
172173 shell ()->cd (SOURCE_PATH . '/php-src ' )
173174 ->exec (
174175 getenv ('SPC_CMD_PREFIX_PHP_CONFIGURE ' ) . ' ' .
175176 ($ enable_cli ? '--enable-cli ' : '--disable-cli ' ) .
176177 ($ enable_fpm ? '--enable-fpm ' : '--disable-fpm ' ) .
177- ($ enable_embed ? ' --enable-embed=static ' : '--disable-embed ' ) .
178+ ($ enable_embed ? " --enable-embed= { $ embed_type } " : '--disable-embed ' ) .
178179 ($ enable_micro ? '--enable-micro=all-static ' : '--disable-micro ' ) .
179180 $ config_file_path .
180181 $ config_file_scan_dir .
Original file line number Diff line number Diff line change @@ -162,12 +162,13 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
162162 );
163163 }
164164
165+ $ embed_type = getenv ('SPC_CMD_VAR_PHP_EMBED_TYPE ' ) ?: 'static ' ;
165166 shell ()->cd (SOURCE_PATH . '/php-src ' )
166167 ->exec (
167168 getenv ('SPC_CMD_PREFIX_PHP_CONFIGURE ' ) . ' ' .
168169 ($ enableCli ? '--enable-cli ' : '--disable-cli ' ) .
169170 ($ enableFpm ? '--enable-fpm ' : '--disable-fpm ' ) .
170- ($ enableEmbed ? ' --enable-embed=static ' : '--disable-embed ' ) .
171+ ($ enableEmbed ? " --enable-embed= { $ embed_type } " : '--disable-embed ' ) .
171172 ($ enableMicro ? '--enable-micro ' : '--disable-micro ' ) .
172173 $ config_file_path .
173174 $ config_file_scan_dir .
Original file line number Diff line number Diff line change @@ -192,7 +192,15 @@ protected function sanityCheck(int $build_target): void
192192 if ($ ret !== 0 ) {
193193 throw new RuntimeException ('embed failed sanity check: build failed. Error message: ' . implode ("\n" , $ out ));
194194 }
195- [$ ret , $ output ] = shell ()->cd ($ sample_file_path )->execWithResult ('./embed ' );
195+ // if someone changed to --enable-embed=shared, we need to add LD_LIBRARY_PATH
196+ if (getenv ('SPC_CMD_VAR_PHP_EMBED_TYPE ' ) === 'shared ' ) {
197+ $ ext_path = 'LD_LIBRARY_PATH= ' . BUILD_ROOT_PATH . '/lib:$LD_LIBRARY_PATH ' ;
198+ FileSystem::removeFileIfExists (BUILD_ROOT_PATH . '/lib/libphp.a ' );
199+ } else {
200+ $ ext_path = '' ;
201+ FileSystem::removeFileIfExists (BUILD_ROOT_PATH . '/lib/libphp.so ' );
202+ }
203+ [$ ret , $ output ] = shell ()->cd ($ sample_file_path )->execWithResult ($ ext_path . './embed ' );
196204 if ($ ret !== 0 || trim (implode ('' , $ output )) !== 'hello ' ) {
197205 throw new RuntimeException ('embed failed sanity check: run failed. Error message: ' . implode ("\n" , $ output ));
198206 }
Original file line number Diff line number Diff line change @@ -454,6 +454,13 @@ public static function restoreBackupFile(string $path): void
454454 unlink ($ path . '.bak ' );
455455 }
456456
457+ public static function removeFileIfExists (string $ string ): void
458+ {
459+ if (file_exists ($ string )) {
460+ unlink ($ string );
461+ }
462+ }
463+
457464 /**
458465 * @throws RuntimeException
459466 * @throws FileSystemException
You can’t perform that action at this time.
0 commit comments