Merge pull request #231 from DubbleClick/cplus

Linux c++ support using musl-cross-make toolchains
This commit is contained in:
Jerry Ma 2023-10-31 13:44:25 +08:00 committed by GitHub
commit 9fb5173e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
70 changed files with 808 additions and 578 deletions

350
composer.lock generated
View File

@ -8,16 +8,16 @@
"packages": [
{
"name": "illuminate/collections",
"version": "v10.24.0",
"version": "v10.29.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
"reference": "939a975daa8a5f77974ffa6a24067f5e947683f4"
"reference": "bb8784ce913bd46f944b4bd67cd857f40d9cfe68"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/collections/zipball/939a975daa8a5f77974ffa6a24067f5e947683f4",
"reference": "939a975daa8a5f77974ffa6a24067f5e947683f4",
"url": "https://api.github.com/repos/illuminate/collections/zipball/bb8784ce913bd46f944b4bd67cd857f40d9cfe68",
"reference": "bb8784ce913bd46f944b4bd67cd857f40d9cfe68",
"shasum": ""
},
"require": {
@ -59,11 +59,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2023-09-18T18:32:31+00:00"
"time": "2023-10-10T12:55:25+00:00"
},
{
"name": "illuminate/conditionable",
"version": "v10.24.0",
"version": "v10.29.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/conditionable.git",
@ -109,7 +109,7 @@
},
{
"name": "illuminate/contracts",
"version": "v10.24.0",
"version": "v10.29.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
@ -157,7 +157,7 @@
},
{
"name": "illuminate/macroable",
"version": "v10.24.0",
"version": "v10.29.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
@ -203,23 +203,27 @@
},
{
"name": "laravel/prompts",
"version": "v0.1.8",
"version": "v0.1.12",
"source": {
"type": "git",
"url": "https://github.com/laravel/prompts.git",
"reference": "68dcc65babf92e1fb43cba0b3f78fc3d8002709c"
"reference": "b35f249028c22016e45e48626e19e5d42fd827ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/prompts/zipball/68dcc65babf92e1fb43cba0b3f78fc3d8002709c",
"reference": "68dcc65babf92e1fb43cba0b3f78fc3d8002709c",
"url": "https://api.github.com/repos/laravel/prompts/zipball/b35f249028c22016e45e48626e19e5d42fd827ff",
"reference": "b35f249028c22016e45e48626e19e5d42fd827ff",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"illuminate/collections": "^10.0|^11.0",
"php": "^8.1",
"symfony/console": "^6.2"
"symfony/console": "^6.2|^7.0"
},
"conflict": {
"illuminate/console": ">=10.17.0 <10.25.0",
"laravel/framework": ">=10.17.0 <10.25.0"
},
"require-dev": {
"mockery/mockery": "^1.5",
@ -231,6 +235,11 @@
"ext-pcntl": "Required for the spinner to be animated."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "0.1.x-dev"
}
},
"autoload": {
"files": [
"src/helpers.php"
@ -245,9 +254,9 @@
],
"support": {
"issues": "https://github.com/laravel/prompts/issues",
"source": "https://github.com/laravel/prompts/tree/v0.1.8"
"source": "https://github.com/laravel/prompts/tree/v0.1.12"
},
"time": "2023-09-19T15:33:56+00:00"
"time": "2023-10-18T14:18:57+00:00"
},
{
"name": "psr/container",
@ -974,16 +983,16 @@
},
{
"name": "symfony/string",
"version": "v6.3.2",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "53d1a83225002635bca3482fcbf963001313fb68"
"reference": "13d76d0fb049051ed12a04bef4f9de8715bea339"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/53d1a83225002635bca3482fcbf963001313fb68",
"reference": "53d1a83225002635bca3482fcbf963001313fb68",
"url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339",
"reference": "13d76d0fb049051ed12a04bef4f9de8715bea339",
"shasum": ""
},
"require": {
@ -1040,7 +1049,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v6.3.2"
"source": "https://github.com/symfony/string/tree/v6.3.5"
},
"funding": [
{
@ -1056,7 +1065,7 @@
"type": "tidelift"
}
],
"time": "2023-07-05T08:41:27+00:00"
"time": "2023-09-18T10:38:32+00:00"
},
{
"name": "zhamao/logger",
@ -1682,16 +1691,16 @@
},
{
"name": "captainhook/captainhook",
"version": "5.16.4",
"version": "5.18.2",
"source": {
"type": "git",
"url": "https://github.com/captainhookphp/captainhook.git",
"reference": "524c8660551bafe9c7211440a71a35984e8dfc4b"
"reference": "61c24442f71ea216e9e172861d48d7676439dd18"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/524c8660551bafe9c7211440a71a35984e8dfc4b",
"reference": "524c8660551bafe9c7211440a71a35984e8dfc4b",
"url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/61c24442f71ea216e9e172861d48d7676439dd18",
"reference": "61c24442f71ea216e9e172861d48d7676439dd18",
"shasum": ""
},
"require": {
@ -1701,7 +1710,7 @@
"php": ">=7.4",
"sebastianfeldmann/camino": "^0.9.2",
"sebastianfeldmann/cli": "^3.3",
"sebastianfeldmann/git": "^3.8.9",
"sebastianfeldmann/git": "^3.9",
"symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0",
"symfony/filesystem": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0",
"symfony/process": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0"
@ -1753,7 +1762,7 @@
],
"support": {
"issues": "https://github.com/captainhookphp/captainhook/issues",
"source": "https://github.com/captainhookphp/captainhook/tree/5.16.4"
"source": "https://github.com/captainhookphp/captainhook/tree/5.18.2"
},
"funding": [
{
@ -1761,7 +1770,7 @@
"type": "github"
}
],
"time": "2023-04-17T19:48:47+00:00"
"time": "2023-10-16T15:13:42+00:00"
},
{
"name": "captainhook/plugin-composer",
@ -1820,16 +1829,16 @@
},
{
"name": "composer/pcre",
"version": "3.1.0",
"version": "3.1.1",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2"
"reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2",
"reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2",
"url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9",
"reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9",
"shasum": ""
},
"require": {
@ -1871,7 +1880,7 @@
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.1.0"
"source": "https://github.com/composer/pcre/tree/3.1.1"
},
"funding": [
{
@ -1887,7 +1896,7 @@
"type": "tidelift"
}
],
"time": "2022-11-17T09:50:14+00:00"
"time": "2023-10-11T07:11:09+00:00"
},
{
"name": "composer/semver",
@ -2038,16 +2047,16 @@
},
{
"name": "doctrine/deprecations",
"version": "v1.1.1",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/deprecations.git",
"reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3"
"reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3",
"reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931",
"reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931",
"shasum": ""
},
"require": {
@ -2079,9 +2088,9 @@
"homepage": "https://www.doctrine-project.org/",
"support": {
"issues": "https://github.com/doctrine/deprecations/issues",
"source": "https://github.com/doctrine/deprecations/tree/v1.1.1"
"source": "https://github.com/doctrine/deprecations/tree/1.1.2"
},
"time": "2023-06-03T09:27:29+00:00"
"time": "2023-09-27T20:04:15+00:00"
},
{
"name": "fidry/console",
@ -2167,6 +2176,75 @@
],
"time": "2022-12-18T10:49:34+00:00"
},
{
"name": "fidry/filesystem",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/theofidry/filesystem.git",
"reference": "1dd372ab3eb8b84ffe9578bff576b00c9a44ee46"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/theofidry/filesystem/zipball/1dd372ab3eb8b84ffe9578bff576b00c9a44ee46",
"reference": "1dd372ab3eb8b84ffe9578bff576b00c9a44ee46",
"shasum": ""
},
"require": {
"php": "^8.1",
"symfony/filesystem": "^6.3",
"thecodingmachine/safe": "^2.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
"ergebnis/composer-normalize": "^2.28",
"infection/infection": "^0.26",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^10.3",
"symfony/finder": "^6.3",
"symfony/phpunit-bridge": "^6.2"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": false,
"forward-command": false
},
"branch-alias": {
"dev-main": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Fidry\\FileSystem\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Théo Fidry",
"email": "theo.fidry@gmail.com"
}
],
"description": "Symfony Filesystem with a few more utilities.",
"keywords": [
"filesystem"
],
"support": {
"issues": "https://github.com/theofidry/filesystem/issues",
"source": "https://github.com/theofidry/filesystem/tree/1.1.0"
},
"funding": [
{
"url": "https://github.com/theofidry",
"type": "github"
}
],
"time": "2023-10-07T07:32:54+00:00"
},
{
"name": "filp/whoops",
"version": "2.15.3",
@ -2240,16 +2318,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.28.0",
"version": "v3.37.1",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "113e09fea3d2306319ffaa2423fe3de768b28cff"
"reference": "c3fe76976081ab871aa654e872da588077e19679"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/113e09fea3d2306319ffaa2423fe3de768b28cff",
"reference": "113e09fea3d2306319ffaa2423fe3de768b28cff",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/c3fe76976081ab871aa654e872da588077e19679",
"reference": "c3fe76976081ab871aa654e872da588077e19679",
"shasum": ""
},
"require": {
@ -2282,8 +2360,6 @@
"phpspec/prophecy": "^1.16",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5",
"phpunitgoodpractices/polyfill": "^1.6",
"phpunitgoodpractices/traits": "^1.9.2",
"symfony/phpunit-bridge": "^6.2.3",
"symfony/yaml": "^5.4 || ^6.0"
},
@ -2323,7 +2399,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.28.0"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.37.1"
},
"funding": [
{
@ -2331,7 +2407,7 @@
"type": "github"
}
],
"time": "2023-09-22T20:43:40+00:00"
"time": "2023-10-29T20:51:23+00:00"
},
{
"name": "humbug/box",
@ -2445,32 +2521,33 @@
},
{
"name": "humbug/php-scoper",
"version": "0.18.3",
"version": "0.18.4",
"source": {
"type": "git",
"url": "https://github.com/humbug/php-scoper.git",
"reference": "1a49b88b7961152daf534757137b8f86f67fde23"
"reference": "d79c1486537280c21c907e9a8a610eceb391407f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/humbug/php-scoper/zipball/1a49b88b7961152daf534757137b8f86f67fde23",
"reference": "1a49b88b7961152daf534757137b8f86f67fde23",
"url": "https://api.github.com/repos/humbug/php-scoper/zipball/d79c1486537280c21c907e9a8a610eceb391407f",
"reference": "d79c1486537280c21c907e9a8a610eceb391407f",
"shasum": ""
},
"require": {
"fidry/console": "^0.5.0",
"fidry/filesystem": "^1.1",
"jetbrains/phpstorm-stubs": "^v2022.2",
"nikic/php-parser": "^4.12",
"php": "^8.1",
"symfony/console": "^5.2 || ^6.0",
"symfony/filesystem": "^5.2 || ^6.0",
"symfony/finder": "^5.2 || ^6.0",
"thecodingmachine/safe": "^1.3 || ^2.0"
"thecodingmachine/safe": "^2.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.1",
"ergebnis/composer-normalize": "^2.28",
"fidry/makefile": "^0.2.1",
"fidry/makefile": "^1.0",
"humbug/box": "^4.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.0",
@ -2521,9 +2598,9 @@
"description": "Prefixes all PHP namespaces in a file or directory.",
"support": {
"issues": "https://github.com/humbug/php-scoper/issues",
"source": "https://github.com/humbug/php-scoper/tree/0.18.3"
"source": "https://github.com/humbug/php-scoper/tree/0.18.4"
},
"time": "2023-03-16T22:49:19+00:00"
"time": "2023-10-20T17:14:04+00:00"
},
{
"name": "jetbrains/phpstorm-stubs",
@ -2575,16 +2652,16 @@
},
{
"name": "justinrainbow/json-schema",
"version": "5.2.12",
"version": "v5.2.13",
"source": {
"type": "git",
"url": "https://github.com/justinrainbow/json-schema.git",
"reference": "ad87d5a5ca981228e0e205c2bc7dfb8e24559b60"
"reference": "fbbe7e5d79f618997bc3332a6f49246036c45793"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/ad87d5a5ca981228e0e205c2bc7dfb8e24559b60",
"reference": "ad87d5a5ca981228e0e205c2bc7dfb8e24559b60",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793",
"reference": "fbbe7e5d79f618997bc3332a6f49246036c45793",
"shasum": ""
},
"require": {
@ -2639,22 +2716,22 @@
],
"support": {
"issues": "https://github.com/justinrainbow/json-schema/issues",
"source": "https://github.com/justinrainbow/json-schema/tree/5.2.12"
"source": "https://github.com/justinrainbow/json-schema/tree/v5.2.13"
},
"time": "2022-04-13T08:02:27+00:00"
"time": "2023-09-26T02:20:38+00:00"
},
{
"name": "laravel/serializable-closure",
"version": "v1.3.1",
"version": "v1.3.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/serializable-closure.git",
"reference": "e5a3057a5591e1cfe8183034b0203921abe2c902"
"reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/e5a3057a5591e1cfe8183034b0203921abe2c902",
"reference": "e5a3057a5591e1cfe8183034b0203921abe2c902",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/076fe2cf128bd54b4341cdc6d49b95b34e101e4c",
"reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c",
"shasum": ""
},
"require": {
@ -2701,7 +2778,7 @@
"issues": "https://github.com/laravel/serializable-closure/issues",
"source": "https://github.com/laravel/serializable-closure"
},
"time": "2023-07-14T13:56:28+00:00"
"time": "2023-10-17T13:38:16+00:00"
},
{
"name": "myclabs/deep-copy",
@ -2872,16 +2949,16 @@
},
{
"name": "nunomaduro/collision",
"version": "v7.9.0",
"version": "v7.10.0",
"source": {
"type": "git",
"url": "https://github.com/nunomaduro/collision.git",
"reference": "296d0cf9fe462837ac0da8a568b56fc026b132da"
"reference": "49ec67fa7b002712da8526678abd651c09f375b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/296d0cf9fe462837ac0da8a568b56fc026b132da",
"reference": "296d0cf9fe462837ac0da8a568b56fc026b132da",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/49ec67fa7b002712da8526678abd651c09f375b2",
"reference": "49ec67fa7b002712da8526678abd651c09f375b2",
"shasum": ""
},
"require": {
@ -2890,19 +2967,22 @@
"php": "^8.1.0",
"symfony/console": "^6.3.4"
},
"conflict": {
"laravel/framework": ">=11.0.0"
},
"require-dev": {
"brianium/paratest": "^7.2.7",
"laravel/framework": "^10.23.1",
"laravel/pint": "^1.13.1",
"brianium/paratest": "^7.3.0",
"laravel/framework": "^10.28.0",
"laravel/pint": "^1.13.3",
"laravel/sail": "^1.25.0",
"laravel/sanctum": "^3.3.1",
"laravel/tinker": "^2.8.2",
"nunomaduro/larastan": "^2.6.4",
"orchestra/testbench-core": "^8.11.0",
"pestphp/pest": "^2.19.1",
"phpunit/phpunit": "^10.3.5",
"orchestra/testbench-core": "^8.13.0",
"pestphp/pest": "^2.23.2",
"phpunit/phpunit": "^10.4.1",
"sebastian/environment": "^6.0.1",
"spatie/laravel-ignition": "^2.3.0"
"spatie/laravel-ignition": "^2.3.1"
},
"type": "library",
"extra": {
@ -2961,7 +3041,7 @@
"type": "patreon"
}
],
"time": "2023-09-19T10:45:09+00:00"
"time": "2023-10-11T15:45:01+00:00"
},
{
"name": "nunomaduro/termwind",
@ -3397,16 +3477,16 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.24.1",
"version": "1.24.2",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01"
"reference": "bcad8d995980440892759db0c32acae7c8e79442"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01",
"reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442",
"reference": "bcad8d995980440892759db0c32acae7c8e79442",
"shasum": ""
},
"require": {
@ -3438,22 +3518,22 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.1"
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2"
},
"time": "2023-09-18T12:18:02+00:00"
"time": "2023-09-26T12:28:12+00:00"
},
{
"name": "phpstan/phpstan",
"version": "1.10.35",
"version": "1.10.40",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3"
"reference": "93c84b5bf7669920d823631e39904d69b9c7dc5d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e730e5facb75ffe09dfb229795e8c01a459f26c3",
"reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/93c84b5bf7669920d823631e39904d69b9c7dc5d",
"reference": "93c84b5bf7669920d823631e39904d69b9c7dc5d",
"shasum": ""
},
"require": {
@ -3502,20 +3582,20 @@
"type": "tidelift"
}
],
"time": "2023-09-19T15:27:56+00:00"
"time": "2023-10-30T14:48:31+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "10.1.6",
"version": "10.1.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "56f33548fe522c8d82da7ff3824b42829d324364"
"reference": "355324ca4980b8916c18b9db29f3ef484078f26e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/56f33548fe522c8d82da7ff3824b42829d324364",
"reference": "56f33548fe522c8d82da7ff3824b42829d324364",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/355324ca4980b8916c18b9db29f3ef484078f26e",
"reference": "355324ca4980b8916c18b9db29f3ef484078f26e",
"shasum": ""
},
"require": {
@ -3572,7 +3652,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.6"
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.7"
},
"funding": [
{
@ -3580,7 +3660,7 @@
"type": "github"
}
],
"time": "2023-09-19T04:59:03+00:00"
"time": "2023-10-04T15:34:17+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -3827,16 +3907,16 @@
},
{
"name": "phpunit/phpunit",
"version": "10.3.5",
"version": "10.4.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "747c3b2038f1139e3dcd9886a3f5a948648b7503"
"reference": "cacd8b9dd224efa8eb28beb69004126c7ca1a1a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/747c3b2038f1139e3dcd9886a3f5a948648b7503",
"reference": "747c3b2038f1139e3dcd9886a3f5a948648b7503",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/cacd8b9dd224efa8eb28beb69004126c7ca1a1a1",
"reference": "cacd8b9dd224efa8eb28beb69004126c7ca1a1a1",
"shasum": ""
},
"require": {
@ -3876,7 +3956,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "10.3-dev"
"dev-main": "10.4-dev"
}
},
"autoload": {
@ -3908,7 +3988,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.5"
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.4.2"
},
"funding": [
{
@ -3924,7 +4004,7 @@
"type": "tidelift"
}
],
"time": "2023-09-19T05:42:37+00:00"
"time": "2023-10-26T07:21:45+00:00"
},
{
"name": "psr/event-dispatcher",
@ -4222,16 +4302,16 @@
},
{
"name": "sebastian/complexity",
"version": "3.0.1",
"version": "3.1.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/complexity.git",
"reference": "c70b73893e10757af9c6a48929fa6a333b56a97a"
"reference": "68cfb347a44871f01e33ab0ef8215966432f6957"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/c70b73893e10757af9c6a48929fa6a333b56a97a",
"reference": "c70b73893e10757af9c6a48929fa6a333b56a97a",
"url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68cfb347a44871f01e33ab0ef8215966432f6957",
"reference": "68cfb347a44871f01e33ab0ef8215966432f6957",
"shasum": ""
},
"require": {
@ -4244,7 +4324,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.0-dev"
"dev-main": "3.1-dev"
}
},
"autoload": {
@ -4268,7 +4348,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/complexity/issues",
"security": "https://github.com/sebastianbergmann/complexity/security/policy",
"source": "https://github.com/sebastianbergmann/complexity/tree/3.0.1"
"source": "https://github.com/sebastianbergmann/complexity/tree/3.1.0"
},
"funding": [
{
@ -4276,7 +4356,7 @@
"type": "github"
}
],
"time": "2023-08-31T09:55:53+00:00"
"time": "2023-09-28T11:50:59+00:00"
},
{
"name": "sebastian/diff",
@ -4411,16 +4491,16 @@
},
{
"name": "sebastian/exporter",
"version": "5.1.0",
"version": "5.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344"
"reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c3fa8483f9539b190f7cd4bfc4a07631dd1df344",
"reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/64f51654862e0f5e318db7e9dcc2292c63cdbddc",
"reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc",
"shasum": ""
},
"require": {
@ -4434,7 +4514,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "5.0-dev"
"dev-main": "5.1-dev"
}
},
"autoload": {
@ -4477,7 +4557,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"security": "https://github.com/sebastianbergmann/exporter/security/policy",
"source": "https://github.com/sebastianbergmann/exporter/tree/5.1.0"
"source": "https://github.com/sebastianbergmann/exporter/tree/5.1.1"
},
"funding": [
{
@ -4485,7 +4565,7 @@
"type": "github"
}
],
"time": "2023-09-18T07:15:37+00:00"
"time": "2023-09-24T13:22:09+00:00"
},
{
"name": "sebastian/global-state",
@ -5007,16 +5087,16 @@
},
{
"name": "sebastianfeldmann/git",
"version": "3.8.9",
"version": "3.9.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianfeldmann/git.git",
"reference": "38586be69b0932b630337afcc8db12e5b7981254"
"reference": "eb2ca84a2b45a461f0bf5d4fd400df805649e83a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianfeldmann/git/zipball/38586be69b0932b630337afcc8db12e5b7981254",
"reference": "38586be69b0932b630337afcc8db12e5b7981254",
"url": "https://api.github.com/repos/sebastianfeldmann/git/zipball/eb2ca84a2b45a461f0bf5d4fd400df805649e83a",
"reference": "eb2ca84a2b45a461f0bf5d4fd400df805649e83a",
"shasum": ""
},
"require": {
@ -5056,7 +5136,7 @@
],
"support": {
"issues": "https://github.com/sebastianfeldmann/git/issues",
"source": "https://github.com/sebastianfeldmann/git/tree/3.8.9"
"source": "https://github.com/sebastianfeldmann/git/tree/3.9.3"
},
"funding": [
{
@ -5064,7 +5144,7 @@
"type": "github"
}
],
"time": "2023-03-30T16:37:34+00:00"
"time": "2023-10-13T09:10:48+00:00"
},
{
"name": "seld/jsonlint",
@ -5351,16 +5431,16 @@
},
{
"name": "symfony/finder",
"version": "v6.3.3",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e"
"reference": "a1b31d88c0e998168ca7792f222cbecee47428c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/9915db259f67d21eefee768c1abcf1cc61b1fc9e",
"reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e",
"url": "https://api.github.com/repos/symfony/finder/zipball/a1b31d88c0e998168ca7792f222cbecee47428c4",
"reference": "a1b31d88c0e998168ca7792f222cbecee47428c4",
"shasum": ""
},
"require": {
@ -5395,7 +5475,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v6.3.3"
"source": "https://github.com/symfony/finder/tree/v6.3.5"
},
"funding": [
{
@ -5411,7 +5491,7 @@
"type": "tidelift"
}
],
"time": "2023-07-31T08:31:44+00:00"
"time": "2023-09-26T12:56:25+00:00"
},
{
"name": "symfony/options-resolver",
@ -5605,16 +5685,16 @@
},
{
"name": "symfony/var-dumper",
"version": "v6.3.4",
"version": "v6.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "2027be14f8ae8eae999ceadebcda5b4909b81d45"
"reference": "999ede244507c32b8e43aebaa10e9fce20de7c97"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/2027be14f8ae8eae999ceadebcda5b4909b81d45",
"reference": "2027be14f8ae8eae999ceadebcda5b4909b81d45",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/999ede244507c32b8e43aebaa10e9fce20de7c97",
"reference": "999ede244507c32b8e43aebaa10e9fce20de7c97",
"shasum": ""
},
"require": {
@ -5669,7 +5749,7 @@
"dump"
],
"support": {
"source": "https://github.com/symfony/var-dumper/tree/v6.3.4"
"source": "https://github.com/symfony/var-dumper/tree/v6.3.6"
},
"funding": [
{
@ -5685,7 +5765,7 @@
"type": "tidelift"
}
],
"time": "2023-08-24T14:51:05+00:00"
"time": "2023-10-12T18:45:56+00:00"
},
{
"name": "thecodingmachine/safe",

View File

@ -146,7 +146,6 @@
},
"intl": {
"type": "builtin",
"cpp-extension": true,
"lib-depends": [
"icu"
]
@ -233,7 +232,7 @@
},
"openssl": {
"type": "builtin",
"arg-type": "with",
"arg-type": "custom",
"lib-depends": [
"openssl"
],

View File

@ -111,6 +111,7 @@
},
"icu": {
"source": "icu",
"cpp-library": true,
"static-libs-unix": [
"libicui18n.a",
"libicuio.a",
@ -122,20 +123,20 @@
"source": "imagemagick",
"static-libs-unix": [
"libMagick++-7.Q16HDRI.a",
"libMagickCore-7.Q16HDRI.a",
"libMagickWand-7.Q16HDRI.a"
"libMagickWand-7.Q16HDRI.a",
"libMagickCore-7.Q16HDRI.a"
],
"lib-depends": [
"zlib",
"libpng",
"libjpeg",
"bzip2",
"libwebp",
"freetype"
],
"lib-suggests": [
"zstd",
"xz",
"bzip2",
"libzip",
"libxml2"
]
@ -434,7 +435,10 @@
"readline"
],
"lib-suggests": [
"icu"
"icu",
"libxslt",
"ldap",
"zstd"
]
},
"pthreads4w": {
@ -464,10 +468,9 @@
"libsnappy.a"
],
"headers-unix": [
"snappy.h",
"snappy-c.h",
"snappy-sinksource.h",
"snappy.h",
"snappy-stubs-internal.h",
"snappy-stubs-public.h"
],
"lib-depends": [

View File

@ -433,7 +433,7 @@
},
"sqlite": {
"type": "url",
"url": "https://www.sqlite.org/2023/sqlite-autoconf-3410100.tar.gz",
"url": "https://www.sqlite.org/2023/sqlite-autoconf-3430200.tar.gz",
"license": {
"type": "text",
"text": "The author disclaims copyright to this source code. In place of\na legal notice, here is a blessing:\n\n * May you do good and not evil.\n * May you find forgiveness for yourself and forgive others.\n * May you share freely, never taking more than you give."

View File

@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand;
*/
final class ConsoleApplication extends Application
{
public const VERSION = '2.0-rc7';
public const VERSION = '2.0.0-rc8';
public function __construct()
{

View File

@ -112,6 +112,16 @@ abstract class BuilderBase
return $this->libs[$name] ?? null;
}
/**
* Get all library objects.
*
* @return LibraryBase[]
*/
public function getLibs(): array
{
return $this->libs;
}
/**
* Add extension to build.
*/
@ -139,12 +149,12 @@ abstract class BuilderBase
}
/**
* Check if there is a cpp extension.
* Check if there is a cpp extensions or libraries.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function hasCppExtension(): bool
public function hasCpp(): bool
{
// judge cpp-extension
$exts = array_keys($this->getExts());
@ -153,6 +163,12 @@ abstract class BuilderBase
return true;
}
}
$libs = array_keys($this->getLibs());
foreach ($libs as $lib) {
if (Config::getLib($lib, 'cpp-library', false) === true) {
return true;
}
}
return false;
}
@ -303,6 +319,18 @@ abstract class BuilderBase
$this->options[$key] = $value;
}
public function getEnvString(array $vars = ['cc', 'cxx', 'ar', 'ld']): string
{
$env = [];
foreach ($vars as $var) {
$var = strtoupper($var);
if (getenv($var) !== false) {
$env[] = "{$var}=" . getenv($var);
}
}
return implode(' ', $env);
}
/**
* Check if all libs are downloaded.
* If not, throw exception.

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\util\CustomExt;
#[CustomExt('iconv')]
@ -13,6 +14,9 @@ class iconv extends Extension
public function patchBeforeConfigure(): bool
{
// macOS need to link iconv dynamically, we add it to extra-libs
if (!$this->builder instanceof MacOSBuilder) {
return false;
}
$extra_libs = $this->builder->getOption('extra-libs', '');
if (!str_contains($extra_libs, '-liconv')) {
$extra_libs .= ' -liconv';

View File

@ -10,13 +10,11 @@ use SPC\util\CustomExt;
#[CustomExt('imagick')]
class imagick extends Extension
{
public function patchBeforeBuildconf(): bool
public function patchBeforeMake(): bool
{
// linux need to link library manually, we add it to extra-libs
// imagick may call omp_pause_all which requires -lgomp
$extra_libs = $this->builder->getOption('extra-libs', '');
if (!str_contains($extra_libs, 'libMagickCore')) {
$extra_libs .= ' /usr/lib/libMagick++-7.Q16HDRI.a /usr/lib/libMagickCore-7.Q16HDRI.a /usr/lib/libMagickWand-7.Q16HDRI.a';
}
$extra_libs .= ' -lgomp ';
$this->builder->setOption('extra-libs', $extra_libs);
return true;
}

View File

@ -22,4 +22,9 @@ class openssl extends Extension
return false;
}
public function getUnixConfigureArg(): string
{
return '--with-openssl=' . BUILD_ROOT_PATH . ' --with-openssl-dir=' . BUILD_ROOT_PATH;
}
}

View File

@ -31,9 +31,16 @@ class BSDBuilder extends BuilderBase
// ---------- set necessary options ----------
// set C Compiler (default: clang)
$this->setOptionIfNotExist('cc', 'clang');
f_putenv('CC=' . $this->getOption('cc', 'clang'));
// set C++ Composer (default: clang++)
$this->setOptionIfNotExist('cxx', 'clang++');
f_putenv('CXX=' . $this->getOption('cxx', 'clang++'));
// set PATH
f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
// set PKG_CONFIG
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
// set PKG_CONFIG_PATH
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/');
// set arch (default: current)
$this->setOptionIfNotExist('arch', php_uname('m'));
$this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch')));
@ -46,16 +53,6 @@ class BSDBuilder extends BuilderBase
$this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch'));
// cmake toolchain
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('BSD', $this->getOption('arch'), $this->arch_c_flags);
// configure environment
$this->configure_env = SystemUtil::makeEnvVarString([
'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config',
'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig/',
'CC' => $this->getOption('cc'),
'CXX' => $this->getOption('cxx'),
'CFLAGS' => "{$this->arch_c_flags} -Wimplicit-function-declaration -Os",
'LIBS' => '-ldl -lpthread',
'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'),
]);
// create pkgconfig and include dir (some libs cannot create them automatically)
f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true);
@ -75,7 +72,7 @@ class BSDBuilder extends BuilderBase
// ---------- Update extra-libs ----------
$extra_libs = $this->getOption('extra-libs', '');
// add libc++, some extensions or libraries need it (C++ cannot be linked statically)
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lc++ ' : '');
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lc++ ' : '');
if (!$this->getOption('bloat', false)) {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
} else {
@ -115,8 +112,7 @@ class BSDBuilder extends BuilderBase
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
$json_74 .
$zts .
$this->makeExtensionArgs() . ' ' .
$this->configure_env
$this->makeExtensionArgs()
);
SourcePatcher::patchBeforeMake($this);
@ -173,12 +169,14 @@ class BSDBuilder extends BuilderBase
/**
* Build phpmicro sapi
*
* @throws FileSystemException|RuntimeException
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildMicro(): void
{
if ($this->getPHPVersionID() < 80000) {
throw new RuntimeException('phpmicro only support PHP >= 8.0!');
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
}
if ($this->getExt('phar')) {
$this->phar_patched = true;
@ -228,6 +226,11 @@ class BSDBuilder extends BuilderBase
$this->deployBinary(BUILD_TARGET_FPM);
}
/**
* Build embed sapi
*
* @throws RuntimeException
*/
public function buildEmbed(): void
{
$vars = SystemUtil::makeEnvVarString([

View File

@ -49,7 +49,7 @@ class openssl extends BSDLibraryBase
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./Configure no-shared {$extra} " .
"./Configure no-shared {$extra} " .
'--prefix=/ ' . // use prefix=/
"--libdir={$lib} " .
'--openssldir=/etc/ssl ' .

View File

@ -18,15 +18,9 @@ class LinuxBuilder extends BuilderBase
/** Unix compatible builder methods */
use UnixBuilderTrait;
/** @var string Using libc [musl,glibc] */
public string $libc;
/** @var array Tune cflags */
public array $tune_c_flags;
/** @var string pkg-config env, including PKG_CONFIG_PATH, PKG_CONFIG */
public string $pkgconf_env;
/** @var bool Micro patch phar flag */
private bool $phar_patched = false;
@ -40,48 +34,55 @@ class LinuxBuilder extends BuilderBase
$this->options = $options;
// ---------- set necessary options ----------
// set C Compiler (default: alpine: gcc, others: musl-gcc)
$this->setOptionIfNotExist('cc', match (SystemUtil::getOSRelease()['dist']) {
'alpine' => 'gcc',
default => 'musl-gcc'
});
// set C++ Compiler (default: g++)
$this->setOptionIfNotExist('cxx', 'g++');
// set C/C++ compilers (default: alpine: gcc, others: musl-cross-make)
if (SystemUtil::isMuslDist()) {
f_putenv("CC={$this->getOption('cc', 'gcc')}");
f_putenv("CXX={$this->getOption('cxx', 'g++')}");
f_putenv("AR={$this->getOption('ar', 'ar')}");
f_putenv("LD={$this->getOption('ld', 'ld.gold')}");
} else {
$arch = arch2gnu(php_uname('m'));
f_putenv("CC={$this->getOption('cc', "{$arch}-linux-musl-gcc")}");
f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}");
f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}");
f_putenv("LD={$this->getOption('ld', 'ld.gold')}");
f_putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
// check musl-cross make installed if we use musl-cross-make
if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) {
throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)');
}
}
// set PKG_CONFIG
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
// set PKG_CONFIG_PATH
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig');
// set arch (default: current)
$this->setOptionIfNotExist('arch', php_uname('m'));
$this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch')));
// ---------- set necessary compile environments ----------
// set libc
$this->libc = $this->getOption('cc', 'gcc') === 'musl-gcc' ? 'musl_wrapper' : 'musl'; // SystemUtil::selectLibc($this->cc);
// concurrency
$this->concurrency = SystemUtil::getCpuCount();
// cflags
$this->arch_c_flags = SystemUtil::getArchCFlags($this->getOption('cc'), $this->getOption('arch'));
$this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('cxx'), $this->getOption('arch'));
$this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), $this->getOption('cc'));
$this->arch_c_flags = SystemUtil::getArchCFlags(getenv('CC'), $this->getOption('arch'));
$this->arch_cxx_flags = SystemUtil::getArchCFlags(getenv('CXX'), $this->getOption('arch'));
$this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), getenv('CC'));
// cmake toolchain
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile(
'Linux',
$this->getOption('arch'),
$this->arch_c_flags,
$this->getOption('cc'),
$this->getOption('cxx'),
getenv('CC'),
getenv('CXX'),
);
// pkg-config
$vars = [
'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config',
'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig',
];
$this->pkgconf_env = SystemUtil::makeEnvVarString($vars);
// configure environment
$this->configure_env = SystemUtil::makeEnvVarString([
...$vars,
'CC' => $this->getOption('cc'),
'CXX' => $this->getOption('cxx'),
'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'),
]);
// cross-compile does not support yet
// cross-compiling is not supported yet
/*if (php_uname('m') !== $this->arch) {
$this->cross_compile_prefix = SystemUtil::getCrossCompilePrefix($this->cc, $this->arch);
logger()->info('using cross compile prefix: ' . $this->cross_compile_prefix);
@ -134,33 +135,16 @@ class LinuxBuilder extends BuilderBase
} else {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles())));
}
// add libstdc++, some extensions or libraries need it (C++ cannot be linked statically)
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lstdc++ ' : '');
// add libstdc++, some extensions or libraries need it
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
$this->setOption('extra-libs', $extra_libs);
$cflags = $this->arch_c_flags;
$use_lld = '';
switch ($this->libc) {
case 'musl_wrapper':
case 'glibc':
$cflags .= ' -static-libgcc -I"' . BUILD_INCLUDE_PATH . '"';
break;
case 'musl':
if (str_ends_with($this->getOption('cc'), 'clang') && SystemUtil::findCommand('lld')) {
$use_lld = '-Xcompiler -fuse-ld=lld';
}
break;
default:
throw new WrongUsageException('libc ' . $this->libc . ' is not implemented yet');
}
$envs = $this->pkgconf_env . ' ' . SystemUtil::makeEnvVarString([
'CC' => $this->getOption('cc'),
'CXX' => $this->getOption('cxx'),
// prepare build php envs
$envs_build_php = SystemUtil::makeEnvVarString([
'CFLAGS' => $cflags,
'LIBS' => '-ldl -lpthread',
'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'),
]);
SourcePatcher::patchBeforeBuildconf($this);
@ -179,6 +163,7 @@ class LinuxBuilder extends BuilderBase
$maxExecutionTimers = '';
$zts = '';
}
$disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : '';
$enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI;
$enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM;
@ -187,6 +172,7 @@ class LinuxBuilder extends BuilderBase
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
"{$this->getOption('ld_library_path')} " .
'./configure ' .
'--prefix= ' .
'--with-valgrind=no ' .
@ -197,13 +183,14 @@ class LinuxBuilder extends BuilderBase
'--disable-phpdbg ' .
($enableCli ? '--enable-cli ' : '--disable-cli ') .
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
($enableEmbed ? '--enable-embed=static --disable-opcache-jit ' : '--disable-embed ') .
($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') .
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
$disable_jit .
$json_74 .
$zts .
$maxExecutionTimers .
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
$this->makeExtensionArgs() . ' ' .
$envs
$envs_build_php
);
SourcePatcher::patchBeforeMake($this);
@ -212,22 +199,22 @@ class LinuxBuilder extends BuilderBase
if ($enableCli) {
logger()->info('building cli');
$this->buildCli($extra_libs, $use_lld);
$this->buildCli();
}
if ($enableFpm) {
logger()->info('building fpm');
$this->buildFpm($extra_libs, $use_lld);
$this->buildFpm();
}
if ($enableMicro) {
logger()->info('building micro');
$this->buildMicro($extra_libs, $use_lld, $cflags);
$this->buildMicro();
}
if ($enableEmbed) {
logger()->info('building embed');
if ($enableMicro) {
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la');
}
$this->buildEmbed($extra_libs, $use_lld);
$this->buildEmbed();
}
if (php_uname('m') === $this->getOption('arch')) {
@ -241,13 +228,9 @@ class LinuxBuilder extends BuilderBase
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildCli(string $extra_libs, string $use_lld): void
public function buildCli(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)),
'EXTRA_LIBS' => $extra_libs,
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static",
]);
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("make -j{$this->concurrency} {$vars} cli");
@ -262,25 +245,23 @@ class LinuxBuilder extends BuilderBase
/**
* Build phpmicro sapi
*
* @throws RuntimeException
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildMicro(string $extra_libs, string $use_lld, string $cflags): void
public function buildMicro(): void
{
if ($this->getPHPVersionID() < 80000) {
throw new RuntimeException('phpmicro only support PHP >= 8.0!');
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
}
if ($this->getExt('phar')) {
$this->phar_patched = true;
SourcePatcher::patchMicro(['phar']);
}
$enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '';
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $enable_fake_cli,
'EXTRA_LIBS' => $extra_libs,
'EXTRA_LDFLAGS_PROGRAM' => "{$cflags} {$use_lld} -all-static",
]);
$vars = SystemUtil::makeEnvVarString($this->getBuildVars([
'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '',
]));
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("make -j{$this->concurrency} {$vars} micro");
@ -302,14 +283,9 @@ class LinuxBuilder extends BuilderBase
* @throws FileSystemException
* @throws RuntimeException
*/
public function buildFpm(string $extra_libs, string $use_lld): void
public function buildFpm(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)),
'EXTRA_LIBS' => $extra_libs,
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static",
]);
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("make -j{$this->concurrency} {$vars} fpm");
@ -321,17 +297,35 @@ class LinuxBuilder extends BuilderBase
$this->deployBinary(BUILD_TARGET_FPM);
}
public function buildEmbed(string $extra_libs, string $use_lld): void
/**
* Build embed sapi
*
* @throws RuntimeException
*/
public function buildEmbed(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)),
'EXTRA_LIBS' => $extra_libs,
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static",
]);
$vars = SystemUtil::makeEnvVarString($this->getBuildVars());
shell()
->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install");
}
private function getBuildVars($input = []): array
{
$use_lld = '';
if (str_ends_with(getenv('CC'), 'clang') && SystemUtil::findCommand('lld')) {
$use_lld = '-Xcompiler -fuse-ld=lld';
}
$optimization = $this->getOption('no-strip', false) ? '-g -O0' : '-g0 -Os';
$cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : '';
$libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : '';
$ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : '';
return [
'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $cflags,
'EXTRA_LIBS' => $this->getOption('extra-libs', '') . $libs,
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static" . $ldflags,
];
}
}

View File

@ -53,6 +53,11 @@ class SystemUtil
return $ret;
}
public static function isMuslDist(): bool
{
return static::getOSRelease()['dist'] === 'alpine';
}
public static function getCpuCount(): int
{
$ncpu = 1;

View File

@ -33,15 +33,4 @@ abstract class LinuxLibraryBase extends LibraryBase
{
return $this->builder;
}
protected function makeFakePkgconfs(): void
{
$workspace = BUILD_ROOT_PATH;
if ($workspace === '/') {
$workspace = '';
}
foreach ($this->pkgconfs as $name => $content) {
file_put_contents(BUILD_LIB_PATH . "/pkgconfig/{$name}", "prefix={$workspace}\n" . $content);
}
}
}

View File

@ -10,11 +10,13 @@ class icu extends LinuxLibraryBase
protected function build(): void
{
$root = BUILD_ROOT_PATH;
$cppflag = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"';
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"';
$cxxflags = 'CXXFLAGS="-std=c++11"';
$ldflags = 'LDFLAGS="-static"';
shell()->cd($this->source_dir . '/source')
->exec(
"{$this->builder->configure_env} {$cppflag} ./runConfigureICU Linux " .
"{$cppflags} {$cxxflags} {$ldflags} " .
'./runConfigureICU Linux ' .
'--enable-static ' .
'--disable-shared ' .
'--with-data-packaging=static ' .
@ -25,7 +27,7 @@ class icu extends LinuxLibraryBase
'--enable-tools=yes ' .
'--enable-tests=no ' .
'--enable-samples=no ' .
"--prefix={$root}"
'--prefix=' . BUILD_ROOT_PATH
)
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")

View File

@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\exception\RuntimeException;
class libffi extends LinuxLibraryBase
{
public const NAME = 'libffi';
/**
* @throws RuntimeException
*/
public function build(): void
{
[$lib, , $destdir] = SEPARATED_PATH;
/*$env = $this->builder->pkgconf_env . ' CFLAGS="' . $this->builder->arch_c_flags . '"';
$env .= match ($this->builder->libc) {
'musl_wrapper' => " CC='{$this->builder->getOption('cc')} --static -idirafter " . BUILD_INCLUDE_PATH .
($this->builder->getOption('arch') === php_uname('m') ? '-idirafter /usr/include/ ' : '') .
"-idirafter /usr/include/{$this->builder->getOption('arch')}-linux-gnu/'",
'musl', 'glibc' => " CC='{$this->builder->getOption('cc')}'",
default => throw new RuntimeException('unsupported libc: ' . $this->builder->libc),
};*/
shell()->cd($this->source_dir)
->exec(
'./configure ' .
'--enable-static ' .
'--disable-shared ' .
"--host={$this->builder->getOption('arch')}-unknown-linux " .
"--target={$this->builder->getOption('arch')}-unknown-linux " .
'--prefix= ' . // use prefix=/
"--libdir={$lib}"
)
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec("make install DESTDIR={$destdir}");
if (is_file(BUILD_ROOT_PATH . '/lib64/libffi.a')) {
copy(BUILD_ROOT_PATH . '/lib64/libffi.a', BUILD_ROOT_PATH . '/lib/libffi.a');
unlink(BUILD_ROOT_PATH . '/lib64/libffi.a');
}
$this->patchPkgconfPrefix(['libffi.pc']);
}
}

View File

@ -20,36 +20,14 @@ declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\builder\linux\SystemUtil;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
class libpng extends LinuxLibraryBase
{
public const NAME = 'libpng';
/**
* @throws FileSystemException
*/
public function patchBeforeBuild(): bool
{
FileSystem::replaceFileStr(
SOURCE_PATH . '/libpng/configure',
'-lz',
BUILD_LIB_PATH . '/libz.a'
);
if (SystemUtil::getOSRelease()['dist'] === 'alpine') {
FileSystem::replaceFileStr(
SOURCE_PATH . '/libpng/configure',
'-lm',
'/usr/lib/libm.a'
);
}
return true;
}
/**
* @throws FileSystemException
* @throws RuntimeException
@ -66,7 +44,8 @@ class libpng extends LinuxLibraryBase
->exec('chmod +x ./configure')
->exec('chmod +x ./install-sh')
->exec(
"{$this->builder->configure_env} ./configure " .
'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' .
'./configure ' .
'--disable-shared ' .
'--enable-static ' .
'--enable-hardware-optimizations ' .
@ -75,7 +54,7 @@ class libpng extends LinuxLibraryBase
'--prefix='
)
->exec('make clean')
->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I. -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la")
->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la")
->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX);
$this->cleanLaFiles();

View File

@ -19,22 +19,19 @@ class libxml2 extends LinuxLibraryBase
public function build(): void
{
$enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF';
// $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
FileSystem::resetDir($this->source_dir . '/build');
shell()->cd($this->source_dir . '/build')
->exec(
"{$this->builder->configure_env} " . ' cmake ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DCMAKE_INSTALL_PREFIX=' . escapeshellarg(BUILD_ROOT_PATH) . ' ' .
'cmake ' .
"{$this->builder->makeCmakeArgs()} " .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DCMAKE_INSTALL_BINDIR=' . escapeshellarg(BUILD_ROOT_PATH . '/bin') . ' ' .
'-DLIBXML2_WITH_ICONV=ON ' .
'-DIconv_IS_BUILT_IN=OFF ' .
'-DLIBXML2_WITH_ICONV=ON ' .
"-DLIBXML2_WITH_ZLIB={$enable_zlib} " .
'-DLIBXML2_WITH_ICU=OFF ' .
"-DLIBXML2_WITH_ICU={$enable_icu} " .
"-DLIBXML2_WITH_LZMA={$enable_xz} " .
'-DLIBXML2_WITH_PYTHON=OFF ' .
'-DLIBXML2_WITH_PROGRAMS=OFF ' .
@ -42,6 +39,12 @@ class libxml2 extends LinuxLibraryBase
'..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
FileSystem::replaceFileStr(
BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc',
'-licudata -licui18n -licuuc',
'-licui18n -licuuc -licudata'
);
}
}

View File

@ -55,7 +55,7 @@ class nghttp2 extends LinuxLibraryBase
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
'./configure ' .
'--enable-static ' .
'--disable-shared ' .
"--host={$this->builder->getOption('gnu-arch')}-unknown-linux " .

View File

@ -41,8 +41,8 @@ class openssl extends LinuxLibraryBase
$extra = '';
$ex_lib = '-ldl -pthread';
$env = $this->builder->pkgconf_env . " CFLAGS='{$this->builder->arch_c_flags}'";
$env .= " CC='{$this->builder->getOption('cc')} -static -idirafter " . BUILD_INCLUDE_PATH .
$env = "CFLAGS='{$this->builder->arch_c_flags}'";
$env .= " CC='" . getenv('CC') . ' -static -idirafter ' . BUILD_INCLUDE_PATH .
' -idirafter /usr/include/ ' .
' -idirafter /usr/include/' . $this->builder->getOption('arch') . '-linux-gnu/ ' .
"' ";
@ -60,11 +60,11 @@ class openssl extends LinuxLibraryBase
$ex_lib = trim($ex_lib);
$clang_postfix = SystemUtil::getCCType($this->builder->getOption('cc')) === 'clang' ? '-clang' : '';
$clang_postfix = SystemUtil::getCCType(getenv('CC')) === 'clang' ? '-clang' : '';
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} {$env} ./Configure no-shared {$extra} " .
"{$env} ./Configure no-shared {$extra} " .
'--prefix=/ ' .
'--libdir=lib ' .
'-static ' .

View File

@ -32,9 +32,16 @@ class MacOSBuilder extends BuilderBase
// ---------- set necessary options ----------
// set C Compiler (default: clang)
$this->setOptionIfNotExist('cc', 'clang');
f_putenv('CC=' . $this->getOption('cc', 'clang'));
// set C++ Composer (default: clang++)
$this->setOptionIfNotExist('cxx', 'clang++');
f_putenv('CXX=' . $this->getOption('cxx', 'clang++'));
// set PATH
f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
// set PKG_CONFIG
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
// set PKG_CONFIG_PATH
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/');
// set arch (default: current)
$this->setOptionIfNotExist('arch', php_uname('m'));
$this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch')));
@ -47,15 +54,6 @@ class MacOSBuilder extends BuilderBase
$this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch'));
// cmake toolchain
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->getOption('arch'), $this->arch_c_flags);
// configure environment
$this->configure_env = SystemUtil::makeEnvVarString([
'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config',
'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig/',
'CC' => $this->getOption('cc'),
'CXX' => $this->getOption('cxx'),
'CFLAGS' => "{$this->arch_c_flags} -Wimplicit-function-declaration -Os",
'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'),
]);
// create pkgconfig and include dir (some libs cannot create them automatically)
f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true);
@ -134,7 +132,7 @@ class MacOSBuilder extends BuilderBase
// add macOS frameworks
$extra_libs .= (empty($extra_libs) ? '' : ' ') . $this->getFrameworks(true);
// add libc++, some extensions or libraries need it (C++ cannot be linked statically)
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lc++ ' : '');
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lc++ ' : '');
if (!$this->getOption('bloat', false)) {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
} else {
@ -174,8 +172,7 @@ class MacOSBuilder extends BuilderBase
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
$json_74 .
$zts .
$this->makeExtensionArgs() . ' ' .
$this->configure_env
$this->makeExtensionArgs()
);
SourcePatcher::patchBeforeMake($this);
@ -231,12 +228,14 @@ class MacOSBuilder extends BuilderBase
/**
* Build phpmicro sapi
*
* @throws FileSystemException|RuntimeException
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function buildMicro(): void
{
if ($this->getPHPVersionID() < 80000) {
throw new RuntimeException('phpmicro only support PHP >= 8.0!');
throw new WrongUsageException('phpmicro only support PHP >= 8.0!');
}
if ($this->getExt('phar')) {
$this->phar_patched = true;
@ -285,6 +284,11 @@ class MacOSBuilder extends BuilderBase
$this->deployBinary(BUILD_TARGET_FPM);
}
/**
* Build embed sapi
*
* @throws RuntimeException
*/
public function buildEmbed(): void
{
$vars = SystemUtil::makeEnvVarString([

View File

@ -19,7 +19,7 @@ class glfw extends MacOSLibraryBase
{
// compile
shell()->cd(SOURCE_PATH . '/ext-glfw/vendor/glfw')
->exec("{$this->builder->configure_env} cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF")
->exec("cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF")
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
// patch pkgconf

View File

@ -12,7 +12,7 @@ class icu extends MacOSLibraryBase
{
$root = BUILD_ROOT_PATH;
shell()->cd($this->source_dir . '/source')
->exec("{$this->builder->configure_env} ./runConfigureICU MacOSX --enable-static --disable-shared --prefix={$root}")
->exec("./runConfigureICU MacOSX --enable-static --disable-shared --prefix={$root}")
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec('make install');

View File

@ -20,7 +20,7 @@ class libffi extends MacOSLibraryBase
[, , $destdir] = SEPARATED_PATH;
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
'./configure ' .
'--enable-static ' .
'--disable-shared ' .
"--host={$this->builder->getOption('arch')}-apple-darwin " .

View File

@ -18,7 +18,7 @@ class libmemcached extends MacOSLibraryBase
shell()->cd($this->source_dir)
->exec('chmod +x configure')
->exec(
"{$this->builder->configure_env} ./configure " .
'./configure ' .
'--enable-static --disable-shared ' .
'--disable-sasl ' .
"--prefix={$rootdir}"

View File

@ -44,7 +44,7 @@ class libpng extends MacOSLibraryBase
->exec('chmod +x ./configure')
->exec('chmod +x ./install-sh')
->exec(
"{$this->builder->configure_env} ./configure " .
'./configure ' .
"--host={$this->builder->getOption('gnu-arch')}-apple-darwin " .
'--disable-shared ' .
'--enable-static ' .

View File

@ -18,38 +18,27 @@ class libxml2 extends MacOSLibraryBase
*/
protected function build(): void
{
// macOS need to link iconv dynamically, we add it to extra-libs
$extra_libs = $this->builder->getOption('extra-libs', '');
if (!str_contains($extra_libs, '-liconv')) {
$extra_libs .= ' -liconv';
}
$this->builder->setOption('extra-libs', $extra_libs);
$enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF';
// $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
$enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF';
$enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF';
[, , $destdir] = SEPARATED_PATH;
FileSystem::resetDir($this->source_dir . '/build');
shell()->cd($this->source_dir . '/build')
->exec(
"{$this->builder->configure_env} " . ' cmake ' .
'cmake ' .
// '--debug-find ' .
'-DCMAKE_BUILD_TYPE=Release ' .
"{$this->builder->makeCmakeArgs()} " .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DLIBXML2_WITH_ICONV=ON ' .
"-DLIBXML2_WITH_ZLIB={$enable_zlib} " .
'-DLIBXML2_WITH_ICU=OFF ' .
"-DLIBXML2_WITH_ICU={$enable_icu} " .
"-DLIBXML2_WITH_LZMA={$enable_xz} " .
'-DLIBXML2_WITH_PYTHON=OFF ' .
'-DLIBXML2_WITH_PROGRAMS=OFF ' .
'-DLIBXML2_WITH_TESTS=OFF ' .
"-DCMAKE_INSTALL_PREFIX={$destdir} " .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
}
}

View File

@ -53,7 +53,7 @@ class nghttp2 extends MacOSLibraryBase
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} " . ' ./configure ' .
'./configure ' .
'--enable-static ' .
'--disable-shared ' .
"--host={$this->builder->getOption('gnu-arch')}-apple-darwin " .

View File

@ -48,7 +48,7 @@ class openssl extends MacOSLibraryBase
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./Configure no-shared {$extra} " .
"./Configure no-shared {$extra} " .
'--prefix=/ ' . // use prefix=/
"--libdir={$lib} " .
'--openssldir=/System/Library/OpenSSL ' .

View File

@ -21,9 +21,6 @@ trait UnixBuilderTrait
/** @var string cmake toolchain file */
public string $cmake_toolchain_file;
/** @var string configure environments */
public string $configure_env;
/**
* @throws WrongUsageException
* @throws FileSystemException
@ -145,12 +142,13 @@ trait UnixBuilderTrait
*/
public function makeCmakeArgs(): string
{
[$lib, $include] = SEPARATED_PATH;
$extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . $this->getOption('cc') . ' ' : '';
return $extra . '-DCMAKE_BUILD_TYPE=Release ' .
$extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . getenv('CC') . ' ' : '';
return $extra .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DCMAKE_INSTALL_PREFIX=/ ' .
"-DCMAKE_INSTALL_LIBDIR={$lib} " .
"-DCMAKE_INSTALL_INCLUDEDIR={$include} " .
'-DCMAKE_INSTALL_BINDIR=/bin ' .
'-DCMAKE_INSTALL_LIBDIR=/lib ' .
'-DCMAKE_INSTALL_INCLUDEDIR=/include ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->cmake_toolchain_file}";
}

View File

@ -19,7 +19,7 @@ trait brotli
FileSystem::resetDir($this->source_dir . '/build-dir');
shell()->cd($this->source_dir . '/build-dir')
->exec(
$this->builder->configure_env . ' cmake ' .
'cmake ' .
"{$this->builder->makeCmakeArgs()} " .
'-DBUILD_SHARED_LIBS=OFF ' .
'..'

View File

@ -9,8 +9,8 @@ trait bzip2
protected function build(): void
{
shell()->cd($this->source_dir)
->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean")
->exec("make -j{$this->builder->concurrency} {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean")
->exec("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
->exec('cp libbz2.a ' . BUILD_LIB_PATH)
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
}

View File

@ -52,7 +52,7 @@ trait curl
// compile
shell()->cd($this->source_dir . '/build')
->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt')
->exec("{$this->builder->configure_env} cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..")
->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..")
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
// patch pkgconf

View File

@ -27,7 +27,7 @@ trait freetype
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
'./configure ' .
'--enable-static --disable-shared --without-harfbuzz --prefix= ' .
$suggested
)

View File

@ -17,7 +17,7 @@ trait gmp
{
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
'./configure ' .
'--enable-static --disable-shared ' .
'--prefix='
)

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
@ -16,23 +17,33 @@ trait imagemagick
*/
protected function build(): void
{
$extra = '--without-jxl --without-xml --without-zstd --without-x --disable-openmp ';
// libzip support
$extra .= $this->builder->getLib('libzip') ? '--with-zip ' : '--without-zip ';
// jpeg support
$extra .= $this->builder->getLib('libjpeg') ? '--with-jpeg ' : '';
// png support
$extra .= $this->builder->getLib('libpng') ? '--with-png ' : '';
// webp support
$extra .= $this->builder->getLib('libwebp') ? '--with-webp ' : '';
// zstd support
// $extra .= $this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ';
// freetype support
$extra .= $this->builder->getLib('freetype') ? '--with-freetype ' : '--without-freetype ';
// TODO: imagemagick build with bzip2 failed with bugs, we need to fix it in the future
$extra = '--without-jxl --without-x --disable-openmp --without-bzlib ';
$required_libs = '';
$optional_libs = [
'libzip' => 'zip',
'libjpeg' => 'jpeg',
'libpng' => 'png',
'libwebp' => 'webp',
'libxml2' => 'xml',
'zlib' => 'zlib',
'xz' => 'lzma',
'zstd' => 'zstd',
'freetype' => 'freetype',
];
foreach ($optional_libs as $lib => $option) {
$extra .= $this->builder->getLib($lib) ? "--with-{$option} " : "--without-{$option} ";
if ($this->builder->getLib($lib) instanceof LinuxLibraryBase) {
$required_libs .= ' ' . $this->builder->getLib($lib)->getStaticLibFiles();
}
}
$ldflags = $this instanceof LinuxLibraryBase ? ('LDFLAGS="-static" ') : '';
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
$ldflags .
"LIBS='{$required_libs}' " .
'./configure ' .
'--enable-static --disable-shared ' .
$extra .
'--prefix='

View File

@ -17,7 +17,6 @@ trait ldap
$alt .= $this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : '';
shell()->cd($this->source_dir)
->exec(
$this->builder->configure_env . ' ' .
$this->builder->makeAutoconfFlags(AUTOCONF_LDFLAGS | AUTOCONF_CPPFLAGS) .
' ./configure ' .
'--enable-static ' .

View File

@ -22,12 +22,7 @@ trait libavif
FileSystem::resetDir($this->source_dir . '/build');
// Start build
shell()->cd($this->source_dir . '/build')
->exec(
"{$this->builder->configure_env} cmake " .
$this->builder->makeCmakeArgs() . ' ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'..'
)
->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..")
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
// patch pkgconfig

View File

@ -21,7 +21,7 @@ trait libevent
// Start build
shell()->cd($this->source_dir . '/build')
->exec(
"{$this->builder->configure_env} cmake " .
'cmake ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .

View File

@ -12,7 +12,7 @@ trait libiconv
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
'./configure ' .
'--enable-static ' .
'--disable-shared ' .
'--prefix='

View File

@ -23,7 +23,7 @@ trait libjpeg
// Start build
shell()->cd($this->source_dir . '/build')
->exec(
"{$this->builder->configure_env} cmake {$this->builder->makeCmakeArgs()} " .
"cmake {$this->builder->makeCmakeArgs()} " .
'-DENABLE_STATIC=ON ' .
'-DENABLE_SHARED=OFF ' .
'..'

View File

@ -10,7 +10,7 @@ trait libsodium
{
$root = BUILD_ROOT_PATH;
shell()->cd($this->source_dir)
->exec("{$this->builder->configure_env} ./configure --enable-static --disable-shared --prefix={$root}")
->exec("./configure --enable-static --disable-shared --prefix={$root}")
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec('make install');

View File

@ -21,7 +21,7 @@ trait libssh2
FileSystem::resetDir($this->source_dir . '/build');
shell()->cd($this->source_dir . '/build')
->exec(
"{$this->builder->configure_env} " . ' cmake ' .
'cmake ' .
"{$this->builder->makeCmakeArgs()} " .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DBUILD_EXAMPLES=OFF ' .

View File

@ -23,7 +23,7 @@ trait libwebp
// Start build
shell()->cd($this->source_dir . '/build')
->exec(
"{$this->builder->configure_env} cmake " .
'cmake ' .
$this->builder->makeCmakeArgs() . ' ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DWEBP_BUILD_EXTRAS=ON ' .

View File

@ -4,20 +4,34 @@ declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
trait libxslt
{
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void
{
$required_libs = '';
foreach ($this->getDependencies() as $dep) {
if ($dep instanceof LinuxLibraryBase) {
$required_libs .= ' ' . $dep->getStaticLibFiles();
}
}
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" ' .
"{$this->builder->getOption('library_path')} " .
"{$this->builder->getOption('ld_library_path')} " .
'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' .
"LIBS='{$required_libs} -lstdc++' " .
'./configure ' .
'--enable-static --disable-shared ' .
'--without-python ' .
'--without-mem-debug ' .

View File

@ -60,7 +60,7 @@ EOF
FileSystem::resetDir($this->source_dir . '/build');
shell()->cd($this->source_dir . '/build')
->exec(
"{$this->builder->configure_env} cmake " .
'cmake ' .
// '--debug-find ' .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_TESTING=OFF ' .

View File

@ -29,7 +29,7 @@ trait libzip
FileSystem::resetDir($this->source_dir . '/build');
shell()->cd($this->source_dir . '/build')
->exec(
"{$this->builder->configure_env} " . ' cmake ' .
'cmake ' .
"{$this->builder->makeCmakeArgs()} " .
'-DENABLE_GNUTLS=OFF ' .
'-DENABLE_MBEDTLS=OFF ' .

View File

@ -10,7 +10,7 @@ trait ncurses
{
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
'./configure ' .
'--enable-static ' .
'--disable-shared ' .
'--enable-overwrite ' .

View File

@ -18,12 +18,7 @@ trait onig
[,,$destdir] = SEPARATED_PATH;
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} " . ' ./configure ' .
'--enable-static ' .
'--disable-shared ' .
'--prefix='
)
->exec('./configure --enable-static --disable-shared --prefix=')
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec("make install DESTDIR={$destdir}");

View File

@ -8,13 +8,8 @@ trait pkgconfig
{
protected function build(): void
{
$macos_env = 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig/" ' .
"CC='{$this->builder->getOption('cc')}' " .
"CXX='{$this->builder->getOption('cxx')}' " .
"CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration' ";
$linux_env = 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig" ' .
"CC='{$this->builder->getOption('cc')}' " .
"CXX='{$this->builder->getOption('cxx')}' ";
$macos_env = "CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration' ";
$linux_env = 'LDFLAGS=--static ';
shell()->cd($this->source_dir)
->exec(

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
@ -18,25 +19,39 @@ trait postgresql
protected function build(): void
{
$builddir = BUILD_ROOT_PATH;
$env = $this->builder->configure_env;
$envs = $env;
$packages = 'openssl zlib readline libxml-2.0'; // icu-uc icu-io icu-i18n libzstd
$envs = '';
$packages = 'openssl zlib readline libxml-2.0 zlib';
$optional_packages = [
'zstd' => 'libzstd',
'ldap' => 'ldap',
'libpam' => 'libpam',
'libxslt' => 'libxslt',
'icu' => 'icu-i18n',
];
foreach ($optional_packages as $lib => $pkg) {
if ($this->getBuilder()->getLib($lib)) {
$packages .= ' ' . $pkg;
}
}
$pkgconfig_executable = $builddir . '/bin/pkg-config';
$output = shell()->execWithResult($env . " {$pkgconfig_executable} --cflags-only-I --static " . $packages);
$output = shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}");
if (!empty($output[1][0])) {
$cppflags = $output[1][0];
$envs .= " CPPFLAGS=\"{$cppflags}\"";
}
$output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-L --static " . $packages);
$output = shell()->execWithResult("pkg-config --libs-only-L --static {$packages}");
if (!empty($output[1][0])) {
$ldflags = $output[1][0];
$envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" ";
}
$output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-l --static " . $packages);
$output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}");
if (!empty($output[1][0])) {
$libs = $output[1][0];
$envs .= " LIBS=\"{$libs}\" ";
$libcpp = '';
if ($this->builder->getLib('icu')) {
$libcpp = $this instanceof LinuxLibraryBase ? ' -lstdc++' : ' -lc++';
}
$envs .= " LIBS=\"{$libs}{$libcpp}\" ";
}
FileSystem::resetDir($this->source_dir . '/build');
@ -44,7 +59,7 @@ trait postgresql
# 有静态链接配置 参考文件: src/interfaces/libpq/Makefile
shell()->cd($this->source_dir . '/build')
->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile')
->exec(' sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib')
->exec('sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib')
->exec('sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib');
// configure
@ -57,14 +72,14 @@ trait postgresql
'--with-ssl=openssl ' .
'--with-readline ' .
'--with-libxml ' .
($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') .
($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') .
'--without-libxslt ' .
($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') .
($this->builder->getLib('libpam') ? '--with-pam ' : '--without-pam ') .
($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') .
($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') .
'--without-lz4 ' .
'--without-zstd ' .
'--without-perl ' .
'--without-python ' .
'--without-pam ' .
'--without-bonjour ' .
'--without-tcl '
);

View File

@ -17,7 +17,7 @@ trait readline
{
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
'./configure ' .
'--enable-static=yes ' .
'--enable-shared=no ' .
'--prefix= ' .

View File

@ -20,15 +20,14 @@ trait snappy
shell()->cd($this->source_dir . '/cmake/build')
->exec(
"{$this->builder->configure_env} cmake " .
'cmake ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DCMAKE_INSTALL_PREFIX=' . escapeshellarg(BUILD_ROOT_PATH) . ' ' .
"{$this->builder->makeCmakeArgs()} " .
'-DSNAPPY_BUILD_TESTS=OFF ' .
'-DSNAPPY_BUILD_BENCHMARKS=OFF ' .
'../..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
}
}

View File

@ -9,7 +9,7 @@ trait sqlite
protected function build(): void
{
shell()->cd($this->source_dir)
->exec("{$this->builder->configure_env} ./configure --enable-static --disable-shared --prefix=")
->exec('./configure --enable-static --disable-shared --prefix=')
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);

View File

@ -17,7 +17,7 @@ trait xz
{
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
'./configure ' .
'--enable-static ' .
'--disable-shared ' .
"--host={$this->builder->getOption('gnu-arch')}-unknown-linux " .

View File

@ -18,7 +18,7 @@ trait zlib
[,,$destdir] = SEPARATED_PATH;
shell()->cd($this->source_dir)
->exec("{$this->builder->configure_env} ./configure --static --prefix=")
->exec('./configure --static --prefix=')
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec("make install DESTDIR={$destdir}");

View File

@ -19,7 +19,7 @@ trait zstd
FileSystem::resetDir($this->source_dir . '/build/cmake/build');
shell()->cd($this->source_dir . '/build/cmake/build')
->exec(
"{$this->builder->configure_env} cmake " .
'cmake ' .
"{$this->builder->makeCmakeArgs()} " .
'-DZSTD_BUILD_STATIC=ON ' .
'-DZSTD_BUILD_SHARED=OFF ' .

View File

@ -30,6 +30,7 @@ class BuildCliCommand extends BuildCommand
$this->addOption('build-all', null, null, 'build cli, micro, fpm, embed');
$this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions');
$this->addOption('enable-zts', null, null, 'enable ZTS support');
$this->addOption('disable-opcache-jit', null, null, 'disable opcache jit');
$this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI');
$this->addOption('with-micro-fake-cli', null, null, 'Enable phpmicro fake cli');
}

View File

@ -19,11 +19,11 @@ abstract class BuildCommand extends BaseCommand
$this->addOption('arch', null, InputOption::VALUE_REQUIRED, 'architecture, "x64" or "arm64"', 'x64');
break;
case 'Linux':
$this->addOption('no-system-static', null, null, 'do not use system static libraries');
// no break
case 'Darwin':
$this->addOption('cc', null, InputOption::VALUE_REQUIRED, 'C compiler');
$this->addOption('cxx', null, InputOption::VALUE_REQUIRED, 'C++ compiler');
$this->addOption('ar', null, InputOption::VALUE_REQUIRED, 'ar');
$this->addOption('ld', null, InputOption::VALUE_REQUIRED, 'ld');
$this->addOption('arch', null, InputOption::VALUE_REQUIRED, 'architecture', php_uname('m'));
break;
}

View File

@ -8,8 +8,8 @@ use SPC\doctor\CheckListHandler;
use SPC\doctor\CheckResult;
use SPC\exception\RuntimeException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use function Laravel\Prompts\confirm;
#[AsCommand('doctor', 'Diagnose whether the current environment can compile normally')]
class DoctorCommand extends BaseCommand
@ -49,9 +49,8 @@ class DoctorCommand extends BaseCommand
throw new RuntimeException('Some check items can not be fixed !');
case FIX_POLICY_PROMPT:
if ($result->getFixItem() !== '') {
$helper = new QuestionHelper();
$question = new ConfirmationQuestion('Do you want to fix it? [Y/n] ', true);
if ($helper->ask($this->input, $this->output, $question)) {
$question = confirm('Do you want to fix it?');
if ($question) {
$checker->emitFix($this->output, $result);
} else {
throw new RuntimeException('You cancelled fix');

View File

@ -59,7 +59,7 @@ class DownloadCommand extends BaseCommand
*/
public function handle(): int
{
// 删除旧资源
try {
if ($this->getOption('clean')) {
logger()->warning('You are doing some operations that not recoverable: removing directories below');
logger()->warning(SOURCE_PATH);
@ -104,13 +104,12 @@ class DownloadCommand extends BaseCommand
// use openssl 1.1
if ($this->getOption('with-openssl11')) {
logger()->debug('Using openssl 1.1');
// 手动修改配置
Config::$source['openssl']['regex'] = '/href="(?<file>openssl-(?<version>1.[^"]+)\.tar\.gz)\"/';
}
// --for-extensions
if ($by_ext = $this->getOption('for-extensions')) {
$ext = array_map('trim', array_filter(explode(',', $by_ext)));
if ($for_ext = $this->getOption('for-extensions')) {
$ext = array_map('trim', array_filter(explode(',', $for_ext)));
$sources = $this->calculateSourcesByExt($ext, !$this->getOption('without-suggestions'));
array_unshift($sources, 'php-src', 'micro', 'pkg-config');
} else {
@ -154,10 +153,16 @@ class DownloadCommand extends BaseCommand
Downloader::downloadSource($source, Config::getSource($source));
}
}
// 打印拉取资源用时
$time = round(microtime(true) - START_TIME, 3);
logger()->info('Download complete, used ' . $time . ' s !');
return static::SUCCESS;
} catch (DownloaderException $e) {
logger()->error($e->getMessage());
return static::FAILURE;
} catch (WrongUsageException $e) {
logger()->critical($e->getMessage());
return static::FAILURE;
}
}
private function downloadFromZip(string $path): int

View File

@ -14,6 +14,8 @@ use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Style\SymfonyStyle;
use function Laravel\Prompts\table;
#[AsCommand('dev:extensions', 'Helper command that lists available extension details', ['list-ext'])]
class AllExtCommand extends BaseCommand
{
@ -62,7 +64,7 @@ class AllExtCommand extends BaseCommand
if ($data === []) {
$style->warning('Unknown extension selected: ' . implode(',', $extensions));
} else {
$style->table(
table(
['Extension', 'lib-depends', 'lib-suggests', 'ext-depends', 'ext-suggests', 'unix-only'],
$data
);

View File

@ -8,54 +8,105 @@ use SPC\builder\linux\SystemUtil;
use SPC\doctor\AsCheckItem;
use SPC\doctor\AsFixItem;
use SPC\doctor\CheckResult;
use SPC\exception\DownloaderException;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Downloader;
use SPC\store\FileSystem;
class LinuxMuslCheck
{
/** @noinspection PhpUnused */
#[AsCheckItem('if musl-libc is installed', limit_os: 'Linux')]
public function checkMusl(): ?CheckResult
#[AsCheckItem('if musl-wrapper is installed', limit_os: 'Linux', level: 800)]
public function checkMusl(): CheckResult
{
$file = sprintf('/lib/ld-musl-%s.so.1', php_uname('m'));
if (file_exists($file)) {
if (SystemUtil::isMuslDist()) {
return CheckResult::ok('musl-based distro, skipped');
}
$musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m'));
if (file_exists($musl_wrapper_lib) && file_exists('/usr/local/musl/lib/libc.a')) {
return CheckResult::ok();
}
// non-exist, need to recognize distro
$distro = SystemUtil::getOSRelease();
return match ($distro['dist']) {
'ubuntu', 'alpine', 'debian', 'rhel', 'almalinux' => CheckResult::fail('musl-libc is not installed on your system', 'fix-musl', [$distro]),
default => CheckResult::fail('musl-libc is not installed on your system'),
};
return CheckResult::fail('musl-wrapper is not installed on your system', 'fix-musl-wrapper');
}
/**
* @throws RuntimeException
* @noinspection PhpUnused
*/
#[AsFixItem('fix-musl')]
public function fixMusl(array $distro): bool
#[AsCheckItem('if musl-cross-make is installed', limit_os: 'Linux', level: 799)]
public function checkMuslCrossMake(): CheckResult
{
$rhel_install = 'wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && \
rm -f musl-1.2.4.tar.gz && cd musl-1.2.4 &&
if [[ ! "$PATH" =~ (^|:)"/usr/local/musl/bin"(:|$) ]]; then echo "export PATH=/usr/local/musl/bin:$PATH" >> ~/.bash_profile
fi && \
./configure --enable-wrapper=gcc && \
make -j && make install && cd .. && rm -rf musl-1.2.4';
$install_cmd = match ($distro['dist']) {
'ubuntu', 'debian' => 'apt-get install musl musl-tools -y',
'alpine' => 'apk add musl musl-utils musl-dev',
'rhel' => $rhel_install,
'almalinux' => $rhel_install,
default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'),
};
if (SystemUtil::isMuslDist()) {
return CheckResult::ok('musl-based distro, skipped');
}
$arch = arch2gnu(php_uname('m'));
$cross_compile_lib = "/usr/local/musl/{$arch}-linux-musl/lib/libc.a";
$cross_compile_gcc = "/usr/local/musl/bin/{$arch}-linux-musl-gcc";
if (file_exists($cross_compile_lib) && file_exists($cross_compile_gcc)) {
return CheckResult::ok();
}
return CheckResult::fail('musl-cross-make is not installed on your system', 'fix-musl-cross-make');
}
/** @noinspection PhpUnused */
/**
* @throws DownloaderException
* @throws FileSystemException
*/
#[AsFixItem('fix-musl-wrapper')]
public function fixMusl(): bool
{
try {
$prefix = '';
if (get_current_user() !== 'root') {
$prefix = 'sudo ';
logger()->warning('Current user is not root, using sudo for running command');
}
// The hardcoded version here is to be consistent with the version compiled by `musl-cross-toolchain`.
$musl_version_name = 'musl-1.2.4';
$musl_source = [
'type' => 'url',
'url' => "https://musl.libc.org/releases/{$musl_version_name}.tar.gz",
];
logger()->info('Downloading ' . $musl_source['url']);
Downloader::downloadSource($musl_version_name, $musl_source);
FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz");
logger()->info('Installing musl wrapper');
shell()->cd(SOURCE_PATH . "/{$musl_version_name}")
->exec('./configure --disable-gcc-wrapper')
->exec('make -j')
->exec("{$prefix}make install");
// TODO: add path using putenv instead of editing /etc/profile
return true;
} catch (RuntimeException) {
return false;
}
}
/** @noinspection PhpUnused */
/**
* @throws DownloaderException
* @throws FileSystemException
* @throws WrongUsageException
*/
#[AsFixItem('fix-musl-cross-make')]
public function fixMuslCrossMake(): bool
{
try {
shell(true)->exec($prefix . $install_cmd);
$prefix = '';
if (get_current_user() !== 'root') {
$prefix = 'sudo ';
logger()->warning('Current user is not root, using sudo for running command');
}
$arch = arch2gnu(php_uname('m'));
$musl_compile_source = [
'type' => 'url',
'url' => "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/{$arch}-musl-toolchain.tgz",
];
logger()->info('Downloading ' . $musl_compile_source['url']);
Downloader::downloadSource('musl-compile', $musl_compile_source);
logger()->info('Extracting musl-cross');
FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-musl-toolchain.tgz");
shell()->exec($prefix . 'cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl');
return true;
} catch (RuntimeException) {
return false;

View File

@ -20,7 +20,7 @@ class LinuxToolCheckList
'git', 'autoconf', 'automake',
'tar', 'unzip', 'gzip',
'bzip2', 'cmake', 'gcc',
'g++', 'patch',
'g++', 'patch', 'binutils-gold',
];
public const TOOLS_DEBIAN = [

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace SPC\doctor\item;
use SPC\builder\linux\SystemUtil;
use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\doctor\AsCheckItem;
use SPC\doctor\CheckResult;
@ -18,6 +19,7 @@ class OSCheckList
if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) {
return CheckResult::fail('Current OS is not supported');
}
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . ', supported');
$distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : '';
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported');
}
}

View File

@ -261,10 +261,13 @@ class Downloader
if ($source === null) {
logger()->warning('Source {name} unknown. Skipping.', ['name' => $name]);
return;
}
if (!is_dir(DOWNLOAD_PATH)) {
FileSystem::createDir(DOWNLOAD_PATH);
}
// load lock file
if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) {
$lock = [];
@ -332,7 +335,7 @@ class Downloader
logger()->warning('Deleting download file: ' . $filename);
unlink(DOWNLOAD_PATH . '/' . $filename);
}
throw $e;
throw new DownloaderException('Download failed! ' . $e->getMessage());
}
}

View File

@ -152,6 +152,9 @@ class FileSystem
if (self::$_extract_hook === []) {
SourcePatcher::init();
}
if (!is_dir(SOURCE_PATH)) {
self::createDir(SOURCE_PATH);
}
if ($move_path !== null) {
$move_path = SOURCE_PATH . '/' . $move_path;
}

View File

@ -13,8 +13,8 @@ define('START_TIME', microtime(true));
define('BUILD_ROOT_PATH', is_string($a = getenv('BUILD_ROOT_PATH')) ? $a : (WORKING_DIR . '/buildroot'));
define('SOURCE_PATH', is_string($a = getenv('SOURCE_PATH')) ? $a : (WORKING_DIR . '/source'));
define('DOWNLOAD_PATH', is_string($a = getenv('DOWNLOAD_PATH')) ? $a : (WORKING_DIR . '/downloads'));
define('BUILD_BIN_PATH', is_string($a = getenv('INSTALL_BIN_PATH')) ? $a : (BUILD_ROOT_PATH . '/bin'));
define('BUILD_LIB_PATH', is_string($a = getenv('INSTALL_LIB_PATH')) ? $a : (BUILD_ROOT_PATH . '/lib'));
const BUILD_DEPS_PATH = BUILD_ROOT_PATH;
define('BUILD_INCLUDE_PATH', is_string($a = getenv('INSTALL_INCLUDE_PATH')) ? $a : (BUILD_ROOT_PATH . '/include'));
define('SEPARATED_PATH', [
'/' . pathinfo(BUILD_LIB_PATH)['basename'], // lib

View File

@ -110,6 +110,12 @@ function f_mkdir(string $directory, int $permissions = 0777, bool $recursive = f
return mkdir($directory, $permissions, $recursive);
}
function f_putenv(string $env): bool
{
logger()->debug('Setting env: ' . $env);
return putenv($env);
}
function shell(?bool $debug = null): UnixShell
{
return new UnixShell($debug);

View File

@ -17,6 +17,8 @@ final class CheckListHandlerTest extends TestCase
$list = new CheckListHandler();
$id = $list->runChecks();
$this->assertCount(7, $id);
foreach ($id as $item) {
$this->assertInstanceOf('SPC\doctor\AsCheckItem', $item);
}
}
}