Skip to content

Commit 123cc92

Browse files
committed
Extract default build env to unix shell
1 parent 9babe7f commit 123cc92

29 files changed

+166
-196
lines changed

src/SPC/builder/Extension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ public function buildUnixShared(): void
301301
// prepare configure args
302302
shell()->cd($this->source_dir)
303303
->setEnv($env)
304-
->execWithEnv(BUILD_BIN_PATH . '/phpize')
305-
->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static')
306-
->execWithEnv('make clean')
307-
->execWithEnv('make -j' . $this->builder->concurrency);
304+
->exec(BUILD_BIN_PATH . '/phpize')
305+
->exec('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static')
306+
->exec('make clean')
307+
->exec('make -j' . $this->builder->concurrency);
308308

309309
// copy shared library
310310
copy($this->source_dir . '/modules/' . $this->getDistName() . '.so', BUILD_LIB_PATH . '/' . $this->getDistName() . '.so');

src/SPC/builder/linux/library/libffi.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public function build(): void
2121
$arch = getenv('SPC_ARCH');
2222

2323
shell()->cd($this->source_dir)
24-
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
25-
->execWithEnv(
24+
->initLibBuildEnv($this)
25+
->exec(
2626
'./configure ' .
2727
'--enable-static ' .
2828
'--disable-shared ' .
@@ -31,9 +31,9 @@ public function build(): void
3131
'--prefix= ' .
3232
"--libdir={$lib}"
3333
)
34-
->execWithEnv('make clean')
35-
->execWithEnv("make -j{$this->builder->concurrency}")
36-
->execWithEnv("make install DESTDIR={$destdir}");
34+
->exec('make clean')
35+
->exec("make -j{$this->builder->concurrency}")
36+
->exec("make install DESTDIR={$destdir}");
3737

3838
if (is_file(BUILD_ROOT_PATH . '/lib64/libffi.a')) {
3939
copy(BUILD_ROOT_PATH . '/lib64/libffi.a', BUILD_ROOT_PATH . '/lib/libffi.a');

src/SPC/builder/linux/library/libpng.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,10 @@ public function build(): void
4141
'aarch64' => '--enable-arm-neon ',
4242
default => '',
4343
};
44-
shell()->cd($this->source_dir)
44+
shell()->cd($this->source_dir)->initLibBuildEnv($this)
4545
->exec('chmod +x ./configure')
4646
->exec('chmod +x ./install-sh')
47-
->setEnv([
48-
'CFLAGS' => trim($this->getLibExtraCFlags() . ' ' . $this->builder->arch_c_flags),
49-
'LDFLAGS' => $this->getLibExtraLdFlags(),
50-
'LIBS' => $this->getLibExtraLibs(),
51-
])
52-
->execWithEnv(
47+
->exec(
5348
'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' .
5449
'./configure ' .
5550
'--disable-shared ' .
@@ -59,9 +54,9 @@ public function build(): void
5954
$optimizations .
6055
'--prefix='
6156
)
62-
->execWithEnv('make clean')
63-
->execWithEnv("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la")
64-
->execWithEnv('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH);
57+
->exec('make clean')
58+
->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la")
59+
->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH);
6560
$this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX);
6661
$this->cleanLaFiles();
6762
}

src/SPC/builder/linux/library/openssl.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ public function build(): void
6464

6565
$clang_postfix = SystemUtil::getCCType(getenv('CC')) === 'clang' ? '-clang' : '';
6666

67-
shell()->cd($this->source_dir)
68-
->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $this->builder->arch_c_flags, 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
69-
->execWithEnv(
67+
shell()->cd($this->source_dir)->initLibBuildEnv($this)
68+
->exec(
7069
"{$env} ./Configure no-shared {$extra} " .
7170
'--prefix=/ ' .
7271
'--libdir=lib ' .
@@ -76,7 +75,7 @@ public function build(): void
7675
"linux-{$arch}{$clang_postfix}"
7776
)
7877
->exec('make clean')
79-
->execWithEnv("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
78+
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
8079
->exec("make install_sw DESTDIR={$destdir}");
8180
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
8281
// patch for openssl 3.3.0+

src/SPC/builder/macos/library/openssl.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ protected function build(): void
4949
}
5050
$arch = getenv('SPC_ARCH');
5151

52-
shell()->cd($this->source_dir)
53-
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
52+
shell()->cd($this->source_dir)->initLibBuildEnv($this)
5453
->exec(
5554
"./Configure no-shared {$extra} " .
5655
'--prefix=/ ' . // use prefix=/
@@ -59,7 +58,7 @@ protected function build(): void
5958
"darwin64-{$arch}-cc"
6059
)
6160
->exec('make clean')
62-
->execWithEnv("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
61+
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
6362
->exec("make install_sw DESTDIR={$destdir}");
6463
$this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']);
6564
// patch for openssl 3.3.0+

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@ trait attr
1313
*/
1414
protected function build(): void
1515
{
16-
shell()->cd($this->source_dir)
17-
->setEnv([
18-
'CFLAGS' => trim('-I' . BUILD_INCLUDE_PATH . ' ' . $this->getLibExtraCFlags()),
19-
'LDFLAGS' => trim('-L' . BUILD_LIB_PATH . ' ' . $this->getLibExtraLdFlags()),
20-
'LIBS' => $this->getLibExtraLibs(),
21-
])
22-
->execWithEnv('libtoolize --force --copy')
23-
->execWithEnv('./autogen.sh || autoreconf -if')
24-
->execWithEnv('./configure --prefix= --enable-static --disable-shared --with-pic --disable-nls')
25-
->execWithEnv("make -j {$this->builder->concurrency}")
16+
shell()->cd($this->source_dir)->initLibBuildEnv($this)
17+
->appendEnv(['CFLAGS' => "-I{$this->getIncludeDir()}", 'LDFLAGS' => "-L{$this->getLibDir()}"])
18+
->exec('libtoolize --force --copy')
19+
->exec('./autogen.sh || autoreconf -if')
20+
->exec('./configure --prefix= --enable-static --disable-shared --with-pic --disable-nls')
21+
->exec("make -j {$this->builder->concurrency}")
2622
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
2723

2824
$this->patchPkgconfPrefix(['libattr.pc'], PKGCONF_PATCH_PREFIX);

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ public function patchBeforeBuild(): bool
1616

1717
protected function build(): void
1818
{
19-
shell()->cd($this->source_dir)
20-
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
21-
->execWithEnv("make PREFIX='" . BUILD_ROOT_PATH . "' clean")
22-
->execWithEnv("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
19+
shell()->cd($this->source_dir)->initLibBuildEnv($this)
20+
->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean")
21+
->exec("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
2322
->exec('cp libbz2.a ' . BUILD_LIB_PATH)
2423
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
2524
}

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@ protected function build(): void
1616
$cflags = $this->builder->getOption('enable-zts') ? '-lpthread -D_REENTRANT' : '';
1717
$ldflags = $this->builder->getOption('enable-zts') ? '-lpthread' : '';
1818

19-
shell()->cd($this->source_dir)
20-
->setEnv([
21-
'CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}",
22-
'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags,
23-
'LIBS' => $this->getLibExtraLibs(),
24-
])
25-
->execWithEnv(
19+
shell()->cd($this->source_dir)->initLibBuildEnv($this)
20+
->appendEnv(['CFLAGS' => $cflags, 'LDFLAGS' => $ldflags])
21+
->exec(
2622
'./configure ' .
2723
'--enable-static ' .
2824
'--disable-shared ' .
@@ -34,8 +30,8 @@ protected function build(): void
3430
'--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' .
3531
'--prefix=' . BUILD_ROOT_PATH
3632
)
37-
->execWithEnv('make clean')
38-
->execWithEnv("make -j{$this->builder->concurrency}")
39-
->execWithEnv('make install');
33+
->exec('make clean')
34+
->exec("make -j{$this->builder->concurrency}")
35+
->exec('make install');
4036
}
4137
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ trait gmp
1515
*/
1616
protected function build(): void
1717
{
18-
shell()->cd($this->source_dir)
19-
->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $this->builder->arch_c_flags, 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
20-
->execWithEnv(
18+
shell()->cd($this->source_dir)->initLibBuildEnv($this)
19+
->exec(
2120
'./configure ' .
2221
'--enable-static --disable-shared ' .
2322
'--prefix='
2423
)
25-
->execWithEnv('make clean')
26-
->execWithEnv("make -j{$this->builder->concurrency}")
24+
->exec('make clean')
25+
->exec("make -j{$this->builder->concurrency}")
2726
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
2827
$this->patchPkgconfPrefix(['gmp.pc']);
2928
}

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,9 @@ protected function build(): void
4646

4747
// libxml iconv patch
4848
$required_libs .= $this instanceof MacOSLibraryBase ? ('-liconv') : '';
49-
shell()->cd($this->source_dir)
50-
->setEnv([
51-
'CFLAGS' => $this->getLibExtraCFlags(),
52-
'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags,
53-
'LIBS' => $this->getLibExtraLibs() ?: $required_libs,
54-
'PKG_CONFIG' => '$PKG_CONFIG --static',
55-
])
56-
->execWithEnv(
49+
shell()->cd($this->source_dir)->initLibBuildEnv($this)
50+
->appendEnv(['LDFLAGS' => $ldflags, 'LIBS' => $required_libs, 'PKG_CONFIG' => '$PKG_CONFIG --static'])
51+
->exec(
5752
'./configure ' .
5853
'--enable-static --disable-shared ' .
5954
$extra .

0 commit comments

Comments
 (0)