@@ -19,17 +19,27 @@ class SPCTarget
1919 ];
2020
2121 /**
22- * Returns whether the target is a full-static target .
22+ * Returns whether we link the C runtime in statically .
2323 */
2424 public static function isStatic (): bool
2525 {
26- $ env = getenv ('SPC_TARGET ' );
2726 $ libc = getenv ('SPC_LIBC ' );
2827 // if SPC_LIBC is set, it means the target is static, remove it when 3.0 is released
2928 if ($ libc === 'musl ' ) {
3029 return true ;
3130 }
32- // TODO: add zig target parser here
31+ if ($ target = getenv ('SPC_TARGET ' )) {
32+ if (str_contains ($ target , '-macos ' ) || str_contains ($ target , '-native ' ) && PHP_OS_FAMILY === 'Darwin ' ) {
33+ return false ;
34+ }
35+ if (str_contains ($ target , '-gnu ' )) {
36+ return false ;
37+ }
38+ if (str_contains ($ target , '-dynamic ' )) {
39+ return false ;
40+ }
41+ return true ;
42+ }
3343 return false ;
3444 }
3545
@@ -38,12 +48,23 @@ public static function isStatic(): bool
3848 */
3949 public static function getLibc (): ?string
4050 {
41- $ env = getenv ('SPC_TARGET ' );
4251 $ libc = getenv ('SPC_LIBC ' );
4352 if ($ libc !== false ) {
4453 return $ libc ;
4554 }
46- // TODO: zig target parser
55+ $ target = getenv ('SPC_TARGET ' );
56+ if (str_contains ($ target , '-gnu ' )) {
57+ return 'glibc ' ;
58+ }
59+ if (str_contains ($ target , '-musl ' )) {
60+ return 'musl ' ;
61+ }
62+ if (str_contains ($ target , '-linux ' )) {
63+ return 'musl ' ;
64+ }
65+ if (PHP_OS_FAMILY === 'Linux ' && str_contains ($ target , '-native ' )) {
66+ return 'musl ' ;
67+ }
4768 return null ;
4869 }
4970
0 commit comments