Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust function to protected #315

Merged
merged 9 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/SPC/builder/BuilderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ abstract class BuilderBase
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @internal
*/
public function buildLibs(array $sorted_libraries): void
{
Expand Down Expand Up @@ -181,6 +182,8 @@ public function hasCpp(): bool

/**
* Set libs only mode.
*
* @internal
*/
public function setLibsOnly(bool $status = true): void
{
Expand All @@ -194,6 +197,7 @@ public function setLibsOnly(bool $status = true): void
* @throws RuntimeException
* @throws \ReflectionException
* @throws WrongUsageException
* @internal
*/
public function proveExts(array $extensions): void
{
Expand Down
8 changes: 4 additions & 4 deletions src/SPC/builder/freebsd/BSDBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildCli(): void
protected function buildCli(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
Expand All @@ -177,7 +177,7 @@ public function buildCli(): void
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildMicro(): void
protected function buildMicro(): void
{
if ($this->getPHPVersionID() < 80000) {
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
Expand Down Expand Up @@ -215,7 +215,7 @@ public function buildMicro(): void
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildFpm(): void
protected function buildFpm(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
Expand All @@ -235,7 +235,7 @@ public function buildFpm(): void
*
* @throws RuntimeException
*/
public function buildEmbed(): void
protected function buildEmbed(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
Expand Down
8 changes: 4 additions & 4 deletions src/SPC/builder/linux/LinuxBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildCli(): void
protected function buildCli(): void
{
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
shell()->cd(SOURCE_PATH . '/php-src')
Expand All @@ -254,7 +254,7 @@ public function buildCli(): void
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildMicro(): void
protected function buildMicro(): void
{
if ($this->getPHPVersionID() < 80000) {
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
Expand Down Expand Up @@ -288,7 +288,7 @@ public function buildMicro(): void
* @throws FileSystemException
* @throws RuntimeException
*/
public function buildFpm(): void
protected function buildFpm(): void
{
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
shell()->cd(SOURCE_PATH . '/php-src')
Expand All @@ -307,7 +307,7 @@ public function buildFpm(): void
*
* @throws RuntimeException
*/
public function buildEmbed(): void
protected function buildEmbed(): void
{
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());

Expand Down
8 changes: 4 additions & 4 deletions src/SPC/builder/macos/MacOSBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildCli(): void
protected function buildCli(): void
{
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());

Expand All @@ -248,7 +248,7 @@ public function buildCli(): void
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildMicro(): void
protected function buildMicro(): void
{
if ($this->getPHPVersionID() < 80000) {
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
Expand Down Expand Up @@ -284,7 +284,7 @@ public function buildMicro(): void
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildFpm(): void
protected function buildFpm(): void
{
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());

Expand All @@ -301,7 +301,7 @@ public function buildFpm(): void
*
* @throws RuntimeException
*/
public function buildEmbed(): void
protected function buildEmbed(): void
{
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());

Expand Down
80 changes: 40 additions & 40 deletions src/SPC/builder/traits/UnixBuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,49 @@ public function getAllStaticLibFiles(): array
return array_map(fn ($x) => realpath(BUILD_LIB_PATH . "/{$x}"), $libFiles);
}

/**
* Return generic cmake options when configuring cmake projects
*/
public function makeCmakeArgs(): string
{
$extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . getenv('CC') . ' ' : '';
return $extra .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DCMAKE_INSTALL_PREFIX=/ ' .
'-DCMAKE_INSTALL_BINDIR=/bin ' .
'-DCMAKE_INSTALL_LIBDIR=/lib ' .
'-DCMAKE_INSTALL_INCLUDEDIR=/include ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->cmake_toolchain_file}";
}

/**
* Generate configure flags
*/
public function makeAutoconfFlags(int $flag = AUTOCONF_ALL): string
{
$extra = '';
// TODO: add auto pkg-config support
if (($flag & AUTOCONF_LIBS) === AUTOCONF_LIBS) {
$extra .= 'LIBS="' . BUILD_LIB_PATH . '" ';
}
if (($flag & AUTOCONF_CFLAGS) === AUTOCONF_CFLAGS) {
$extra .= 'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" ';
}
if (($flag & AUTOCONF_CPPFLAGS) === AUTOCONF_CPPFLAGS) {
$extra .= 'CPPFLAGS="-I' . BUILD_INCLUDE_PATH . '" ';
}
if (($flag & AUTOCONF_LDFLAGS) === AUTOCONF_LDFLAGS) {
$extra .= 'LDFLAGS="-L' . BUILD_LIB_PATH . '" ';
}
return $extra;
}

/**
* Sanity check after build complete
*
* @throws RuntimeException
*/
public function sanityCheck(int $build_target): void
protected function sanityCheck(int $build_target): void
{
// sanity check for php-cli
if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
Expand Down Expand Up @@ -95,7 +132,7 @@ public function sanityCheck(int $build_target): void
* @throws RuntimeException
* @throws FileSystemException
*/
public function deployBinary(int $type): bool
protected function deployBinary(int $type): bool
{
$src = match ($type) {
BUILD_TARGET_CLI => SOURCE_PATH . '/php-src/sapi/cli/php',
Expand All @@ -114,46 +151,9 @@ public function deployBinary(int $type): bool
*
* @throws RuntimeException
*/
public function cleanMake(): void
protected function cleanMake(): void
{
logger()->info('cleaning up');
shell()->cd(SOURCE_PATH . '/php-src')->exec('make clean');
}

/**
* Return generic cmake options when configuring cmake projects
*/
public function makeCmakeArgs(): string
{
$extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . getenv('CC') . ' ' : '';
return $extra .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DCMAKE_INSTALL_PREFIX=/ ' .
'-DCMAKE_INSTALL_BINDIR=/bin ' .
'-DCMAKE_INSTALL_LIBDIR=/lib ' .
'-DCMAKE_INSTALL_INCLUDEDIR=/include ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->cmake_toolchain_file}";
}

/**
* Generate configure flags
*/
public function makeAutoconfFlags(int $flag = AUTOCONF_ALL): string
{
$extra = '';
// TODO: add auto pkg-config support
if (($flag & AUTOCONF_LIBS) === AUTOCONF_LIBS) {
$extra .= 'LIBS="' . BUILD_LIB_PATH . '" ';
}
if (($flag & AUTOCONF_CFLAGS) === AUTOCONF_CFLAGS) {
$extra .= 'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" ';
}
if (($flag & AUTOCONF_CPPFLAGS) === AUTOCONF_CPPFLAGS) {
$extra .= 'CPPFLAGS="-I' . BUILD_INCLUDE_PATH . '" ';
}
if (($flag & AUTOCONF_LDFLAGS) === AUTOCONF_LDFLAGS) {
$extra .= 'LDFLAGS="-L' . BUILD_LIB_PATH . '" ';
}
return $extra;
}
}