Compare commits

...

41 Commits

Author SHA1 Message Date
Marc
3804e842bb Merge pull request #858 from crazywhalecc/fix/imagick
imagick needs static libstdc++ on gcc-toolset (successor of devtoolse) too
2025-08-20 07:56:08 +02:00
DubbleClick
e6832ecf61 add msgpack suggestion 2025-08-19 20:15:41 +07:00
DubbleClick
ed3e29bade devtoolset any version 2025-08-19 20:03:16 +07:00
DubbleClick
811aeb58ea imagick needs static libstdc++ on gcc-toolset (successor of devtoolset) too 2025-08-19 20:01:10 +07:00
Marc
6b5aaa38ae Merge pull request #857 from crazywhalecc/fix/lstdcpp
move -lstdc++ to the end of the libraries
2025-08-19 10:51:28 +02:00
DubbleClick
4e9545262d finish the redis thingy from the year long open PR 2025-08-19 10:42:30 +07:00
DubbleClick
d48c84d81b move -lstdc++ to the end of the libraries 2025-08-19 10:27:52 +07:00
Jerry Ma
cbddb2652d Merge pull request #856 from crazywhalecc/fix/windows-cmd
Fix WindowsCmd execution, use popen instead of proc_open
2025-08-18 12:07:09 +08:00
Jerry Ma
5f629253ac Merge pull request #853 from crazywhalecc/fix/exception-reflection
Enhance exception handling by binding builder and extra info to exception handler
2025-08-16 19:33:13 +08:00
crazywhalecc
8d84a95c01 Fix WindowsCmd execution, use popen instead of proc_open 2025-08-16 17:54:24 +08:00
crazywhalecc
2cabaf6402 8.5 extension test 2025-08-15 13:19:14 +08:00
crazywhalecc
ad25ac49b8 Update to beta1, extension test 2025-08-15 12:28:26 +08:00
crazywhalecc
d0412a88df Use PatchException instead of ExecutionException for patchFile 2025-08-15 12:04:06 +08:00
crazywhalecc
a3ae1eb2f0 Remove redundant builer options 2025-08-15 11:54:34 +08:00
crazywhalecc
2e616af836 PHPStan fix 2025-08-11 13:32:59 +08:00
Jerry Ma
4fd8afcee4 Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:30:10 +08:00
Jerry Ma
e96b4f5541 Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:30:04 +08:00
Jerry Ma
9978a56b1e Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:59 +08:00
Jerry Ma
d3a5be13ea Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:54 +08:00
Jerry Ma
5ba0de12eb Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:48 +08:00
Jerry Ma
a73c097c94 Update src/SPC/command/BuildPHPCommand.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:42 +08:00
Jerry Ma
d3840b19fa Update src/SPC/builder/BuilderProvider.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:36 +08:00
crazywhalecc
b34b6594de Suggestions 2025-08-11 12:05:41 +08:00
crazywhalecc
2fba61e9bd Enhance exception handling by binding builder and extra info to ExceptionHandler 2025-08-11 10:48:48 +08:00
crazywhalecc
1e9434221b Remove spc.env.log due to potential secret leaks 2025-08-07 16:25:01 +08:00
crazywhalecc
afd6791075 Fix phpunit 2025-08-07 13:09:18 +08:00
crazywhalecc
b3b53b6b4d Use latest version of logger 2025-08-07 13:09:18 +08:00
crazywhalecc
b8b8cf6ea9 Update version to 2.7.2 2025-08-07 13:09:18 +08:00
crazywhalecc
9a340e1ad8 Update docs, GitHub issue templates, workflows 2025-08-07 13:09:18 +08:00
crazywhalecc
29dc5e4ea7 Chore 2025-08-07 13:09:18 +08:00
crazywhalecc
08fa49b791 Remove craft.log 2025-08-07 13:09:18 +08:00
crazywhalecc
333b776e77 Refactor all command class exception handling 2025-08-07 13:09:18 +08:00
crazywhalecc
f68f060be2 Refactor all (except command) modules using new exceptions 2025-08-07 13:09:18 +08:00
crazywhalecc
722bb31815 Introduce AttributeMapper for managing extensions and doctor attributes 2025-08-07 13:09:18 +08:00
crazywhalecc
e28580de00 Refactor shell utilities: reorganize namespaces and introduce Shell base class 2025-08-07 13:09:18 +08:00
crazywhalecc
cc447a089a Refactor all exception classes, remove unclear RuntimeException, InvalidArgumentException 2025-08-07 13:09:18 +08:00
crazywhalecc
0c9a30256e Remove all @throws PHPDoc, it's almost useless for SPC anymore 2025-08-07 13:09:18 +08:00
Jerry Ma
fa10142f13 Merge pull request #847 from crazywhalecc/fix/spc-exe
Fix spc build actions version, add spc validation
2025-08-06 01:03:38 +08:00
Jerry Ma
c342741670 Update version to 2.7.1 2025-08-05 23:13:19 +08:00
Jerry Ma
64d49003e0 Update release-build.yml 2025-08-05 21:26:35 +08:00
crazywhalecc
b0c93c7418 Fix spc build actions version, add spc validation 2025-08-05 18:59:30 +08:00
198 changed files with 2578 additions and 2763 deletions

View File

@@ -10,6 +10,7 @@ trim_trailing_whitespace = true
[*.md] [*.md]
trim_trailing_whitespace = false trim_trailing_whitespace = false
indent_size = 2
[*.{yml,yaml, vue}] [*.{yml,yaml, vue}]
indent_size = 2 indent_size = 2

View File

@@ -3,6 +3,15 @@ name: Bug report
about: Build PHP or library failed, download failed, doesn't seem to work... about: Build PHP or library failed, download failed, doesn't seem to work...
title: '' title: ''
labels: bug labels: bug
assignees: crazywhalecc body:
- type: textarea
id: what-happened
attributes:
label: What happened?
description: |
Please tell us what you do, what you get and what you expected.
Provide with some step-by-step instructions to reproduce the issue.
If possible, attach a screenshot or log files in ./log directory.
validations:
required: true
--- ---

View File

@@ -3,6 +3,6 @@ name: Feature request
about: Suggest an idea for this project about: Suggest an idea for this project
title: '' title: ''
labels: new feature labels: new feature
assignees: '' assignees: crazywhalecc
--- ---

View File

@@ -82,7 +82,7 @@ jobs:
- zlib - zlib
- zstd - zstd
php-version: php-version:
- "git" - "8.5"
operating-system: operating-system:
- "ubuntu-latest" - "ubuntu-latest"
#- "macos-13" #- "macos-13"

View File

@@ -3,6 +3,10 @@ name: Build SPC Binary
on: on:
push: push:
branches: [ "main" ] branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths:
- '.github/workflows/release-build.yml'
release: release:
types: types:
- published - published
@@ -10,7 +14,7 @@ on:
env: env:
PHP_VERSION: 8.4 PHP_VERSION: 8.4
MICRO_VERSION: 8.4.10 MICRO_VERSION: 8.4.11
jobs: jobs:
build-release-artifacts: build-release-artifacts:
@@ -117,7 +121,8 @@ jobs:
files: dist/${{ matrix.operating-system.filename }} files: dist/${{ matrix.operating-system.filename }}
- name: "Deploy to self-hosted OSS" - name: "Deploy to self-hosted OSS"
if: github.repository == 'crazywhalecc/static-php-cli' # only run this step if the repository is static-php-cli and the branch is main
if: github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/main'
uses: static-php/upload-s3-action@v1.0.0 uses: static-php/upload-s3-action@v1.0.0
with: with:
aws_key_id: ${{ secrets.AWS_KEY_ID }} aws_key_id: ${{ secrets.AWS_KEY_ID }}
@@ -132,3 +137,39 @@ jobs:
with: with:
path: spc${{ env.SUFFIX }} path: spc${{ env.SUFFIX }}
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }} name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
test-spc:
name: "Test SPC Binary for ${{ matrix.operating-system.name }}"
runs-on: ${{ matrix.operating-system.os }}
needs: [build-release-artifacts]
strategy:
matrix:
operating-system:
- name: "linux-x86_64"
os: "ubuntu-latest"
- name: "macos-x86_64"
os: "macos-13"
- name: "linux-aarch64"
os: "ubuntu-24.04-arm"
- name: "macos-aarch64"
os: "macos-latest"
- name: "windows-x64"
os: "windows-latest"
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Download Artifact"
uses: actions/download-artifact@v4
env:
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
with:
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
- name: "Chmod"
if: matrix.operating-system.name != 'windows-x64'
run: chmod +x spc
- name: "Run SPC Tests"
env:
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
run: ./spc${{ env.SUFFIX }} dev:extensions

View File

@@ -206,6 +206,13 @@ jobs:
if: ${{ !startsWith(matrix.os, 'windows-') }} if: ${{ !startsWith(matrix.os, 'windows-') }}
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }} run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}
- name: "Upload logs"
if: ${{ always() && hashFiles('log/**') != '' }}
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ matrix.os }}-${{ matrix.php }}
path: log
# - name: Setup tmate session # - name: Setup tmate session
# if: ${{ failure() }} # if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3 # uses: mxschmitt/action-tmate@v3

10
.gitignore vendored
View File

@@ -48,6 +48,12 @@ packlib_files.txt
package-lock.json package-lock.json
pnpm-lock.yaml pnpm-lock.yaml
# craft.log # craft
craft.log
craft.yml craft.yml
# SPC logs
log/
# spc.phar
spc.phar
spc.exe

View File

@@ -16,7 +16,7 @@
"symfony/console": "^5.4 || ^6 || ^7", "symfony/console": "^5.4 || ^6 || ^7",
"symfony/process": "^7.2", "symfony/process": "^7.2",
"symfony/yaml": "^7.2", "symfony/yaml": "^7.2",
"zhamao/logger": "^1.0" "zhamao/logger": "^1.1.3"
}, },
"require-dev": { "require-dev": {
"captainhook/captainhook-phar": "^5.23", "captainhook/captainhook-phar": "^5.23",

26
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "dbefe1ee5c584f6f0cc64c26fb83451c", "content-hash": "f81132977eb1310f5ccb27c8de76c8d2",
"packages": [ "packages": [
{ {
"name": "illuminate/collections", "name": "illuminate/collections",
@@ -1211,16 +1211,16 @@
}, },
{ {
"name": "zhamao/logger", "name": "zhamao/logger",
"version": "1.1.2", "version": "1.1.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zhamao-robot/zhamao-logger.git", "url": "https://github.com/zhamao-robot/zhamao-logger.git",
"reference": "1d7427abd8b1b3387ed7d9244953049356db3e62" "reference": "2551b3e1dbbb1db81794d5c3a666c66804a9dca9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zhamao-robot/zhamao-logger/zipball/1d7427abd8b1b3387ed7d9244953049356db3e62", "url": "https://api.github.com/repos/zhamao-robot/zhamao-logger/zipball/2551b3e1dbbb1db81794d5c3a666c66804a9dca9",
"reference": "1d7427abd8b1b3387ed7d9244953049356db3e62", "reference": "2551b3e1dbbb1db81794d5c3a666c66804a9dca9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1274,9 +1274,9 @@
"description": "Another Console Logger for CLI Applications", "description": "Another Console Logger for CLI Applications",
"support": { "support": {
"issues": "https://github.com/zhamao-robot/zhamao-logger/issues", "issues": "https://github.com/zhamao-robot/zhamao-logger/issues",
"source": "https://github.com/zhamao-robot/zhamao-logger/tree/1.1.2" "source": "https://github.com/zhamao-robot/zhamao-logger/tree/1.1.3"
}, },
"time": "2025-04-24T02:02:28+00:00" "time": "2025-08-02T13:44:27+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
@@ -3489,16 +3489,16 @@
}, },
{ {
"name": "myclabs/deep-copy", "name": "myclabs/deep-copy",
"version": "1.13.3", "version": "1.13.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/myclabs/DeepCopy.git", "url": "https://github.com/myclabs/DeepCopy.git",
"reference": "faed855a7b5f4d4637717c2b3863e277116beb36" "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/faed855a7b5f4d4637717c2b3863e277116beb36", "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a",
"reference": "faed855a7b5f4d4637717c2b3863e277116beb36", "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3537,7 +3537,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/myclabs/DeepCopy/issues", "issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.13.3" "source": "https://github.com/myclabs/DeepCopy/tree/1.13.4"
}, },
"funding": [ "funding": [
{ {
@@ -3545,7 +3545,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2025-07-05T12:25:42+00:00" "time": "2025-08-01T08:46:24+00:00"
}, },
{ {
"name": "nikic/iter", "name": "nikic/iter",

View File

@@ -694,7 +694,8 @@
"arg-type": "custom", "arg-type": "custom",
"ext-suggests": [ "ext-suggests": [
"session", "session",
"igbinary" "igbinary",
"msgpack"
], ],
"lib-suggests-unix": [ "lib-suggests-unix": [
"zstd", "zstd",

View File

@@ -172,7 +172,7 @@ If the build is successful, you will see the `buildroot/bin` directory in the cu
If the build fails, you can use the `--debug` parameter to view detailed error information, If the build fails, you can use the `--debug` parameter to view detailed error information,
or use the `--with-clean` to clear the old compilation results and recompile. or use the `--with-clean` to clear the old compilation results and recompile.
If the build still fails to use the above method, please submit an issue and attach your `craft.yml` and `craft.log`. If the build still fails to use the above method, please submit an issue and attach your `craft.yml` and `./log` archive.
## Step-by-step build command ## Step-by-step build command

View File

@@ -149,7 +149,7 @@ bin/spc craft --debug
如果中途构建出错,你可以使用 `--debug` 参数查看详细的错误信息,或者使用 `--with-clean` 参数清除旧的编译结果,重新编译。 如果中途构建出错,你可以使用 `--debug` 参数查看详细的错误信息,或者使用 `--with-clean` 参数清除旧的编译结果,重新编译。
如使用以上方式仍构建失败,请提交一个 issue附上你的 `craft.yml``craft.log` 如使用以上方式仍构建失败,请提交一个 issue附上你的 `craft.yml` 文件`log/` 目录的压缩包
## 分步构建命令 ## 分步构建命令

View File

@@ -8,6 +8,7 @@ parameters:
- '#class Fiber#' - '#class Fiber#'
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#' - '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
- '#Function Swoole\\Coroutine\\run not found.#' - '#Function Swoole\\Coroutine\\run not found.#'
- '#Static call to instance method ZM\\Logger\\ConsoleColor#'
dynamicConstantNames: dynamicConstantNames:
- PHP_OS_FAMILY - PHP_OS_FAMILY
excludePaths: excludePaths:

View File

@@ -34,7 +34,7 @@ use Symfony\Component\Console\Application;
*/ */
final class ConsoleApplication extends Application final class ConsoleApplication extends Application
{ {
public const VERSION = '2.7.0'; public const string VERSION = '2.7.2';
public function __construct() public function __construct()
{ {

View File

@@ -4,18 +4,15 @@ declare(strict_types=1);
namespace SPC\builder; namespace SPC\builder;
use PharIo\FileSystem\File; use SPC\exception\BuildFailureException;
use SPC\exception\ExceptionHandler;
use SPC\exception\FileSystemException;
use SPC\exception\InterruptException; use SPC\exception\InterruptException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\Config; use SPC\store\Config;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\store\LockFile; use SPC\store\LockFile;
use SPC\store\SourceManager; use SPC\store\SourceManager;
use SPC\store\SourcePatcher; use SPC\store\SourcePatcher;
use SPC\util\CustomExt; use SPC\util\AttributeMapper;
abstract class BuilderBase abstract class BuilderBase
{ {
@@ -46,20 +43,14 @@ abstract class BuilderBase
/** /**
* Convert libraries to class * Convert libraries to class
* *
* @param array<string> $sorted_libraries Libraries to build (if not empty, must sort first) * @param array<string> $sorted_libraries Libraries to build (if not empty, must sort first)
* @throws FileSystemException *
* @throws RuntimeException
* @throws WrongUsageException
* @internal * @internal
*/ */
abstract public function proveLibs(array $sorted_libraries); abstract public function proveLibs(array $sorted_libraries);
/** /**
* Set-Up libraries * Set-Up libraries
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/ */
public function setupLibs(): void public function setupLibs(): void
{ {
@@ -70,12 +61,11 @@ abstract class BuilderBase
match ($status) { match ($status) {
LIB_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] setup success, took ' . round(microtime(true) - $starttime, 2) . ' s'), LIB_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] setup success, took ' . round(microtime(true) - $starttime, 2) . ' s'),
LIB_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'), LIB_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
LIB_STATUS_BUILD_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
LIB_STATUS_INSTALL_FAILED => logger()->error('lib [' . $lib::NAME . '] install failed'), LIB_STATUS_INSTALL_FAILED => logger()->error('lib [' . $lib::NAME . '] install failed'),
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'), default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
}; };
if (in_array($status, [LIB_STATUS_BUILD_FAILED, LIB_STATUS_INSTALL_FAILED])) { if (in_array($status, [LIB_STATUS_BUILD_FAILED, LIB_STATUS_INSTALL_FAILED])) {
throw new RuntimeException('Library [' . $lib::NAME . '] setup failed.'); throw new BuildFailureException('Library [' . $lib::NAME . '] setup failed.');
} }
} }
} }
@@ -139,9 +129,6 @@ abstract class BuilderBase
/** /**
* Check if there is a cpp extensions or libraries. * Check if there is a cpp extensions or libraries.
*
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function hasCpp(): bool public function hasCpp(): bool
{ {
@@ -174,15 +161,10 @@ abstract class BuilderBase
/** /**
* Verify the list of "ext" extensions for validity and declare an Extension object to check the dependencies of the extensions. * Verify the list of "ext" extensions for validity and declare an Extension object to check the dependencies of the extensions.
* *
* @throws FileSystemException
* @throws RuntimeException
* @throws \ReflectionException
* @throws \Throwable|WrongUsageException
* @internal * @internal
*/ */
public function proveExts(array $static_extensions, array $shared_extensions = [], bool $skip_check_deps = false, bool $skip_extract = false): void public function proveExts(array $static_extensions, array $shared_extensions = [], bool $skip_check_deps = false, bool $skip_extract = false): void
{ {
CustomExt::loadCustomExt();
// judge ext // judge ext
foreach ($static_extensions as $ext) { foreach ($static_extensions as $ext) {
// if extension does not support static build, throw exception // if extension does not support static build, throw exception
@@ -213,7 +195,7 @@ abstract class BuilderBase
} }
foreach ([...$static_extensions, ...$shared_extensions] as $extension) { foreach ([...$static_extensions, ...$shared_extensions] as $extension) {
$class = CustomExt::getExtClass($extension); $class = AttributeMapper::getExtensionClassByName($extension) ?? Extension::class;
/** @var Extension $ext */ /** @var Extension $ext */
$ext = new $class($extension, $this); $ext = new $class($extension, $this);
if (in_array($extension, $static_extensions)) { if (in_array($extension, $static_extensions)) {
@@ -248,9 +230,7 @@ abstract class BuilderBase
abstract public function testPHP(int $build_target = BUILD_TARGET_NONE); abstract public function testPHP(int $build_target = BUILD_TARGET_NONE);
/** /**
* @throws WrongUsageException * Build shared extensions.
* @throws RuntimeException
* @throws FileSystemException
*/ */
public function buildSharedExts(): void public function buildSharedExts(): void
{ {
@@ -273,9 +253,8 @@ abstract class BuilderBase
} }
$ext->buildShared(); $ext->buildShared();
} }
} catch (RuntimeException $e) { } finally {
FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line); FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line);
throw $e;
} }
FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line); FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line);
FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', '# test "[$]$1" = "no" && $1=yes', 'test "[$]$1" = "no" && $1=yes'); FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', '# test "[$]$1" = "no" && $1=yes', 'test "[$]$1" = "no" && $1=yes');
@@ -284,9 +263,6 @@ abstract class BuilderBase
/** /**
* Generate extension enable arguments for configure. * Generate extension enable arguments for configure.
* e.g. --enable-mbstring * e.g. --enable-mbstring
*
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function makeStaticExtensionArgs(): string public function makeStaticExtensionArgs(): string
{ {
@@ -321,9 +297,6 @@ abstract class BuilderBase
/** /**
* Get PHP Version ID from php-src/main/php_version.h * Get PHP Version ID from php-src/main/php_version.h
*
* @throws RuntimeException
* @throws WrongUsageException
*/ */
public function getPHPVersionID(): int public function getPHPVersionID(): int
{ {
@@ -336,7 +309,7 @@ abstract class BuilderBase
return intval($match[1]); return intval($match[1]);
} }
throw new RuntimeException('PHP version file format is malformed, please remove it and download again'); throw new WrongUsageException('PHP version file format is malformed, please remove "./source/php-src" dir and download/extract again');
} }
public function getPHPVersion(bool $exception_on_failure = true): string public function getPHPVersion(bool $exception_on_failure = true): string
@@ -354,7 +327,7 @@ abstract class BuilderBase
if (!$exception_on_failure) { if (!$exception_on_failure) {
return 'unknown'; return 'unknown';
} }
throw new RuntimeException('PHP version file format is malformed, please remove it and download again'); throw new WrongUsageException('PHP version file format is malformed, please remove it and download again');
} }
/** /**
@@ -501,7 +474,7 @@ abstract class BuilderBase
foreach ($patches as $patch) { foreach ($patches as $patch) {
try { try {
if (!file_exists($patch)) { if (!file_exists($patch)) {
throw new RuntimeException("Additional patch script file {$patch} not found!"); throw new WrongUsageException("Additional patch script file {$patch} not found!");
} }
logger()->debug('Running additional patch script: ' . $patch); logger()->debug('Running additional patch script: ' . $patch);
require $patch; require $patch;
@@ -514,11 +487,6 @@ abstract class BuilderBase
exit($e->getCode()); exit($e->getCode());
} catch (\Throwable $e) { } catch (\Throwable $e) {
logger()->critical('Patch script ' . $patch . ' failed to run.'); logger()->critical('Patch script ' . $patch . ' failed to run.');
if ($this->getOption('debug')) {
ExceptionHandler::getInstance()->handle($e);
} else {
logger()->critical('Please check with --debug option to see more details.');
}
throw $e; throw $e;
} }
} }

View File

@@ -8,8 +8,7 @@ use SPC\builder\freebsd\BSDBuilder;
use SPC\builder\linux\LinuxBuilder; use SPC\builder\linux\LinuxBuilder;
use SPC\builder\macos\MacOSBuilder; use SPC\builder\macos\MacOSBuilder;
use SPC\builder\windows\WindowsBuilder; use SPC\builder\windows\WindowsBuilder;
use SPC\exception\FileSystemException; use SPC\exception\ExceptionHandler;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@@ -20,11 +19,6 @@ class BuilderProvider
{ {
private static ?BuilderBase $builder = null; private static ?BuilderBase $builder = null;
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public static function makeBuilderByInput(InputInterface $input): BuilderBase public static function makeBuilderByInput(InputInterface $input): BuilderBase
{ {
ini_set('memory_limit', '4G'); ini_set('memory_limit', '4G');
@@ -36,12 +30,13 @@ class BuilderProvider
'BSD' => new BSDBuilder($input->getOptions()), 'BSD' => new BSDBuilder($input->getOptions()),
default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'), default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
}; };
// bind the builder to ExceptionHandler
ExceptionHandler::bindBuilder(self::$builder);
return self::$builder; return self::$builder;
} }
/**
* @throws WrongUsageException
*/
public static function getBuilder(): BuilderBase public static function getBuilder(): BuilderBase
{ {
if (self::$builder === null) { if (self::$builder === null) {

View File

@@ -4,8 +4,9 @@ declare(strict_types=1);
namespace SPC\builder; namespace SPC\builder;
use SPC\exception\FileSystemException; use SPC\exception\EnvironmentException;
use SPC\exception\RuntimeException; use SPC\exception\SPCException;
use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\Config; use SPC\store\Config;
use SPC\store\FileSystem; use SPC\store\FileSystem;
@@ -24,21 +25,16 @@ class Extension
protected string $source_dir; protected string $source_dir;
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function __construct(protected string $name, protected BuilderBase $builder) public function __construct(protected string $name, protected BuilderBase $builder)
{ {
$ext_type = Config::getExt($this->name, 'type'); $ext_type = Config::getExt($this->name, 'type');
$unix_only = Config::getExt($this->name, 'unix-only', false); $unix_only = Config::getExt($this->name, 'unix-only', false);
$windows_only = Config::getExt($this->name, 'windows-only', false); $windows_only = Config::getExt($this->name, 'windows-only', false);
if (PHP_OS_FAMILY !== 'Windows' && $windows_only) { if (PHP_OS_FAMILY !== 'Windows' && $windows_only) {
throw new RuntimeException("{$ext_type} extension {$name} is not supported on Linux and macOS platform"); throw new EnvironmentException("{$ext_type} extension {$name} is not supported on Linux and macOS platform");
} }
if (PHP_OS_FAMILY === 'Windows' && $unix_only) { if (PHP_OS_FAMILY === 'Windows' && $unix_only) {
throw new RuntimeException("{$ext_type} extension {$name} is not supported on Windows platform"); throw new EnvironmentException("{$ext_type} extension {$name} is not supported on Windows platform");
} }
// set source_dir for builtin // set source_dir for builtin
if ($ext_type === 'builtin') { if ($ext_type === 'builtin') {
@@ -46,7 +42,7 @@ class Extension
} elseif ($ext_type === 'external') { } elseif ($ext_type === 'external') {
$source = Config::getExt($this->name, 'source'); $source = Config::getExt($this->name, 'source');
if ($source === null) { if ($source === null) {
throw new RuntimeException("{$ext_type} extension {$name} source not found"); throw new ValidationException("{$ext_type} extension {$name} source not found", validation_module: "Extension [{$name}] loader");
} }
$source_path = Config::getSource($source)['path'] ?? null; $source_path = Config::getSource($source)['path'] ?? null;
$source_path = $source_path === null ? SOURCE_PATH . '/' . $source : SOURCE_PATH . '/' . $source_path; $source_path = $source_path === null ? SOURCE_PATH . '/' . $source : SOURCE_PATH . '/' . $source_path;
@@ -63,9 +59,6 @@ class Extension
/** /**
* 获取开启该扩展的 PHP 编译添加的参数 * 获取开启该扩展的 PHP 编译添加的参数
*
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function getConfigureArg(bool $shared = false): string public function getConfigureArg(bool $shared = false): string
{ {
@@ -80,9 +73,6 @@ class Extension
/** /**
* 根据 ext 的 arg-type 获取对应开启的参数,一般都是 --enable-xxx 和 --with-xxx * 根据 ext 的 arg-type 获取对应开启的参数,一般都是 --enable-xxx 和 --with-xxx
*
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function getEnableArg(bool $shared = false): string public function getEnableArg(bool $shared = false): string
{ {
@@ -112,10 +102,6 @@ class Extension
/** /**
* 检查下依赖就行了,作用是导入依赖给 Extension 对象,今后可以对库依赖进行选择性处理 * 检查下依赖就行了,作用是导入依赖给 Extension 对象,今后可以对库依赖进行选择性处理
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function checkDependency(): static public function checkDependency(): static
{ {
@@ -259,8 +245,6 @@ class Extension
* i.e.; pdo_pgsql would return: * i.e.; pdo_pgsql would return:
* *
* `-d "extension=pgsql" -d "extension=pdo_pgsql"` * `-d "extension=pgsql" -d "extension=pdo_pgsql"`
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function getSharedExtensionLoadString(): string public function getSharedExtensionLoadString(): string
{ {
@@ -300,20 +284,16 @@ class Extension
return $ret; return $ret;
} }
/**
* @throws RuntimeException
*/
public function runCliCheckUnix(): void public function runCliCheckUnix(): void
{ {
// Run compile check if build target is cli // Run compile check if build target is cli
// If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php // If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php
// If check failed, throw RuntimeException
$sharedExtensions = $this->getSharedExtensionLoadString(); $sharedExtensions = $this->getSharedExtensionLoadString();
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException( throw new ValidationException(
'extension ' . $this->getName() . ' failed runtime check: php-cli returned ' . $ret . "\n" . "extension {$this->getName()} failed compile check: php-cli returned {$ret}",
join("\n", $out) validation_module: 'Extension ' . $this->getName() . ' sanity check'
); );
} }
@@ -327,23 +307,21 @@ class Extension
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' -r "' . trim($test) . '"'); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' -r "' . trim($test) . '"');
if ($ret !== 0) { if ($ret !== 0) {
var_dump($out); throw new ValidationException(
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); "extension {$this->getName()} failed sanity check. Code: {$ret}, output: " . implode("\n", $out),
validation_module: 'Extension ' . $this->getName() . ' function check'
);
} }
} }
} }
/**
* @throws RuntimeException
*/
public function runCliCheckWindows(): void public function runCliCheckWindows(): void
{ {
// Run compile check if build target is cli // Run compile check if build target is cli
// If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php // If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php
// If check failed, throw RuntimeException
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n --ri "' . $this->getDistName() . '"', false); [$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n --ri "' . $this->getDistName() . '"', false);
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
} }
if (file_exists(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php'))) { if (file_exists(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php'))) {
@@ -356,7 +334,10 @@ class Extension
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n -r "' . trim($test) . '"'); [$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n -r "' . trim($test) . '"');
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); throw new ValidationException(
"extension {$this->getName()} failed function check",
validation_module: "Extension {$this->getName()} function check"
);
} }
} }
} }
@@ -368,50 +349,46 @@ class Extension
/** /**
* Build shared extension * Build shared extension
*
* @throws WrongUsageException
* @throws RuntimeException
*/ */
public function buildShared(): void public function buildShared(): void
{ {
if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) { try {
if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) {
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('Shared extension [' . $this->getName() . '] was already built by php-src/configure (' . $this->getName() . '.so)');
return;
}
if (Config::getExt($this->getName(), 'build-with-php') === true) {
logger()->warning('Shared extension [' . $this->getName() . '] did not build with php-src/configure (' . $this->getName() . '.so)');
logger()->warning('Try deleting your build and source folders and running `spc build`` again.');
return;
}
}
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) { if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('Shared extension [' . $this->getName() . '] was already built by php-src/configure (' . $this->getName() . '.so)'); logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)');
return;
} }
if (Config::getExt($this->getName(), 'build-with-php') === true) { logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
logger()->warning('Shared extension [' . $this->getName() . '] did not build with php-src/configure (' . $this->getName() . '.so)'); foreach ($this->dependencies as $dependency) {
logger()->warning('Try deleting your build and source folders and running `spc build`` again.'); if (!$dependency instanceof Extension) {
return; continue;
}
if (!$dependency->isBuildStatic()) {
logger()->info('extension ' . $this->getName() . ' requires extension ' . $dependency->getName());
$dependency->buildShared();
}
} }
match (PHP_OS_FAMILY) {
'Darwin', 'Linux' => $this->buildUnixShared(),
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
};
} catch (SPCException $e) {
$e->bindExtensionInfo(['extension_name' => $this->getName()]);
throw $e;
} }
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)');
}
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
foreach ($this->dependencies as $dependency) {
if (!$dependency instanceof Extension) {
continue;
}
if (!$dependency->isBuildStatic()) {
logger()->info('extension ' . $this->getName() . ' requires extension ' . $dependency->getName());
$dependency->buildShared();
}
}
match (PHP_OS_FAMILY) {
'Darwin', 'Linux' => $this->buildUnixShared(),
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
};
} }
/** /**
* Build shared extension for Unix * Build shared extension for Unix
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @throws \ReflectionException
* @throws \Throwable
*/ */
public function buildUnixShared(): void public function buildUnixShared(): void
{ {
@@ -506,15 +483,12 @@ class Extension
return $this->build_static; return $this->build_static;
} }
/**
* @throws RuntimeException
*/
protected function addLibraryDependency(string $name, bool $optional = false): void protected function addLibraryDependency(string $name, bool $optional = false): void
{ {
$depLib = $this->builder->getLib($name); $depLib = $this->builder->getLib($name);
if (!$depLib) { if (!$depLib) {
if (!$optional) { if (!$optional) {
throw new RuntimeException("extension {$this->name} requires library {$name}"); throw new WrongUsageException("extension {$this->name} requires library {$name}");
} }
logger()->info("enabling {$this->name} without library {$name}"); logger()->info("enabling {$this->name} without library {$name}");
} else { } else {
@@ -522,15 +496,12 @@ class Extension
} }
} }
/**
* @throws RuntimeException
*/
protected function addExtensionDependency(string $name, bool $optional = false): void protected function addExtensionDependency(string $name, bool $optional = false): void
{ {
$depExt = $this->builder->getExt($name); $depExt = $this->builder->getExt($name);
if (!$depExt) { if (!$depExt) {
if (!$optional) { if (!$optional) {
throw new RuntimeException("{$this->name} requires extension {$name}"); throw new WrongUsageException("{$this->name} requires extension {$name} which is not included");
} }
logger()->info("enabling {$this->name} without extension {$name}"); logger()->info("enabling {$this->name} without extension {$name}");
} else { } else {

View File

@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace SPC\builder; namespace SPC\builder;
use SPC\exception\FileSystemException; use SPC\exception\SPCException;
use SPC\exception\RuntimeException; use SPC\exception\SPCInternalException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\Config; use SPC\store\Config;
use SPC\store\Downloader; use SPC\store\Downloader;
@@ -27,23 +27,17 @@ abstract class LibraryBase
protected bool $patched = false; protected bool $patched = false;
/**
* @throws RuntimeException
*/
public function __construct(?string $source_dir = null) public function __construct(?string $source_dir = null)
{ {
if (static::NAME === 'unknown') { if (static::NAME === 'unknown') {
throw new RuntimeException('no unknown!!!!!'); throw new SPCInternalException('Please set the NAME constant in ' . static::class);
} }
$this->source_dir = $source_dir ?? (SOURCE_PATH . '/' . Config::getLib(static::NAME, 'source')); $this->source_dir = $source_dir ?? (SOURCE_PATH . DIRECTORY_SEPARATOR . Config::getLib(static::NAME, 'source'));
} }
/** /**
* Try to install or build this library. * Try to install or build this library.
* @param bool $force If true, force install or build * @param bool $force If true, force install or build
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/ */
public function setup(bool $force = false): int public function setup(bool $force = false): int
{ {
@@ -107,10 +101,6 @@ abstract class LibraryBase
/** /**
* Calculate dependencies for current library. * Calculate dependencies for current library.
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function calcDependency(): void public function calcDependency(): void
{ {
@@ -131,9 +121,6 @@ abstract class LibraryBase
/** /**
* Get config static libs. * Get config static libs.
*
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function getStaticLibs(): array public function getStaticLibs(): array
{ {
@@ -142,9 +129,6 @@ abstract class LibraryBase
/** /**
* Get config headers. * Get config headers.
*
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function getHeaders(): array public function getHeaders(): array
{ {
@@ -153,19 +137,12 @@ abstract class LibraryBase
/** /**
* Get binary files. * Get binary files.
*
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function getBinaryFiles(): array public function getBinaryFiles(): array
{ {
return Config::getLib(static::NAME, 'bin', []); return Config::getLib(static::NAME, 'bin', []);
} }
/**
* @throws WrongUsageException
* @throws FileSystemException
*/
public function tryInstall(array $lock, bool $force_install = false): int public function tryInstall(array $lock, bool $force_install = false): int
{ {
$install_file = $lock['filename']; $install_file = $lock['filename'];
@@ -177,7 +154,7 @@ abstract class LibraryBase
FileSystem::extractPackage($install_file, $lock['source_type'], DOWNLOAD_PATH . '/' . $install_file, BUILD_ROOT_PATH); FileSystem::extractPackage($install_file, $lock['source_type'], DOWNLOAD_PATH . '/' . $install_file, BUILD_ROOT_PATH);
$this->install(); $this->install();
return LIB_STATUS_OK; return LIB_STATUS_OK;
} catch (FileSystemException|RuntimeException $e) { } catch (SPCException $e) {
logger()->error('Failed to extract pre-built library [' . static::NAME . ']: ' . $e->getMessage()); logger()->error('Failed to extract pre-built library [' . static::NAME . ']: ' . $e->getMessage());
return LIB_STATUS_INSTALL_FAILED; return LIB_STATUS_INSTALL_FAILED;
} }
@@ -194,10 +171,6 @@ abstract class LibraryBase
* BUILD_STATUS_OK if build success * BUILD_STATUS_OK if build success
* BUILD_STATUS_ALREADY if already built * BUILD_STATUS_ALREADY if already built
* BUILD_STATUS_FAILED if build failed * BUILD_STATUS_FAILED if build failed
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function tryBuild(bool $force_build = false): int public function tryBuild(bool $force_build = false): int
{ {
@@ -319,8 +292,6 @@ abstract class LibraryBase
/** /**
* Build this library. * Build this library.
*
* @throws RuntimeException
*/ */
abstract protected function build(); abstract protected function build();
@@ -333,7 +304,7 @@ abstract class LibraryBase
} }
$replace_items = json_decode(file_get_contents($replace_item_file), true); $replace_items = json_decode(file_get_contents($replace_item_file), true);
if (!is_array($replace_items)) { if (!is_array($replace_items)) {
throw new RuntimeException('Invalid placeholder file: ' . $replace_item_file); throw new SPCInternalException("Invalid placeholder file: {$replace_item_file}");
} }
$placeholders = get_pack_replace(); $placeholders = get_pack_replace();
// replace placeholders in BUILD_ROOT_PATH // replace placeholders in BUILD_ROOT_PATH
@@ -351,8 +322,6 @@ abstract class LibraryBase
/** /**
* Add lib dependency * Add lib dependency
*
* @throws RuntimeException
*/ */
protected function addLibraryDependency(string $name, bool $optional = false): void protected function addLibraryDependency(string $name, bool $optional = false): void
{ {
@@ -362,7 +331,7 @@ abstract class LibraryBase
return; return;
} }
if (!$optional) { if (!$optional) {
throw new RuntimeException(static::NAME . " requires library {$name}"); throw new WrongUsageException(static::NAME . " requires library {$name} but it is not included");
} }
logger()->debug('enabling ' . static::NAME . " without {$name}"); logger()->debug('enabling ' . static::NAME . " without {$name}");
} }

View File

@@ -6,18 +6,12 @@ namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder; use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('bz2')] #[CustomExt('bz2')]
class bz2 extends Extension class bz2 extends Extension
{ {
/**
* @throws FileSystemException
* @throws WrongUsageException
*/
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';

View File

@@ -8,17 +8,13 @@ use SPC\builder\Extension;
use SPC\builder\linux\LinuxBuilder; use SPC\builder\linux\LinuxBuilder;
use SPC\builder\macos\MacOSBuilder; use SPC\builder\macos\MacOSBuilder;
use SPC\builder\windows\WindowsBuilder; use SPC\builder\windows\WindowsBuilder;
use SPC\exception\FileSystemException; use SPC\exception\PatchException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('curl')] #[CustomExt('curl')]
class curl extends Extension class curl extends Extension
{ {
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool public function patchBeforeBuildconf(): bool
{ {
logger()->info('patching before-configure for curl checks'); logger()->info('patching before-configure for curl checks');
@@ -46,10 +42,6 @@ class curl extends Extension
return true; return true;
} }
/**
* @throws FileSystemException
* @throws WrongUsageException
*/
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';
@@ -105,7 +97,7 @@ class curl extends Extension
); );
if ($patched === null) { if ($patched === null) {
throw new \RuntimeException('Failed to patch config.m4 due to a regex error'); throw new PatchException('shared extension curl patcher', 'Failed to patch config.m4 due to a regex error');
} }
FileSystem::writeFile($file, $patched); FileSystem::writeFile($file, $patched);

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('dom')] #[CustomExt('dom')]
class dom extends Extension class dom extends Extension
{ {
/**
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string public function getUnixConfigureArg(bool $shared = false): string
{ {
$arg = '--enable-dom' . ($shared ? '=shared' : ''); $arg = '--enable-dom' . ($shared ? '=shared' : '');

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('ev')] #[CustomExt('ev')]
class ev extends Extension class ev extends Extension
{ {
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool public function patchBeforeBuildconf(): bool
{ {
/* /*

View File

@@ -6,7 +6,6 @@ namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder; use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
@@ -27,18 +26,12 @@ class event extends Extension
return $arg; return $arg;
} }
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString()); FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString());
return true; return true;
} }
/**
* @throws FileSystemException
*/
public function patchBeforeMake(): bool public function patchBeforeMake(): bool
{ {
$patched = parent::patchBeforeMake(); $patched = parent::patchBeforeMake();

View File

@@ -6,17 +6,12 @@ namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder; use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('gettext')] #[CustomExt('gettext')]
class gettext extends Extension class gettext extends Extension
{ {
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool public function patchBeforeBuildconf(): bool
{ {
if ($this->builder instanceof MacOSBuilder) { if ($this->builder instanceof MacOSBuilder) {
@@ -25,10 +20,6 @@ class gettext extends Extension
return true; return true;
} }
/**
* @throws WrongUsageException
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
if ($this->builder instanceof MacOSBuilder) { if ($this->builder instanceof MacOSBuilder) {

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('glfw')] #[CustomExt('glfw')]
class glfw extends Extension class glfw extends Extension
{ {
/**
* @throws RuntimeException
*/
public function patchBeforeBuildconf(): bool public function patchBeforeBuildconf(): bool
{ {
if (file_exists(SOURCE_PATH . '/php-src/ext/glfw')) { if (file_exists(SOURCE_PATH . '/php-src/ext/glfw')) {

View File

@@ -6,6 +6,7 @@ namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\builder\windows\WindowsBuilder; use SPC\builder\windows\WindowsBuilder;
use SPC\exception\ValidationException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
use SPC\util\GlobalEnvManager; use SPC\util\GlobalEnvManager;
@@ -18,7 +19,7 @@ class grpc extends Extension
public function patchBeforeBuildconf(): bool public function patchBeforeBuildconf(): bool
{ {
if ($this->builder instanceof WindowsBuilder) { if ($this->builder instanceof WindowsBuilder) {
throw new \RuntimeException('grpc extension does not support windows yet'); throw new ValidationException('grpc extension does not support windows yet');
} }
if (file_exists(SOURCE_PATH . '/php-src/ext/grpc')) { if (file_exists(SOURCE_PATH . '/php-src/ext/grpc')) {
return false; return false;
@@ -27,7 +28,7 @@ class grpc extends Extension
if (is_dir($this->source_dir . '/src/php/ext/grpc')) { if (is_dir($this->source_dir . '/src/php/ext/grpc')) {
shell()->exec('ln -s ' . $this->source_dir . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc'); shell()->exec('ln -s ' . $this->source_dir . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc');
} else { } else {
throw new \RuntimeException('Cannot find grpc source code'); throw new ValidationException('Cannot find grpc source code in ' . $this->source_dir . '/src/php/ext/grpc');
} }
if (SPCTarget::getTargetOS() === 'Darwin') { if (SPCTarget::getTargetOS() === 'Darwin') {
FileSystem::replaceFileRegex( FileSystem::replaceFileRegex(

View File

@@ -19,7 +19,7 @@ class imagick extends Extension
protected function splitLibsIntoStaticAndShared(string $allLibs): array protected function splitLibsIntoStaticAndShared(string $allLibs): array
{ {
[$static, $shared] = parent::splitLibsIntoStaticAndShared($allLibs); [$static, $shared] = parent::splitLibsIntoStaticAndShared($allLibs);
if (str_contains(getenv('PATH'), 'rh/devtoolset-10')) { if (str_contains(getenv('PATH'), 'rh/devtoolset') || str_contains(getenv('PATH'), 'rh/gcc-toolset')) {
$static .= ' -l:libstdc++.a'; $static .= ' -l:libstdc++.a';
$shared = str_replace('-lstdc++', '', $shared); $shared = str_replace('-lstdc++', '', $shared);
} }

View File

@@ -24,9 +24,6 @@ class imap extends Extension
return false; return false;
} }
/**
* @throws WrongUsageException
*/
public function validate(): void public function validate(): void
{ {
if ($this->builder->getOption('enable-zts')) { if ($this->builder->getOption('enable-zts')) {

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\RuntimeException; use SPC\exception\ValidationException;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('mbregex')] #[CustomExt('mbregex')]
@@ -16,11 +16,6 @@ class mbregex extends Extension
return 'mbstring'; return 'mbstring';
} }
public function getConfigureArg(bool $shared = false): string
{
return '';
}
/** /**
* mbregex is not an extension, we need to overwrite the default check. * mbregex is not an extension, we need to overwrite the default check.
*/ */
@@ -29,7 +24,7 @@ class mbregex extends Extension
$sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? '-d "extension_dir=' . BUILD_MODULES_PATH . '" -d "extension=mbstring"' : ''; $sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? '-d "extension_dir=' . BUILD_MODULES_PATH . '" -d "extension=mbstring"' : '';
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedext . ' --ri "mbstring" | grep regex', false); [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedext . ' --ri "mbstring" | grep regex', false);
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); throw new ValidationException("Extension {$this->getName()} failed compile check: compiled php-cli mbstring extension does not contain regex !");
} }
} }
@@ -37,11 +32,11 @@ class mbregex extends Extension
{ {
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "mbstring"', false); [$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "mbstring"', false);
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !'); throw new ValidationException("extension {$this->getName()} failed compile check: compiled php-cli does not contain mbstring !");
} }
$out = implode("\n", $out); $out = implode("\n", $out);
if (!str_contains($out, 'regex')) { if (!str_contains($out, 'regex')) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); throw new ValidationException("extension {$this->getName()} failed compile check: compiled php-cli mbstring extension does not contain regex !");
} }
} }
} }

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
@@ -17,9 +16,6 @@ class memcache extends Extension
return '--enable-memcache' . ($shared ? '=shared' : '') . ' --with-zlib-dir=' . BUILD_ROOT_PATH; return '--enable-memcache' . ($shared ? '=shared' : '') . ' --with-zlib-dir=' . BUILD_ROOT_PATH;
} }
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool public function patchBeforeBuildconf(): bool
{ {
FileSystem::replaceFileStr( FileSystem::replaceFileStr(

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\SourcePatcher; use SPC\store\SourcePatcher;
use SPC\util\CustomExt; use SPC\util\CustomExt;
@@ -13,10 +12,6 @@ use SPC\util\CustomExt;
#[CustomExt('opcache')] #[CustomExt('opcache')]
class opcache extends Extension class opcache extends Extension
{ {
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function validate(): void public function validate(): void
{ {
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
use SPC\util\GlobalEnvManager; use SPC\util\GlobalEnvManager;
@@ -15,7 +16,7 @@ class opentelemetry extends Extension
public function validate(): void public function validate(): void
{ {
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The opentelemetry extension requires PHP 8.0 or later'); throw new ValidationException('The opentelemetry extension requires PHP 8.0 or later');
} }
} }

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\RuntimeException; use SPC\exception\ValidationException;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('password-argon2')] #[CustomExt('password-argon2')]
@@ -20,7 +20,7 @@ class password_argon2 extends Extension
{ {
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n -r "assert(defined(\'PASSWORD_ARGON2I\'));"'); [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); throw new ValidationException('extension ' . $this->getName() . ' failed sanity check', validation_module: 'password_argon2 function check');
} }
} }

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('pdo_sqlite')] #[CustomExt('pdo_sqlite')]
class pdo_sqlite extends Extension class pdo_sqlite extends Extension
{ {
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
FileSystem::replaceFileRegex( FileSystem::replaceFileRegex(

View File

@@ -5,20 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('pgsql')] #[CustomExt('pgsql')]
class pgsql extends Extension class pgsql extends Extension
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
FileSystem::replaceFileRegex( FileSystem::replaceFileRegex(
@@ -29,10 +21,6 @@ class pgsql extends Extension
return true; return true;
} }
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string public function getUnixConfigureArg(bool $shared = false): string
{ {
if ($this->builder->getPHPVersionID() >= 80400) { if ($this->builder->getPHPVersionID() >= 80400) {
@@ -46,10 +34,6 @@ class pgsql extends Extension
return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH;
} }
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getWindowsConfigureArg(bool $shared = false): string public function getWindowsConfigureArg(bool $shared = false): string
{ {
if ($this->builder->getPHPVersionID() >= 80400) { if ($this->builder->getPHPVersionID() >= 80400) {

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('protobuf')] #[CustomExt('protobuf')]
@@ -13,12 +14,12 @@ class protobuf extends Extension
public function validate(): void public function validate(): void
{ {
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The latest protobuf extension requires PHP 8.0 or later'); throw new ValidationException('The latest protobuf extension requires PHP 8.0 or later');
} }
$grpc = $this->builder->getExt('grpc'); $grpc = $this->builder->getExt('grpc');
// protobuf conflicts with grpc // protobuf conflicts with grpc
if ($grpc?->isBuildStatic()) { if ($grpc?->isBuildStatic()) {
throw new \RuntimeException('protobuf conflicts with grpc, please remove grpc or protobuf extension'); throw new ValidationException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
} }
} }
} }

View File

@@ -6,16 +6,12 @@ namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder; use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('rar')] #[CustomExt('rar')]
class rar extends Extension class rar extends Extension
{ {
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool public function patchBeforeBuildconf(): bool
{ {
// workaround for newer Xcode clang (>= 15.0) // workaround for newer Xcode clang (>= 15.0)

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('readline')] #[CustomExt('readline')]
class readline extends Extension class readline extends Extension
{ {
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
FileSystem::replaceFileRegex( FileSystem::replaceFileRegex(

View File

@@ -16,9 +16,11 @@ class redis extends Extension
if ($this->isBuildStatic()) { if ($this->isBuildStatic()) {
$arg .= $this->builder->getExt('session')?->isBuildStatic() ? ' --enable-redis-session' : ' --disable-redis-session'; $arg .= $this->builder->getExt('session')?->isBuildStatic() ? ' --enable-redis-session' : ' --disable-redis-session';
$arg .= $this->builder->getExt('igbinary')?->isBuildStatic() ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary'; $arg .= $this->builder->getExt('igbinary')?->isBuildStatic() ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
$arg .= $this->builder->getExt('msgpack')?->isBuildStatic() ? ' --enable-redis-msgpack' : ' --disable-redis-msgpack';
} else { } else {
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session'; $arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';
$arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary'; $arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
$arg .= $this->builder->getExt('msgpack') ? ' --enable-redis-msgpack' : ' --disable-redis-msgpack';
} }
if ($this->builder->getLib('zstd')) { if ($this->builder->getLib('zstd')) {
$arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"'; $arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';

View File

@@ -6,16 +6,12 @@ namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder; use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('snappy')] #[CustomExt('snappy')]
class snappy extends Extension class snappy extends Extension
{ {
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
FileSystem::replaceFileRegex( FileSystem::replaceFileRegex(

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('ssh2')] #[CustomExt('ssh2')]
class ssh2 extends Extension class ssh2 extends Extension
{ {
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool public function patchBeforeConfigure(): bool
{ {
FileSystem::replaceFileRegex( FileSystem::replaceFileRegex(

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\RuntimeException; use SPC\exception\ValidationException;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('swoole-hook-mysql')] #[CustomExt('swoole-hook-mysql')]
@@ -32,10 +32,10 @@ class swoole_hook_mysql extends Extension
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"', false); [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"', false);
$out = implode('', $out); $out = implode('', $out);
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: 'extension swoole_hook_mysql sanity check');
} }
if (!str_contains($out, 'mysqlnd')) { if (!str_contains($out, 'mysqlnd')) {
throw new RuntimeException('swoole mysql hook is not enabled correctly.'); throw new ValidationException('swoole mysql hook is not enabled correctly.', validation_module: 'Extension swoole mysql hook avilability check');
} }
} }
} }

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\RuntimeException; use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\util\CustomExt; use SPC\util\CustomExt;
@@ -41,10 +41,16 @@ class swoole_hook_pgsql extends Extension
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
$out = implode('', $out); $out = implode('', $out);
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); throw new ValidationException(
"extension {$this->getName()} failed sanity check: php-cli returned {$ret}",
validation_module: 'Extension swoole-hook-pgsql sanity check'
);
} }
if (!str_contains($out, 'coroutine_pgsql')) { if (!str_contains($out, 'coroutine_pgsql')) {
throw new RuntimeException('swoole pgsql hook is not enabled correctly.'); throw new ValidationException(
'swoole pgsql hook is not enabled correctly.',
validation_module: 'Extension swoole pgsql hook availability check'
);
} }
} }
} }

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\RuntimeException; use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\util\CustomExt; use SPC\util\CustomExt;
@@ -41,10 +41,10 @@ class swoole_hook_sqlite extends Extension
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
$out = implode('', $out); $out = implode('', $out);
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
} }
if (!str_contains($out, 'coroutine_sqlite')) { if (!str_contains($out, 'coroutine_sqlite')) {
throw new RuntimeException('swoole sqlite hook is not enabled correctly.'); throw new ValidationException('swoole sqlite hook is not enabled correctly.', validation_module: 'Extension swoole sqlite hook availability check');
} }
} }
} }

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\RuntimeException; use SPC\exception\ValidationException;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('swow')] #[CustomExt('swow')]
@@ -14,7 +14,7 @@ class swow extends Extension
public function validate(): void public function validate(): void
{ {
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new RuntimeException('The latest swow extension requires PHP 8.0 or later'); throw new ValidationException('The latest swow extension requires PHP 8.0 or later');
} }
} }
@@ -26,9 +26,6 @@ class swow extends Extension
return $arg; return $arg;
} }
/**
* @throws RuntimeException
*/
public function patchBeforeBuildconf(): bool public function patchBeforeBuildconf(): bool
{ {
if ($this->builder->getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) { if ($this->builder->getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) {

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
@@ -14,7 +15,7 @@ class uv extends Extension
public function validate(): void public function validate(): void
{ {
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later'); throw new ValidationException('The latest uv extension requires PHP 8.0 or later');
} }
} }

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\exception\RuntimeException; use SPC\exception\SPCInternalException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
@@ -16,9 +16,6 @@ use SPC\util\CustomExt;
#[CustomExt('simplexml')] #[CustomExt('simplexml')]
class xml extends Extension class xml extends Extension
{ {
/**
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string public function getUnixConfigureArg(bool $shared = false): string
{ {
$arg = match ($this->name) { $arg = match ($this->name) {
@@ -27,7 +24,7 @@ class xml extends Extension
'xmlreader' => '--enable-xmlreader', 'xmlreader' => '--enable-xmlreader',
'xmlwriter' => '--enable-xmlwriter', 'xmlwriter' => '--enable-xmlwriter',
'simplexml' => '--enable-simplexml', 'simplexml' => '--enable-simplexml',
default => throw new RuntimeException('Not accept non-xml extension'), default => throw new SPCInternalException('Not accept non-xml extension'),
}; };
$arg .= ($shared ? '=shared' : '') . ' --with-libxml="' . BUILD_ROOT_PATH . '"'; $arg .= ($shared ? '=shared' : '') . ' --with-libxml="' . BUILD_ROOT_PATH . '"';
return $arg; return $arg;
@@ -47,7 +44,7 @@ class xml extends Extension
'xmlreader' => '--enable-xmlreader', 'xmlreader' => '--enable-xmlreader',
'xmlwriter' => '--enable-xmlwriter', 'xmlwriter' => '--enable-xmlwriter',
'simplexml' => '--with-simplexml', 'simplexml' => '--with-simplexml',
default => throw new RuntimeException('Not accept non-xml extension'), default => throw new SPCInternalException('Not accept non-xml extension'),
}; };
$arg .= ' --with-libxml'; $arg .= ' --with-libxml';
return $arg; return $arg;

View File

@@ -5,8 +5,6 @@ declare(strict_types=1);
namespace SPC\builder\freebsd; namespace SPC\builder\freebsd;
use SPC\builder\unix\UnixBuilderBase; use SPC\builder\unix\UnixBuilderBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\store\SourcePatcher; use SPC\store\SourcePatcher;
@@ -16,11 +14,6 @@ class BSDBuilder extends UnixBuilderBase
/** @var bool Micro patch phar flag */ /** @var bool Micro patch phar flag */
private bool $phar_patched = false; private bool $phar_patched = false;
/**
* @throws RuntimeException
* @throws WrongUsageException
* @throws FileSystemException
*/
public function __construct(array $options = []) public function __construct(array $options = [])
{ {
$this->options = $options; $this->options = $options;
@@ -56,10 +49,7 @@ class BSDBuilder extends UnixBuilderBase
/** /**
* Just start to build statically linked php binary * Just start to build statically linked php binary
* *
* @param int $build_target build target * @param int $build_target build target
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/ */
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
{ {
@@ -148,9 +138,6 @@ class BSDBuilder extends UnixBuilderBase
/** /**
* Build cli sapi * Build cli sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/ */
protected function buildCli(): void protected function buildCli(): void
{ {
@@ -170,10 +157,6 @@ class BSDBuilder extends UnixBuilderBase
/** /**
* Build phpmicro sapi * Build phpmicro sapi
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/ */
protected function buildMicro(): void protected function buildMicro(): void
{ {
@@ -209,9 +192,6 @@ class BSDBuilder extends UnixBuilderBase
/** /**
* Build fpm sapi * Build fpm sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/ */
protected function buildFpm(): void protected function buildFpm(): void
{ {
@@ -230,8 +210,6 @@ class BSDBuilder extends UnixBuilderBase
/** /**
* Build embed sapi * Build embed sapi
*
* @throws RuntimeException
*/ */
protected function buildEmbed(): void protected function buildEmbed(): void
{ {

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\freebsd; namespace SPC\builder\freebsd;
use SPC\builder\traits\UnixSystemUtilTrait; use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException; use SPC\exception\EnvironmentException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
class SystemUtil class SystemUtil
@@ -15,14 +15,15 @@ class SystemUtil
/** /**
* Get Logic CPU Count for macOS * Get Logic CPU Count for macOS
*
* @throws RuntimeException
*/ */
public static function getCpuCount(): int public static function getCpuCount(): int
{ {
[$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu'); [$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu');
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('Failed to get cpu count'); throw new EnvironmentException(
'Failed to get cpu count from FreeBSD sysctl',
'Please ensure you are running this command on a FreeBSD system and have the sysctl command available.'
);
} }
return (int) $output[0]; return (int) $output[0];
@@ -31,9 +32,8 @@ class SystemUtil
/** /**
* Get Target Arch CFlags * Get Target Arch CFlags
* *
* @param string $arch Arch Name * @param string $arch Arch Name
* @return string return Arch CFlags string * @return string return Arch CFlags string
* @throws WrongUsageException
*/ */
public static function getArchCFlags(string $arch): string public static function getArchCFlags(string $arch): string
{ {

View File

@@ -22,19 +22,11 @@ declare(strict_types=1);
namespace SPC\builder\freebsd\library; namespace SPC\builder\freebsd\library;
use SPC\builder\macos\library\MacOSLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
class openssl extends BSDLibraryBase class openssl extends BSDLibraryBase
{ {
public const NAME = 'openssl'; public const NAME = 'openssl';
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
[$lib,,$destdir] = SEPARATED_PATH; [$lib,,$destdir] = SEPARATED_PATH;

View File

@@ -5,8 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\linux; namespace SPC\builder\linux;
use SPC\builder\unix\UnixBuilderBase; use SPC\builder\unix\UnixBuilderBase;
use SPC\exception\FileSystemException; use SPC\exception\PatchException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\store\SourcePatcher; use SPC\store\SourcePatcher;
@@ -19,10 +18,6 @@ class LinuxBuilder extends UnixBuilderBase
/** @var bool Micro patch phar flag */ /** @var bool Micro patch phar flag */
private bool $phar_patched = false; private bool $phar_patched = false;
/**
* @throws FileSystemException
* @throws WrongUsageException
*/
public function __construct(array $options = []) public function __construct(array $options = [])
{ {
$this->options = $options; $this->options = $options;
@@ -45,10 +40,7 @@ class LinuxBuilder extends UnixBuilderBase
/** /**
* Build PHP from source. * Build PHP from source.
* *
* @param int $build_target Build target, use `BUILD_TARGET_*` constants * @param int $build_target Build target, use `BUILD_TARGET_*` constants
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
{ {
@@ -168,9 +160,6 @@ class LinuxBuilder extends UnixBuilderBase
/** /**
* Build cli sapi * Build cli sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/ */
protected function buildCli(): void protected function buildCli(): void
{ {
@@ -193,10 +182,6 @@ class LinuxBuilder extends UnixBuilderBase
/** /**
* Build phpmicro sapi * Build phpmicro sapi
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/ */
protected function buildMicro(): void protected function buildMicro(): void
{ {
@@ -231,9 +216,6 @@ class LinuxBuilder extends UnixBuilderBase
/** /**
* Build fpm sapi * Build fpm sapi
*
* @throws FileSystemException
* @throws RuntimeException
*/ */
protected function buildFpm(): void protected function buildFpm(): void
{ {
@@ -255,8 +237,6 @@ class LinuxBuilder extends UnixBuilderBase
/** /**
* Build embed sapi * Build embed sapi
*
* @throws RuntimeException
*/ */
protected function buildEmbed(): void protected function buildEmbed(): void
{ {
@@ -346,12 +326,6 @@ class LinuxBuilder extends UnixBuilderBase
/** /**
* Return extra variables for php make command. * Return extra variables for php make command.
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @throws \ReflectionException
* @throws \Throwable
*/ */
private function getMakeExtraVars(): array private function getMakeExtraVars(): array
{ {
@@ -370,8 +344,6 @@ class LinuxBuilder extends UnixBuilderBase
* Strip micro.sfx for Linux. * Strip micro.sfx for Linux.
* The micro.sfx does not support UPX directly, but we can remove UPX-info segment to adapt. * The micro.sfx does not support UPX directly, but we can remove UPX-info segment to adapt.
* This will also make micro.sfx with upx-packed more like a malware fore antivirus :( * This will also make micro.sfx with upx-packed more like a malware fore antivirus :(
*
* @throws RuntimeException
*/ */
private function processMicroUPX(): void private function processMicroUPX(): void
{ {
@@ -386,7 +358,7 @@ class LinuxBuilder extends UnixBuilderBase
$out[1] = explode(' ', $out[1]); $out[1] = explode(' ', $out[1]);
$offset = $out[1][0]; $offset = $out[1][0];
if ($ret !== 0 || !str_starts_with($offset, '0x')) { if ($ret !== 0 || !str_starts_with($offset, '0x')) {
throw new RuntimeException('Cannot find offset in readelf output'); throw new PatchException('phpmicro UPX patcher', 'Cannot find offset in readelf output');
} }
$offset = hexdec($offset); $offset = hexdec($offset);
// remove upx extra wastes // remove upx extra wastes

View File

@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\linux\library; namespace SPC\builder\linux\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\SPCTarget; use SPC\util\SPCTarget;
@@ -13,9 +11,6 @@ class imap extends LinuxLibraryBase
{ {
public const NAME = 'imap'; public const NAME = 'imap';
/**
* @throws FileSystemException
*/
public function patchBeforeBuild(): bool public function patchBeforeBuild(): bool
{ {
$cc = getenv('CC') ?: 'gcc'; $cc = getenv('CC') ?: 'gcc';
@@ -44,9 +39,6 @@ class imap extends LinuxLibraryBase
return false; return false;
} }
/**
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
if ($this->builder->getLib('openssl')) { if ($this->builder->getLib('openssl')) {

View File

@@ -4,18 +4,12 @@ declare(strict_types=1);
namespace SPC\builder\linux\library; namespace SPC\builder\linux\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
class libffi extends LinuxLibraryBase class libffi extends LinuxLibraryBase
{ {
public const NAME = 'libffi'; public const NAME = 'libffi';
/**
* @throws RuntimeException
* @throws FileSystemException
*/
public function build(): void public function build(): void
{ {
UnixAutoconfExecutor::create($this) UnixAutoconfExecutor::create($this)

View File

@@ -21,20 +21,12 @@ declare(strict_types=1);
namespace SPC\builder\linux\library; namespace SPC\builder\linux\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
class libpng extends LinuxLibraryBase class libpng extends LinuxLibraryBase
{ {
public const NAME = 'libpng'; public const NAME = 'libpng';
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function build(): void public function build(): void
{ {
UnixAutoconfExecutor::create($this) UnixAutoconfExecutor::create($this)

View File

@@ -21,9 +21,6 @@ declare(strict_types=1);
namespace SPC\builder\linux\library; namespace SPC\builder\linux\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
class openssl extends LinuxLibraryBase class openssl extends LinuxLibraryBase
@@ -32,11 +29,6 @@ class openssl extends LinuxLibraryBase
public const NAME = 'openssl'; public const NAME = 'openssl';
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function build(): void public function build(): void
{ {
$extra = ''; $extra = '';

View File

@@ -6,8 +6,6 @@ namespace SPC\builder\macos;
use SPC\builder\macos\library\MacOSLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\builder\unix\UnixBuilderBase; use SPC\builder\unix\UnixBuilderBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\store\SourcePatcher; use SPC\store\SourcePatcher;
@@ -19,11 +17,6 @@ class MacOSBuilder extends UnixBuilderBase
/** @var bool Micro patch phar flag */ /** @var bool Micro patch phar flag */
private bool $phar_patched = false; private bool $phar_patched = false;
/**
* @throws RuntimeException
* @throws WrongUsageException
* @throws FileSystemException
*/
public function __construct(array $options = []) public function __construct(array $options = [])
{ {
$this->options = $options; $this->options = $options;
@@ -48,9 +41,7 @@ class MacOSBuilder extends UnixBuilderBase
/** /**
* Get dynamically linked macOS frameworks * Get dynamically linked macOS frameworks
* *
* @param bool $asString If true, return as string * @param bool $asString If true, return as string
* @throws FileSystemException
* @throws WrongUsageException
*/ */
public function getFrameworks(bool $asString = false): array|string public function getFrameworks(bool $asString = false): array|string
{ {
@@ -83,10 +74,7 @@ class MacOSBuilder extends UnixBuilderBase
/** /**
* Just start to build statically linked php binary * Just start to build statically linked php binary
* *
* @param int $build_target build target * @param int $build_target build target
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/ */
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
{ {
@@ -190,9 +178,6 @@ class MacOSBuilder extends UnixBuilderBase
/** /**
* Build cli sapi * Build cli sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/ */
protected function buildCli(): void protected function buildCli(): void
{ {
@@ -209,10 +194,6 @@ class MacOSBuilder extends UnixBuilderBase
/** /**
* Build phpmicro sapi * Build phpmicro sapi
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/ */
protected function buildMicro(): void protected function buildMicro(): void
{ {
@@ -248,9 +229,6 @@ class MacOSBuilder extends UnixBuilderBase
/** /**
* Build fpm sapi * Build fpm sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/ */
protected function buildFpm(): void protected function buildFpm(): void
{ {
@@ -266,8 +244,6 @@ class MacOSBuilder extends UnixBuilderBase
/** /**
* Build embed sapi * Build embed sapi
*
* @throws RuntimeException
*/ */
protected function buildEmbed(): void protected function buildEmbed(): void
{ {

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\macos; namespace SPC\builder\macos;
use SPC\builder\traits\UnixSystemUtilTrait; use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException; use SPC\exception\EnvironmentException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
class SystemUtil class SystemUtil
@@ -15,25 +15,25 @@ class SystemUtil
/** /**
* Get Logic CPU Count for macOS * Get Logic CPU Count for macOS
*
* @throws RuntimeException
*/ */
public static function getCpuCount(): int public static function getCpuCount(): int
{ {
[$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu', false); $cpu = exec('sysctl -n hw.ncpu', $output, $ret);
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('Failed to get cpu count'); throw new EnvironmentException(
'Failed to get cpu count from macOS sysctl',
'Please ensure you are running this command on a macOS system and have the sysctl command available.'
);
} }
return (int) $output[0]; return (int) $cpu;
} }
/** /**
* Get Target Arch CFlags * Get Target Arch CFlags
* *
* @param string $arch Arch Name * @param string $arch Arch Name
* @return string return Arch CFlags string * @return string return Arch CFlags string
* @throws WrongUsageException
*/ */
public static function getArchCFlags(string $arch): string public static function getArchCFlags(string $arch): string
{ {

View File

@@ -8,8 +8,6 @@ use SPC\builder\BuilderBase;
use SPC\builder\LibraryBase; use SPC\builder\LibraryBase;
use SPC\builder\macos\MacOSBuilder; use SPC\builder\macos\MacOSBuilder;
use SPC\builder\traits\UnixLibraryTrait; use SPC\builder\traits\UnixLibraryTrait;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
use SPC\store\Config; use SPC\store\Config;
abstract class MacOSLibraryBase extends LibraryBase abstract class MacOSLibraryBase extends LibraryBase
@@ -28,10 +26,6 @@ abstract class MacOSLibraryBase extends LibraryBase
return $this->builder; return $this->builder;
} }
/**
* @throws WrongUsageException
* @throws FileSystemException
*/
public function getFrameworks(): array public function getFrameworks(): array
{ {
return Config::getLib(static::NAME, 'frameworks', []); return Config::getLib(static::NAME, 'frameworks', []);

View File

@@ -21,7 +21,6 @@ declare(strict_types=1);
namespace SPC\builder\macos\library; namespace SPC\builder\macos\library;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
class curl extends MacOSLibraryBase class curl extends MacOSLibraryBase
@@ -30,9 +29,6 @@ class curl extends MacOSLibraryBase
public const NAME = 'curl'; public const NAME = 'curl';
/**
* @throws FileSystemException
*/
public function patchBeforeBuild(): bool public function patchBeforeBuild(): bool
{ {
FileSystem::replaceFileRegex( FileSystem::replaceFileRegex(

View File

@@ -4,18 +4,12 @@ declare(strict_types=1);
namespace SPC\builder\macos\library; namespace SPC\builder\macos\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
class glfw extends MacOSLibraryBase class glfw extends MacOSLibraryBase
{ {
public const NAME = 'glfw'; public const NAME = 'glfw';
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\macos\library; namespace SPC\builder\macos\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\store\SourcePatcher; use SPC\store\SourcePatcher;
@@ -13,10 +11,6 @@ class imap extends MacOSLibraryBase
{ {
public const NAME = 'imap'; public const NAME = 'imap';
/**
* @throws FileSystemException
* @throws RuntimeException
*/
public function patchBeforeBuild(): bool public function patchBeforeBuild(): bool
{ {
$cc = getenv('CC') ?: 'clang'; $cc = getenv('CC') ?: 'clang';
@@ -37,9 +31,6 @@ class imap extends MacOSLibraryBase
return true; return true;
} }
/**
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
if ($this->builder->getLib('openssl')) { if ($this->builder->getLib('openssl')) {

View File

@@ -4,18 +4,12 @@ declare(strict_types=1);
namespace SPC\builder\macos\library; namespace SPC\builder\macos\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
class libffi extends MacOSLibraryBase class libffi extends MacOSLibraryBase
{ {
public const NAME = 'libffi'; public const NAME = 'libffi';
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
$arch = getenv('SPC_ARCH'); $arch = getenv('SPC_ARCH');

View File

@@ -21,20 +21,12 @@ declare(strict_types=1);
namespace SPC\builder\macos\library; namespace SPC\builder\macos\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
class libpng extends MacOSLibraryBase class libpng extends MacOSLibraryBase
{ {
public const NAME = 'libpng'; public const NAME = 'libpng';
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
$arch = arch2gnu(php_uname('m')); $arch = arch2gnu(php_uname('m'));

View File

@@ -21,9 +21,6 @@ declare(strict_types=1);
namespace SPC\builder\macos\library; namespace SPC\builder\macos\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
class openssl extends MacOSLibraryBase class openssl extends MacOSLibraryBase
@@ -32,11 +29,6 @@ class openssl extends MacOSLibraryBase
public const NAME = 'openssl'; public const NAME = 'openssl';
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
// lib:zlib // lib:zlib

View File

@@ -4,20 +4,13 @@ declare(strict_types=1);
namespace SPC\builder\traits; namespace SPC\builder\traits;
use SPC\exception\FileSystemException; use SPC\exception\PatchException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Config; use SPC\store\Config;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\SPCConfigUtil; use SPC\util\SPCConfigUtil;
trait UnixLibraryTrait trait UnixLibraryTrait
{ {
/**
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getStaticLibFiles(bool $include_self = true): string public function getStaticLibFiles(bool $include_self = true): string
{ {
$libs = $include_self ? [$this] : []; $libs = $include_self ? [$this] : [];
@@ -28,11 +21,11 @@ trait UnixLibraryTrait
} }
/** /**
* Patch pkgconfig file prefix * Patch pkgconfig file prefix, exec_prefix, libdir, includedir for correct build.
* *
* @param array $files file list * @param array $files File list to patch, if empty, will use pkg-configs from config (e.g. ['zlib.pc', 'openssl.pc'])
* @throws FileSystemException * @param int $patch_option Patch options
* @throws RuntimeException * @param null|array $custom_replace Custom replace rules, if provided, will be used to replace in the format [regex, replacement]
*/ */
public function patchPkgconfPrefix(array $files = [], int $patch_option = PKGCONF_PATCH_ALL, ?array $custom_replace = null): void public function patchPkgconfPrefix(array $files = [], int $patch_option = PKGCONF_PATCH_ALL, ?array $custom_replace = null): void
{ {
@@ -43,7 +36,7 @@ trait UnixLibraryTrait
foreach ($files as $name) { foreach ($files as $name) {
$realpath = realpath(BUILD_ROOT_PATH . '/lib/pkgconfig/' . $name); $realpath = realpath(BUILD_ROOT_PATH . '/lib/pkgconfig/' . $name);
if ($realpath === false) { if ($realpath === false) {
throw new RuntimeException('Cannot find library [' . static::NAME . '] pkgconfig file [' . $name . '] !'); throw new PatchException('pkg-config prefix patcher', 'Cannot find library [' . static::NAME . '] pkgconfig file [' . $name . '] in ' . BUILD_LIB_PATH . '/pkgconfig/ !');
} }
logger()->debug('Patching ' . $realpath); logger()->debug('Patching ' . $realpath);
// replace prefix // replace prefix
@@ -70,7 +63,7 @@ trait UnixLibraryTrait
$realpath = realpath(BUILD_LIB_PATH . '/' . $name); $realpath = realpath(BUILD_LIB_PATH . '/' . $name);
if ($realpath === false) { if ($realpath === false) {
if ($throwOnMissing) { if ($throwOnMissing) {
throw new RuntimeException('Cannot find library [' . static::NAME . '] la file [' . $name . '] !'); throw new PatchException('la dependency patcher', 'Cannot find library [' . static::NAME . '] la file [' . $name . '] !');
} }
logger()->warning('Cannot find library [' . static::NAME . '] la file [' . $name . '] !'); logger()->warning('Cannot find library [' . static::NAME . '] la file [' . $name . '] !');
continue; continue;

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace SPC\builder\traits; namespace SPC\builder\traits;
use SPC\exception\RuntimeException; use SPC\exception\SPCException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\PkgConfigUtil; use SPC\util\PkgConfigUtil;
@@ -24,7 +24,7 @@ trait openssl
if (PHP_OS_FAMILY !== 'Windows') { if (PHP_OS_FAMILY !== 'Windows') {
try { try {
return PkgConfigUtil::getModuleVersion('openssl'); return PkgConfigUtil::getModuleVersion('openssl');
} catch (RuntimeException) { } catch (SPCException) {
} }
} }
// get openssl version from header openssl/opensslv.h // get openssl version from header openssl/opensslv.h

View File

@@ -5,8 +5,8 @@ declare(strict_types=1);
namespace SPC\builder\unix; namespace SPC\builder\unix;
use SPC\builder\BuilderBase; use SPC\builder\BuilderBase;
use SPC\exception\FileSystemException; use SPC\exception\SPCInternalException;
use SPC\exception\RuntimeException; use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\Config; use SPC\store\Config;
use SPC\store\CurlHook; use SPC\store\CurlHook;
@@ -56,7 +56,14 @@ abstract class UnixBuilderBase extends BuilderBase
} }
// if some libs are not supported (but in config "lib.json", throw exception) // if some libs are not supported (but in config "lib.json", throw exception)
if (!isset($support_lib_list[$library])) { if (!isset($support_lib_list[$library])) {
throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'); $os = match (PHP_OS_FAMILY) {
'Linux' => 'Linux',
'Darwin' => 'macOS',
'Windows' => 'Windows',
'BSD' => 'FreeBSD',
default => PHP_OS_FAMILY,
};
throw new WrongUsageException("library [{$library}] is in the lib.json list but not supported to build on {$os}.");
} }
$lib = new ($support_lib_list[$library])($this); $lib = new ($support_lib_list[$library])($this);
$this->addLib($lib); $this->addLib($lib);
@@ -70,9 +77,7 @@ abstract class UnixBuilderBase extends BuilderBase
} }
/** /**
* Sanity check after build complete * Sanity check after build complete.
*
* @throws RuntimeException
*/ */
protected function sanityCheck(int $build_target): void protected function sanityCheck(int $build_target): void
{ {
@@ -82,7 +87,7 @@ abstract class UnixBuilderBase extends BuilderBase
[$ret, $output] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -r "echo \"hello\";"'); [$ret, $output] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -r "echo \"hello\";"');
$raw_output = implode('', $output); $raw_output = implode('', $output);
if ($ret !== 0 || trim($raw_output) !== 'hello') { if ($ret !== 0 || trim($raw_output) !== 'hello') {
throw new RuntimeException("cli failed sanity check: ret[{$ret}]. out[{$raw_output}]"); throw new ValidationException("cli failed sanity check. code: {$ret}, output: {$raw_output}", validation_module: 'php-cli sanity check');
} }
foreach ($this->getExts() as $ext) { foreach ($this->getExts() as $ext) {
@@ -105,7 +110,10 @@ abstract class UnixBuilderBase extends BuilderBase
foreach ($task['conditions'] as $condition => $closure) { foreach ($task['conditions'] as $condition => $closure) {
if (!$closure($ret, $out)) { if (!$closure($ret, $out)) {
$raw_out = trim(implode('', $out)); $raw_out = trim(implode('', $out));
throw new RuntimeException("micro failed sanity check: {$task_name}, condition [{$condition}], ret[{$ret}], out[{$raw_out}]"); throw new ValidationException(
"failure info: {$condition}, code: {$ret}, output: {$raw_out}",
validation_module: "phpmicro sanity check item [{$task_name}]"
);
} }
} }
} }
@@ -144,11 +152,17 @@ abstract class UnixBuilderBase extends BuilderBase
} }
[$ret, $out] = shell()->cd($sample_file_path)->execWithResult(getenv('CC') . ' -o embed embed.c ' . $lens); [$ret, $out] = shell()->cd($sample_file_path)->execWithResult(getenv('CC') . ' -o embed embed.c ' . $lens);
if ($ret !== 0) { if ($ret !== 0) {
throw new RuntimeException('embed failed sanity check: build failed. Error message: ' . implode("\n", $out)); throw new ValidationException(
'embed failed sanity check: build failed. Error message: ' . implode("\n", $out),
validation_module: 'static libphp.a sanity check'
);
} }
[$ret, $output] = shell()->cd($sample_file_path)->execWithResult($ext_path . './embed'); [$ret, $output] = shell()->cd($sample_file_path)->execWithResult($ext_path . './embed');
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') { if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
throw new RuntimeException('embed failed sanity check: run failed. Error message: ' . implode("\n", $output)); throw new ValidationException(
'embed failed sanity check: run failed. Error message: ' . implode("\n", $output),
validation_module: 'static libphp.a sanity check'
);
} }
} }
@@ -157,24 +171,28 @@ abstract class UnixBuilderBase extends BuilderBase
logger()->info('running frankenphp sanity check'); logger()->info('running frankenphp sanity check');
$frankenphp = BUILD_BIN_PATH . '/frankenphp'; $frankenphp = BUILD_BIN_PATH . '/frankenphp';
if (!file_exists($frankenphp)) { if (!file_exists($frankenphp)) {
throw new RuntimeException('FrankenPHP binary not found: ' . $frankenphp); throw new ValidationException(
"FrankenPHP binary not found: {$frankenphp}",
validation_module: 'FrankenPHP sanity check'
);
} }
$prefix = PHP_OS_FAMILY === 'Darwin' ? 'DYLD_' : 'LD_'; $prefix = PHP_OS_FAMILY === 'Darwin' ? 'DYLD_' : 'LD_';
[$ret, $output] = shell() [$ret, $output] = shell()
->setEnv(["{$prefix}LIBRARY_PATH" => BUILD_LIB_PATH]) ->setEnv(["{$prefix}LIBRARY_PATH" => BUILD_LIB_PATH])
->execWithResult("{$frankenphp} version"); ->execWithResult("{$frankenphp} version");
if ($ret !== 0 || !str_contains(implode('', $output), 'FrankenPHP')) { if ($ret !== 0 || !str_contains(implode('', $output), 'FrankenPHP')) {
throw new RuntimeException('FrankenPHP failed sanity check: ret[' . $ret . ']. out[' . implode('', $output) . ']'); throw new ValidationException(
'FrankenPHP failed sanity check: ret[' . $ret . ']. out[' . implode('', $output) . ']',
validation_module: 'FrankenPHP sanity check'
);
} }
} }
} }
/** /**
* 将编译好的二进制文件发布到 buildroot * Deploy the binary file to the build bin path.
* *
* @param int $type 发布类型 * @param int $type Type integer, one of BUILD_TARGET_CLI, BUILD_TARGET_MICRO, BUILD_TARGET_FPM
* @throws RuntimeException
* @throws FileSystemException
*/ */
protected function deployBinary(int $type): bool protected function deployBinary(int $type): bool
{ {
@@ -182,7 +200,7 @@ abstract class UnixBuilderBase extends BuilderBase
BUILD_TARGET_CLI => SOURCE_PATH . '/php-src/sapi/cli/php', BUILD_TARGET_CLI => SOURCE_PATH . '/php-src/sapi/cli/php',
BUILD_TARGET_MICRO => SOURCE_PATH . '/php-src/sapi/micro/micro.sfx', BUILD_TARGET_MICRO => SOURCE_PATH . '/php-src/sapi/micro/micro.sfx',
BUILD_TARGET_FPM => SOURCE_PATH . '/php-src/sapi/fpm/php-fpm', BUILD_TARGET_FPM => SOURCE_PATH . '/php-src/sapi/fpm/php-fpm',
default => throw new RuntimeException('Deployment does not accept type ' . $type), default => throw new SPCInternalException("Deployment does not accept type {$type}"),
}; };
logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file'); logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file');
FileSystem::createDir(BUILD_BIN_PATH); FileSystem::createDir(BUILD_BIN_PATH);
@@ -192,18 +210,15 @@ abstract class UnixBuilderBase extends BuilderBase
/** /**
* Run php clean * Run php clean
*
* @throws RuntimeException
*/ */
protected function cleanMake(): void protected function cleanMake(): void
{ {
logger()->info('cleaning up'); logger()->info('cleaning up php-src build files');
shell()->cd(SOURCE_PATH . '/php-src')->exec('make clean'); shell()->cd(SOURCE_PATH . '/php-src')->exec('make clean');
} }
/** /**
* Patch phpize and php-config if needed * Patch phpize and php-config if needed
* @throws FileSystemException
*/ */
protected function patchPhpScripts(): void protected function patchPhpScripts(): void
{ {
@@ -231,10 +246,6 @@ abstract class UnixBuilderBase extends BuilderBase
} }
} }
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
protected function buildFrankenphp(): void protected function buildFrankenphp(): void
{ {
$nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : ''; $nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : '';

View File

@@ -4,14 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait attr trait attr
{ {
/**
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixAutoconfExecutor::create($this) UnixAutoconfExecutor::create($this)

View File

@@ -4,17 +4,11 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait brotli trait brotli
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait curl trait curl
{ {
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
shell()->cd($this->source_dir)->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt'); shell()->cd($this->source_dir)->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt');

View File

@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\BuildFailureException;
trait fastlz trait fastlz
{ {
protected function build(): void protected function build(): void
@@ -13,10 +15,10 @@ trait fastlz
->exec((getenv('AR') ?: 'ar') . ' rcs libfastlz.a fastlz.o'); ->exec((getenv('AR') ?: 'ar') . ' rcs libfastlz.a fastlz.o');
if (!copy($this->source_dir . '/fastlz.h', BUILD_INCLUDE_PATH . '/fastlz.h')) { if (!copy($this->source_dir . '/fastlz.h', BUILD_INCLUDE_PATH . '/fastlz.h')) {
throw new \RuntimeException('Failed to copy fastlz.h'); throw new BuildFailureException('Failed to copy fastlz.h, file does not exist');
} }
if (!copy($this->source_dir . '/libfastlz.a', BUILD_LIB_PATH . '/libfastlz.a')) { if (!copy($this->source_dir . '/libfastlz.a', BUILD_LIB_PATH . '/libfastlz.a')) {
throw new \RuntimeException('Failed to copy libfastlz.a'); throw new BuildFailureException('Failed to copy libfastlz.a, file does not exist');
} }
} }
} }

View File

@@ -4,19 +4,11 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait freetype trait freetype
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
$cmake = UnixCMakeExecutor::create($this) $cmake = UnixCMakeExecutor::create($this)

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait gmp trait gmp
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixAutoconfExecutor::create($this)->configure()->make(); UnixAutoconfExecutor::create($this)->configure()->make();

View File

@@ -4,20 +4,12 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
use SPC\util\SPCTarget; use SPC\util\SPCTarget;
trait imagemagick trait imagemagick
{ {
/**
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
$ac = UnixAutoconfExecutor::create($this) $ac = UnixAutoconfExecutor::create($this)

View File

@@ -4,24 +4,16 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
trait jbig trait jbig
{ {
/**
* @throws FileSystemException
*/
public function patchBeforeBuild(): bool public function patchBeforeBuild(): bool
{ {
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'CFLAGS = -O2 -W -Wno-unused-result', 'CFLAGS = -O2 -W -Wno-unused-result -fPIC'); FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'CFLAGS = -O2 -W -Wno-unused-result', 'CFLAGS = -O2 -W -Wno-unused-result -fPIC');
return true; return true;
} }
/**
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
shell()->cd($this->source_dir)->initializeEnv($this) shell()->cd($this->source_dir)->initializeEnv($this)

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait lerc trait lerc
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -4,16 +4,11 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait libacl trait libacl
{ {
/**
* @throws FileSystemException
*/
public function patchBeforeMake(): bool public function patchBeforeMake(): bool
{ {
$file_path = SOURCE_PATH . '/php-src/Makefile'; $file_path = SOURCE_PATH . '/php-src/Makefile';
@@ -25,9 +20,6 @@ trait libacl
return true; return true;
} }
/**
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixAutoconfExecutor::create($this) UnixAutoconfExecutor::create($this)

View File

@@ -4,18 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait libavif trait libavif
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
@@ -20,9 +19,6 @@ trait libcares
return false; return false;
} }
/**
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixAutoconfExecutor::create($this)->configure('--disable-tests')->make(); UnixAutoconfExecutor::create($this)->configure('--disable-tests')->make();

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait libde265 trait libde265
{ {
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
@@ -34,10 +32,6 @@ trait libevent
} }
} }
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
$cmake = UnixCMakeExecutor::create($this) $cmake = UnixCMakeExecutor::create($this)

View File

@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
@@ -24,10 +22,6 @@ trait libheif
return false; return false;
} }
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -4,18 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait libjpeg trait libjpeg
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait librabbitmq trait librabbitmq
{ {
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this)->addConfigureArgs('-DBUILD_STATIC_LIBS=ON')->build(); UnixCMakeExecutor::create($this)->addConfigureArgs('-DBUILD_STATIC_LIBS=ON')->build();

View File

@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
@@ -26,10 +24,6 @@ trait librdkafka
return true; return true;
} }
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixAutoconfExecutor::create($this) UnixAutoconfExecutor::create($this)

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait libssh2 trait libssh2
{ {
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -4,18 +4,12 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
use SPC\util\SPCTarget; use SPC\util\SPCTarget;
trait libtiff trait libtiff
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
$libcpp = SPCTarget::getTargetOS() === 'Linux' ? '-lstdc++' : '-lc++'; $libcpp = SPCTarget::getTargetOS() === 'Linux' ? '-lstdc++' : '-lc++';

View File

@@ -4,15 +4,11 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait libuuid trait libuuid
{ {
/**
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this)->toStep(2)->build(); UnixCMakeExecutor::create($this)->toStep(2)->build();

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait libuv trait libuv
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -4,18 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait libwebp trait libwebp
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -5,15 +5,11 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait libxml2 trait libxml2
{ {
/**
* @throws FileSystemException
*/
public function build(): void public function build(): void
{ {
$cmake = UnixCMakeExecutor::create($this) $cmake = UnixCMakeExecutor::create($this)

View File

@@ -6,18 +6,10 @@ namespace SPC\builder\unix\library;
use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\builder\macos\library\MacOSLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait libxslt trait libxslt
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
$static_libs = $this instanceof LinuxLibraryBase ? $this->getStaticLibFiles(include_self: false) : ''; $static_libs = $this instanceof LinuxLibraryBase ? $this->getStaticLibFiles(include_self: false) : '';

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait libzip trait libzip
{ {
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)

View File

@@ -4,18 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait nghttp2 trait nghttp2
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
UnixAutoconfExecutor::create($this) UnixAutoconfExecutor::create($this)

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait nghttp3 trait nghttp3
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixAutoconfExecutor::create($this)->configure('--enable-lib-only')->make(); UnixAutoconfExecutor::create($this)->configure('--enable-lib-only')->make();

View File

@@ -6,18 +6,10 @@ namespace SPC\builder\unix\library;
use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\builder\macos\library\MacOSLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait ngtcp2 trait ngtcp2
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void protected function build(): void
{ {
UnixAutoconfExecutor::create($this) UnixAutoconfExecutor::create($this)

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait onig trait onig
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
UnixAutoconfExecutor::create($this)->configure()->make(); UnixAutoconfExecutor::create($this)->configure()->make();

View File

@@ -5,17 +5,13 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\exception\BuildFailureException;
use SPC\exception\FileSystemException; use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\SPCTarget; use SPC\util\SPCTarget;
trait postgresql trait postgresql
{ {
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
$builddir = BUILD_ROOT_PATH; $builddir = BUILD_ROOT_PATH;
@@ -64,7 +60,7 @@ trait postgresql
$envs .= " LIBS=\"{$libs}{$libcpp}\" "; $envs .= " LIBS=\"{$libs}{$libcpp}\" ";
} }
if ($error_exec_cnt > 0) { if ($error_exec_cnt > 0) {
throw new RuntimeException('Failed to get pkg-config information!'); throw new BuildFailureException('Failed to get pkg-config information!');
} }
FileSystem::resetDir($this->source_dir . '/build'); FileSystem::resetDir($this->source_dir . '/build');
@@ -78,7 +74,7 @@ trait postgresql
->exec('sed -i.backup "278 s/^/# /" ../src/Makefile.shlib') ->exec('sed -i.backup "278 s/^/# /" ../src/Makefile.shlib')
->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib'); ->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib');
} else { } else {
throw new RuntimeException('Unsupported version for postgresql: ' . $version . ' !'); throw new BuildFailureException('Unsupported version for postgresql: ' . $version . ' !');
} }
// configure // configure

View File

@@ -5,17 +5,11 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\builder\macos\library\MacOSLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait qdbm trait qdbm
{ {
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void protected function build(): void
{ {
$ac = UnixAutoconfExecutor::create($this)->configure(); $ac = UnixAutoconfExecutor::create($this)->configure();

View File

@@ -4,16 +4,10 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait readline trait readline
{ {
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void protected function build(): void
{ {
UnixAutoconfExecutor::create($this) UnixAutoconfExecutor::create($this)

Some files were not shown because too many files have changed in this diff Show More