Skip to content

Commit a7e48a8

Browse files
authored
Merge pull request #748 from crazywhalecc/feat/h3
simplify makeAutoConfArgs, fix macOS differences
2 parents fce115d + 4fae158 commit a7e48a8

File tree

4 files changed

+37
-59
lines changed

4 files changed

+37
-59
lines changed

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace SPC\builder\linux;
66

7-
use SPC\builder\linux\library\LinuxLibraryBase;
87
use SPC\builder\unix\UnixBuilderBase;
98
use SPC\exception\FileSystemException;
109
use SPC\exception\RuntimeException;
@@ -70,35 +69,6 @@ public function __construct(array $options = [])
7069
f_mkdir(BUILD_INCLUDE_PATH, recursive: true);
7170
}
7271

73-
/**
74-
* @throws FileSystemException
75-
* @throws RuntimeException
76-
* @throws WrongUsageException
77-
*/
78-
public function makeAutoconfArgs(string $name, array $libSpecs): string
79-
{
80-
$ret = '';
81-
foreach ($libSpecs as $libName => $arr) {
82-
$lib = $this->getLib($libName);
83-
if ($lib === null && str_starts_with($libName, 'lib')) {
84-
$lib = $this->getLib(substr($libName, 3));
85-
}
86-
87-
$arr = $arr ?? [];
88-
89-
$disableArgs = $arr[0] ?? null;
90-
$prefix = $arr[1] ?? null;
91-
if ($lib instanceof LinuxLibraryBase) {
92-
logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support");
93-
$ret .= $lib->makeAutoconfEnv($prefix) . ' ';
94-
} else {
95-
logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support");
96-
$ret .= ($disableArgs ?? "--with-{$libName}=no") . ' ';
97-
}
98-
}
99-
return rtrim($ret);
100-
}
101-
10272
/**
10373
* Build PHP from source.
10474
*

src/SPC/builder/macos/MacOSBuilder.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,35 +44,6 @@ public function __construct(array $options = [])
4444
f_mkdir(BUILD_INCLUDE_PATH, recursive: true);
4545
}
4646

47-
/**
48-
* [deprecated] 生成库构建采用的 autoconf 参数列表
49-
*
50-
* @param string $name 要构建的 lib 库名,传入仅供输出日志
51-
* @param array $lib_specs 依赖的 lib 库的 autoconf 文件
52-
*/
53-
public function makeAutoconfArgs(string $name, array $lib_specs): string
54-
{
55-
$ret = '';
56-
foreach ($lib_specs as $libName => $arr) {
57-
$lib = $this->getLib($libName);
58-
if ($lib === null && str_starts_with($libName, 'lib')) {
59-
$lib = $this->getLib(substr($libName, 3));
60-
}
61-
62-
$arr = $arr ?? [];
63-
64-
$disableArgs = $arr[0] ?? null;
65-
if ($lib instanceof MacOSLibraryBase) {
66-
logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support");
67-
$ret .= '--with-' . $libName . '=yes ';
68-
} else {
69-
logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support");
70-
$ret .= ($disableArgs ?? "--with-{$libName}=no") . ' ';
71-
}
72-
}
73-
return rtrim($ret);
74-
}
75-
7647
/**
7748
* Get dynamically linked macOS frameworks
7849
*

src/SPC/builder/unix/UnixBuilderBase.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
namespace SPC\builder\unix;
66

77
use SPC\builder\BuilderBase;
8+
use SPC\builder\freebsd\library\BSDLibraryBase;
9+
use SPC\builder\linux\library\LinuxLibraryBase;
810
use SPC\builder\linux\LinuxBuilder;
11+
use SPC\builder\macos\library\MacOSLibraryBase;
912
use SPC\exception\FileSystemException;
1013
use SPC\exception\RuntimeException;
1114
use SPC\exception\WrongUsageException;
@@ -90,6 +93,35 @@ public function makeAutoconfFlags(int $flag = AUTOCONF_ALL): string
9093
return $extra;
9194
}
9295

96+
/**
97+
* @throws FileSystemException
98+
* @throws RuntimeException
99+
* @throws WrongUsageException
100+
*/
101+
public function makeAutoconfArgs(string $name, array $libSpecs): string
102+
{
103+
$ret = '';
104+
foreach ($libSpecs as $libName => $arr) {
105+
$lib = $this->getLib($libName);
106+
if ($lib === null && str_starts_with($libName, 'lib')) {
107+
$lib = $this->getLib(substr($libName, 3));
108+
}
109+
110+
$arr = $arr ?? [];
111+
112+
$disableArgs = $arr[0] ?? null;
113+
$prefix = $arr[1] ?? null;
114+
if ($lib instanceof LinuxLibraryBase || $lib instanceof MacOSLibraryBase || $lib instanceof BSDLibraryBase) {
115+
logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support");
116+
$ret .= "--with-{$libName}=yes " . $lib->makeAutoconfEnv($prefix) . ' ';
117+
} else {
118+
logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support");
119+
$ret .= ($disableArgs ?? "--with-{$libName}=no") . ' ';
120+
}
121+
}
122+
return rtrim($ret);
123+
}
124+
93125
public function proveLibs(array $sorted_libraries): void
94126
{
95127
// search all supported libs

src/SPC/builder/unix/library/ngtcp2.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,10 @@ protected function build(): void
4949
->execWithEnv("make -j{$this->builder->concurrency}")
5050
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
5151
$this->patchPkgconfPrefix(['libngtcp2.pc', 'libngtcp2_crypto_ossl.pc']);
52+
53+
// on macOS, the static library may contain other static libraries?
54+
// ld: archive member 'libssl.a' not a mach-o file in libngtcp2_crypto_ossl.a
55+
shell()->cd(BUILD_LIB_PATH)
56+
->exec("ar -t libngtcp2_crypto_ossl.a | grep '\\.a$' | xargs -n1 ar d libngtcp2_crypto_ossl.a");
5257
}
5358
}

0 commit comments

Comments
 (0)