1616use SPC \store \Downloader ;
1717use SPC \store \FileSystem ;
1818use SPC \store \pkg \GoXcaddy ;
19+ use SPC \store \pkg \Zig ;
1920use SPC \util \DependencyUtil ;
21+ use SPC \util \GlobalEnvManager ;
2022use SPC \util \SPCConfigUtil ;
2123
2224abstract class UnixBuilderBase extends BuilderBase
@@ -52,7 +54,7 @@ public function getAllStaticLibFiles(): array
5254 array_unshift ($ libFiles , ...$ lib ->getStaticLibs ());
5355 }
5456 }
55- return array_map (fn ($ x ) => realpath (BUILD_LIB_PATH . "/ {$ x }" ), $ libFiles );
57+ return array_map (fn ($ x ) => realpath (BUILD_LIB_PATH . "/ {$ x }" ), $ libFiles );
5658 }
5759
5860 /**
@@ -98,7 +100,8 @@ public function makeAutoconfArgs(string $name, array $libSpecs): string
98100 if ($ lib instanceof LinuxLibraryBase || $ lib instanceof MacOSLibraryBase || $ lib instanceof BSDLibraryBase) {
99101 logger ()->info ("{$ name } \033[32;1mwith \033[0;1m {$ libName } support " );
100102 $ ret .= "--with- {$ libName }=yes " . $ lib ->makeAutoconfEnv ($ prefix ) . ' ' ;
101- } else {
103+ }
104+ else {
102105 logger ()->info ("{$ name } \033[31;1mwithout \033[0;1m {$ libName } support " );
103106 $ ret .= ($ disableArgs ?? "--with- {$ libName }=no " ) . ' ' ;
104107 }
@@ -212,7 +215,8 @@ protected function sanityCheck(int $build_target): void
212215 if (getenv ('SPC_CMD_VAR_PHP_EMBED_TYPE ' ) === 'shared ' ) {
213216 $ ext_path = 'LD_LIBRARY_PATH= ' . BUILD_ROOT_PATH . '/lib:$LD_LIBRARY_PATH ' ;
214217 FileSystem::removeFileIfExists (BUILD_ROOT_PATH . '/lib/libphp.a ' );
215- } else {
218+ }
219+ else {
216220 $ ext_path = '' ;
217221 FileSystem::removeFileIfExists (BUILD_ROOT_PATH . '/lib/libphp.so ' );
218222 }
@@ -241,7 +245,7 @@ protected function sanityCheck(int $build_target): void
241245 /**
242246 * 将编译好的二进制文件发布到 buildroot
243247 *
244- * @param int $type 发布类型
248+ * @param int $type 发布类型
245249 * @throws RuntimeException
246250 * @throws FileSystemException
247251 */
@@ -333,7 +337,7 @@ protected function buildFrankenphp(): void
333337
334338 $ config = (new SPCConfigUtil ($ this ))->config ($ this ->ext_list , $ this ->lib_list , with_dependencies: true );
335339
336- $ env = [...GoXcaddy:: getEnvironment (), ...[
340+ $ env = [
337341 'CGO_ENABLED ' => '1 ' ,
338342 'CGO_CFLAGS ' => $ config ['cflags ' ],
339343 'CGO_LDFLAGS ' => "{$ config ['ldflags ' ]} {$ config ['libs ' ]} {$ lrt }" ,
@@ -343,7 +347,14 @@ protected function buildFrankenphp(): void
343347 "{$ frankenPhpVersion } PHP {$ libphpVersion } Caddy' \\\" " .
344348 "-tags= {$ muslTags }nobadger,nomysql,nopgx {$ nobrotli }{$ nowatcher }" ,
345349 'LD_LIBRARY_PATH ' => BUILD_LIB_PATH ,
346- ]];
350+ ];
351+ foreach (GoXcaddy::getEnvironment () as $ key => $ value ) {
352+ if ($ key === 'PATH ' ) {
353+ GlobalEnvManager::addPathIfNotExists ($ value );
354+ } else {
355+ $ env [$ key ] = $ value ;
356+ }
357+ }
347358 shell ()->cd (BUILD_BIN_PATH )
348359 ->setEnv ($ env )
349360 ->exec ("xcaddy build --output frankenphp {$ xcaddyModules }" );
0 commit comments