├── .github ├── FUNDING.yml ├── pull_request_template.md └── workflows │ ├── build-linux-arm.yml │ ├── build-linux-x86_64.yml │ ├── build-macos-aarch64.yml │ ├── build-macos-x86_64.yml │ ├── build-windows-x86_64.yml │ ├── release-build.yml │ ├── tests.yml │ └── vitepress-deploy.yml ├── .gitignore ├── .php-cs-fixer.php ├── LICENSE ├── README-en.md ├── README-zh.md ├── README.md ├── bin ├── setup-runtime ├── setup-runtime.ps1 ├── spc ├── spc-alpine-docker └── spc.ps1 ├── box.json ├── captainhook.json ├── composer.json ├── composer.lock ├── config ├── ext.json ├── lib.json ├── pkg.json ├── pre-built.json └── source.json ├── docs ├── .vitepress │ ├── components │ │ ├── CliGenerator.vue │ │ └── DependencyUtil.js │ ├── config.ts │ ├── sidebar.en.ts │ ├── sidebar.zh.ts │ └── theme │ │ └── index.ts ├── deps-map-ext.md ├── deps-map-lib.md ├── en │ ├── contributing │ │ └── index.md │ ├── develop │ │ ├── doctor-module.md │ │ ├── index.md │ │ ├── php-src-changes.md │ │ ├── source-module.md │ │ ├── structure.md │ │ └── system-build-tools.md │ ├── faq │ │ └── index.md │ ├── guide │ │ ├── action-build.md │ │ ├── build-on-windows.md │ │ ├── cli-generator.md │ │ ├── deps-map.md │ │ ├── env-vars.md │ │ ├── extension-notes.md │ │ ├── extensions.md │ │ ├── index.md │ │ ├── manual-build.md │ │ └── troubleshooting.md │ └── index.md ├── extension-notes.md ├── extensions.md ├── index.md ├── public │ └── CNAME └── zh │ ├── contributing │ └── index.md │ ├── develop │ ├── doctor-module.md │ ├── index.md │ ├── php-src-changes.md │ ├── source-module.md │ ├── structure.md │ └── system-build-tools.md │ ├── faq │ └── index.md │ ├── guide │ ├── action-build.md │ ├── build-on-windows.md │ ├── cli-generator.md │ ├── deps-map.md │ ├── env-vars.md │ ├── extension-notes.md │ ├── extensions.md │ ├── index.md │ ├── manual-build.md │ └── troubleshooting.md │ └── index.md ├── ext-support.md ├── package.json ├── phpstan.neon ├── src ├── SPC │ ├── ConsoleApplication.php │ ├── builder │ │ ├── BuilderBase.php │ │ ├── BuilderProvider.php │ │ ├── Extension.php │ │ ├── LibraryBase.php │ │ ├── LibraryInterface.php │ │ ├── extension │ │ │ ├── amqp.php │ │ │ ├── bz2.php │ │ │ ├── curl.php │ │ │ ├── dba.php │ │ │ ├── enchant.php │ │ │ ├── event.php │ │ │ ├── ffi.php │ │ │ ├── gd.php │ │ │ ├── gettext.php │ │ │ ├── glfw.php │ │ │ ├── gmssl.php │ │ │ ├── iconv.php │ │ │ ├── imagick.php │ │ │ ├── imap.php │ │ │ ├── intl.php │ │ │ ├── ldap.php │ │ │ ├── mbregex.php │ │ │ ├── mbstring.php │ │ │ ├── memcache.php │ │ │ ├── memcached.php │ │ │ ├── mongodb.php │ │ │ ├── opcache.php │ │ │ ├── openssl.php │ │ │ ├── parallel.php │ │ │ ├── password_argon2.php │ │ │ ├── pdo_sqlite.php │ │ │ ├── pgsql.php │ │ │ ├── protobuf.php │ │ │ ├── rar.php │ │ │ ├── readline.php │ │ │ ├── redis.php │ │ │ ├── simdjson.php │ │ │ ├── snappy.php │ │ │ ├── sodium.php │ │ │ ├── spx.php │ │ │ ├── sqlsrv.php │ │ │ ├── ssh2.php │ │ │ ├── swoole.php │ │ │ ├── swoole_hook_mysql.php │ │ │ ├── swoole_hook_pgsql.php │ │ │ ├── swoole_hook_sqlite.php │ │ │ ├── swow.php │ │ │ ├── uv.php │ │ │ ├── xhprof.php │ │ │ ├── xlswriter.php │ │ │ ├── xml.php │ │ │ ├── yac.php │ │ │ ├── zlib.php │ │ │ └── zstd.php │ │ ├── freebsd │ │ │ ├── BSDBuilder.php │ │ │ ├── SystemUtil.php │ │ │ └── library │ │ │ │ ├── BSDLibraryBase.php │ │ │ │ ├── bzip2.php │ │ │ │ ├── curl.php │ │ │ │ ├── onig.php │ │ │ │ ├── openssl.php │ │ │ │ ├── pkgconfig.php │ │ │ │ └── zlib.php │ │ ├── linux │ │ │ ├── LinuxBuilder.php │ │ │ ├── SystemUtil.php │ │ │ └── library │ │ │ │ ├── LinuxLibraryBase.php │ │ │ │ ├── brotli.php │ │ │ │ ├── bzip2.php │ │ │ │ ├── curl.php │ │ │ │ ├── freetype.php │ │ │ │ ├── gettext.php │ │ │ │ ├── gmp.php │ │ │ │ ├── gmssl.php │ │ │ │ ├── icu.php │ │ │ │ ├── imagemagick.php │ │ │ │ ├── imap.php │ │ │ │ ├── ldap.php │ │ │ │ ├── libargon2.php │ │ │ │ ├── libavif.php │ │ │ │ ├── libcares.php │ │ │ │ ├── libevent.php │ │ │ │ ├── libffi.php │ │ │ │ ├── libiconv.php │ │ │ │ ├── libjpeg.php │ │ │ │ ├── liblz4.php │ │ │ │ ├── libmemcached.php │ │ │ │ ├── libpng.php │ │ │ │ ├── librabbitmq.php │ │ │ │ ├── libsodium.php │ │ │ │ ├── libssh2.php │ │ │ │ ├── libtiff.php │ │ │ │ ├── libuuid.php │ │ │ │ ├── libuv.php │ │ │ │ ├── libwebp.php │ │ │ │ ├── libxml2.php │ │ │ │ ├── libxslt.php │ │ │ │ ├── libyaml.php │ │ │ │ ├── libzip.php │ │ │ │ ├── ncurses.php │ │ │ │ ├── nghttp2.php │ │ │ │ ├── onig.php │ │ │ │ ├── openssl.php │ │ │ │ ├── pkgconfig.php │ │ │ │ ├── postgresql.php │ │ │ │ ├── qdbm.php │ │ │ │ ├── readline.php │ │ │ │ ├── snappy.php │ │ │ │ ├── sqlite.php │ │ │ │ ├── tidy.php │ │ │ │ ├── unixodbc.php │ │ │ │ ├── xz.php │ │ │ │ ├── zlib.php │ │ │ │ └── zstd.php │ │ ├── macos │ │ │ ├── MacOSBuilder.php │ │ │ ├── SystemUtil.php │ │ │ └── library │ │ │ │ ├── MacOSLibraryBase.php │ │ │ │ ├── brotli.php │ │ │ │ ├── bzip2.php │ │ │ │ ├── curl.php │ │ │ │ ├── freetype.php │ │ │ │ ├── gettext.php │ │ │ │ ├── glfw.php │ │ │ │ ├── gmp.php │ │ │ │ ├── gmssl.php │ │ │ │ ├── icu.php │ │ │ │ ├── imagemagick.php │ │ │ │ ├── imap.php │ │ │ │ ├── ldap.php │ │ │ │ ├── libargon2.php │ │ │ │ ├── libavif.php │ │ │ │ ├── libcares.php │ │ │ │ ├── libevent.php │ │ │ │ ├── libffi.php │ │ │ │ ├── libiconv.php │ │ │ │ ├── libjpeg.php │ │ │ │ ├── liblz4.php │ │ │ │ ├── libmemcached.php │ │ │ │ ├── libpng.php │ │ │ │ ├── librabbitmq.php │ │ │ │ ├── libsodium.php │ │ │ │ ├── libssh2.php │ │ │ │ ├── libtiff.php │ │ │ │ ├── libuuid.php │ │ │ │ ├── libuv.php │ │ │ │ ├── libwebp.php │ │ │ │ ├── libxml2.php │ │ │ │ ├── libxslt.php │ │ │ │ ├── libyaml.php │ │ │ │ ├── libzip.php │ │ │ │ ├── ncurses.php │ │ │ │ ├── nghttp2.php │ │ │ │ ├── onig.php │ │ │ │ ├── openssl.php │ │ │ │ ├── pkgconfig.php │ │ │ │ ├── postgresql.php │ │ │ │ ├── qdbm.php │ │ │ │ ├── readline.php │ │ │ │ ├── snappy.php │ │ │ │ ├── sqlite.php │ │ │ │ ├── tidy.php │ │ │ │ ├── unixodbc.php │ │ │ │ ├── xz.php │ │ │ │ ├── zlib.php │ │ │ │ └── zstd.php │ │ ├── traits │ │ │ ├── UnixLibraryTrait.php │ │ │ └── UnixSystemUtilTrait.php │ │ ├── unix │ │ │ ├── UnixBuilderBase.php │ │ │ └── library │ │ │ │ ├── brotli.php │ │ │ │ ├── bzip2.php │ │ │ │ ├── curl.php │ │ │ │ ├── freetype.php │ │ │ │ ├── gettext.php │ │ │ │ ├── gmp.php │ │ │ │ ├── gmssl.php │ │ │ │ ├── icu.php │ │ │ │ ├── imagemagick.php │ │ │ │ ├── ldap.php │ │ │ │ ├── libargon2.php │ │ │ │ ├── libavif.php │ │ │ │ ├── libcares.php │ │ │ │ ├── libevent.php │ │ │ │ ├── libiconv.php │ │ │ │ ├── libjpeg.php │ │ │ │ ├── liblz4.php │ │ │ │ ├── librabbitmq.php │ │ │ │ ├── libsodium.php │ │ │ │ ├── libssh2.php │ │ │ │ ├── libtiff.php │ │ │ │ ├── libuuid.php │ │ │ │ ├── libuv.php │ │ │ │ ├── libwebp.php │ │ │ │ ├── libxslt.php │ │ │ │ ├── libyaml.php │ │ │ │ ├── libzip.php │ │ │ │ ├── ncurses.php │ │ │ │ ├── nghttp2.php │ │ │ │ ├── onig.php │ │ │ │ ├── pkgconfig.php │ │ │ │ ├── postgresql.php │ │ │ │ ├── qdbm.php │ │ │ │ ├── readline.php │ │ │ │ ├── snappy.php │ │ │ │ ├── sqlite.php │ │ │ │ ├── tidy.php │ │ │ │ ├── unixodbc.php │ │ │ │ ├── xz.php │ │ │ │ ├── zlib.php │ │ │ │ └── zstd.php │ │ └── windows │ │ │ ├── SystemUtil.php │ │ │ ├── WindowsBuilder.php │ │ │ └── library │ │ │ ├── WindowsLibraryBase.php │ │ │ ├── bzip2.php │ │ │ ├── curl.php │ │ │ ├── freetype.php │ │ │ ├── gmssl.php │ │ │ ├── libavif.php │ │ │ ├── libffi_win.php │ │ │ ├── libiconv_win.php │ │ │ ├── libjpeg.php │ │ │ ├── libpng.php │ │ │ ├── librabbitmq.php │ │ │ ├── libssh2.php │ │ │ ├── libwebp.php │ │ │ ├── libxml2.php │ │ │ ├── libyaml.php │ │ │ ├── libzip.php │ │ │ ├── nghttp2.php │ │ │ ├── onig.php │ │ │ ├── openssl.php │ │ │ ├── pthreads4w.php │ │ │ ├── qdbm.php │ │ │ ├── sqlite.php │ │ │ ├── xz.php │ │ │ └── zlib.php │ ├── command │ │ ├── BaseCommand.php │ │ ├── BuildCliCommand.php │ │ ├── BuildCommand.php │ │ ├── BuildLibsCommand.php │ │ ├── DeleteDownloadCommand.php │ │ ├── DoctorCommand.php │ │ ├── DownloadCommand.php │ │ ├── DumpLicenseCommand.php │ │ ├── ExtractCommand.php │ │ ├── InstallPkgCommand.php │ │ ├── MicroCombineCommand.php │ │ ├── SwitchPhpVersionCommand.php │ │ └── dev │ │ │ ├── AllExtCommand.php │ │ │ ├── ExtVerCommand.php │ │ │ ├── GenerateExtDepDocsCommand.php │ │ │ ├── GenerateExtDocCommand.php │ │ │ ├── GenerateLibDepDocsCommand.php │ │ │ ├── LibVerCommand.php │ │ │ ├── PackLibCommand.php │ │ │ ├── PhpVerCommand.php │ │ │ └── SortConfigCommand.php │ ├── doctor │ │ ├── AsCheckItem.php │ │ ├── AsFixItem.php │ │ ├── CheckListHandler.php │ │ ├── CheckResult.php │ │ └── item │ │ │ ├── BSDToolCheckList.php │ │ │ ├── LinuxMuslCheck.php │ │ │ ├── LinuxToolCheckList.php │ │ │ ├── MacOSToolCheckList.php │ │ │ ├── OSCheckList.php │ │ │ └── WindowsToolCheckList.php │ ├── exception │ │ ├── DownloaderException.php │ │ ├── ExceptionHandler.php │ │ ├── FileSystemException.php │ │ ├── InvalidArgumentException.php │ │ ├── RuntimeException.php │ │ ├── ValidationException.php │ │ └── WrongUsageException.php │ ├── store │ │ ├── Config.php │ │ ├── CurlHook.php │ │ ├── Downloader.php │ │ ├── FileSystem.php │ │ ├── PackageManager.php │ │ ├── SourceManager.php │ │ ├── SourcePatcher.php │ │ └── source │ │ │ ├── CustomSourceBase.php │ │ │ ├── PhpSource.php │ │ │ └── PostgreSQLSource.php │ └── util │ │ ├── ConfigValidator.php │ │ ├── CustomExt.php │ │ ├── DependencyUtil.php │ │ ├── GlobalEnvManager.php │ │ ├── LicenseDumper.php │ │ ├── UnixShell.php │ │ └── WindowsCmd.php └── globals │ ├── common-tests │ └── micro_zend_mm_heap_corrupted.txt │ ├── defines.php │ ├── ext-tests │ ├── bcmath.php │ ├── bz2.php │ ├── calendar.php │ ├── curl.php │ ├── dom.php │ ├── filter.php │ ├── gd.php │ ├── gettext.php │ ├── gmssl.php │ ├── iconv.php │ ├── intl.php │ ├── msgpack.php │ ├── openssl.php │ ├── parallel.php │ ├── redis.php │ ├── swoole.php │ ├── uuid.php │ ├── zip.php │ └── zlib.php │ ├── extra │ ├── Makefile-sqlite │ ├── gd_config_80.w32 │ ├── gd_config_81.w32 │ ├── libcares_dnsinfo.h │ ├── libyaml_config.h.in │ ├── libyaml_yamlConfig.cmake.in │ └── micro-triple-Makefile.frag │ ├── functions.php │ ├── patch │ ├── 0001_imap_macos.patch │ ├── spc_fix_alpine_build_php80.patch │ ├── spc_fix_libxml2_12_php80.patch │ ├── spc_fix_libxml2_12_php81.patch │ ├── spc_fix_static_opcache_before_80222.patch │ ├── spc_fix_static_opcache_before_80310.patch │ └── spc_fix_swoole_50513.patch │ └── test-extensions.php ├── tests └── SPC │ ├── doctor │ └── CheckListHandlerTest.php │ ├── globals │ └── GlobalFunctionsTest.php │ ├── store │ ├── ConfigTest.php │ └── FileSystemTest.php │ └── util │ ├── ConfigValidatorTest.php │ ├── DependencyUtilTest.php │ └── LicenseDumperTest.php └── yarn.lock /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: crazywhalecc # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | # noinspection YAMLSchemaValidation 14 | buy_me_a_coffee: # crazywhalecc 15 | custom: 'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 16 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## What does this PR do? 2 | 3 | 4 | 5 | ## Checklist before merging 6 | 7 | > If your PR involves the changes mentioned below and completed the action, please tick the corresponding option. 8 | > If a modification is not involved, please skip it directly. 9 | 10 | - [ ] If it's an extension or dependency update, make sure adding related extensions in `src/global/test-extensions.php`. 11 | - [ ] If you changed the behavior of static-php-cli, update docs in `./docs/`. 12 | - [ ] If you updated `config/xxx.json` content, run `bin/spc dev:sort-config xxx`. 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | runtime/ 3 | docker/libraries/ 4 | docker/extensions/ 5 | docker/source/ 6 | 7 | # Vendor files 8 | /vendor/ 9 | 10 | # default source extract directory 11 | /source/ 12 | 13 | # default source download directory 14 | /downloads/ 15 | 16 | # default source build root directory 17 | /buildroot/ 18 | 19 | # default package root directory 20 | /pkgroot/ 21 | 22 | # default pack:lib and release directory 23 | /dist/ 24 | packlib_files.txt 25 | 26 | # tools cache files 27 | .php-cs-fixer.cache 28 | .phpunit.result.cache 29 | 30 | # exclude self-runtime 31 | /bin/* 32 | !/bin/spc* 33 | !/bin/setup-runtime* 34 | !/bin/spc-alpine-docker 35 | 36 | # exclude windows build tools 37 | /php-sdk-binary-tools/ 38 | 39 | # default test directory 40 | /tests/var/ 41 | 42 | # VitePress 43 | /node_modules/ 44 | /docs/.vitepress/dist/ 45 | /docs/.vitepress/cache/ 46 | package-lock.json 47 | pnpm-lock.yaml 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-2023 Jerry Ma 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README-en.md: -------------------------------------------------------------------------------- 1 | # static-php-cli 2 | 3 | English README has been moved to [README.md](README.md). 4 | -------------------------------------------------------------------------------- /bin/spc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run(); 22 | } catch (Exception $e) { 23 | ExceptionHandler::getInstance()->handle($e); 24 | exit(1); 25 | } 26 | -------------------------------------------------------------------------------- /bin/spc.ps1: -------------------------------------------------------------------------------- 1 | $PHP_Exec = ".\runtime\php.exe" 2 | 3 | if (-not(Test-Path $PHP_Exec)) { 4 | $PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition 5 | if (-not $PHP_Exec) { 6 | Write-Host "Error: PHP not found, you need to install PHP on your system or use 'bin/setup-runtime'." -ForegroundColor Red 7 | exit 1 8 | } 9 | } 10 | 11 | & "$PHP_Exec" ("bin/spc") @args 12 | exit $LASTEXITCODE 13 | -------------------------------------------------------------------------------- /box.json: -------------------------------------------------------------------------------- 1 | { 2 | "alias": "spc-php.phar", 3 | "banner": false, 4 | "blacklist": [ 5 | ".github" 6 | ], 7 | "compression": "GZ", 8 | "directories": [ 9 | "config", 10 | "src", 11 | "vendor/psr", 12 | "vendor/laravel/prompts", 13 | "vendor/illuminate", 14 | "vendor/symfony", 15 | "vendor/zhamao" 16 | ], 17 | "git-commit-short": "git_commit_short", 18 | "output": "spc.phar" 19 | } 20 | -------------------------------------------------------------------------------- /captainhook.json: -------------------------------------------------------------------------------- 1 | { 2 | "pre-push": { 3 | "enabled": true, 4 | "actions": [ 5 | { 6 | "action": "composer analyse" 7 | } 8 | ] 9 | }, 10 | "pre-commit": { 11 | "enabled": true, 12 | "actions": [ 13 | { 14 | "action": "composer cs-fix -- --config=.php-cs-fixer.php --dry-run --diff {$STAGED_FILES|of-type:php}", 15 | "conditions": [ 16 | { 17 | "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType", 18 | "args": ["php"] 19 | } 20 | ] 21 | } 22 | ] 23 | }, 24 | "post-change": { 25 | "enabled": true, 26 | "actions": [ 27 | { 28 | "action": "composer install", 29 | "options": [], 30 | "conditions": [ 31 | { 32 | "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any", 33 | "args": [ 34 | [ 35 | "composer.json", 36 | "composer.lock" 37 | ] 38 | ] 39 | } 40 | ] 41 | } 42 | ] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /config/pkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "musl-toolchain-aarch64-linux": { 3 | "type": "url", 4 | "url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/aarch64-musl-toolchain.tgz" 5 | }, 6 | "musl-toolchain-x86_64-linux": { 7 | "type": "url", 8 | "url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/x86_64-musl-toolchain.tgz" 9 | }, 10 | "nasm-x86_64-win": { 11 | "type": "url", 12 | "url": "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip", 13 | "extract-files": { 14 | "nasm-2.16.01/nasm.exe": "{php_sdk_path}/bin/nasm.exe", 15 | "nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe" 16 | } 17 | }, 18 | "strawberry-perl-x86_64-win": { 19 | "type": "url", 20 | "url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip" 21 | }, 22 | "upx-aarch64-linux": { 23 | "type": "ghrel", 24 | "repo": "upx/upx", 25 | "match": "upx.+-arm64_linux\\.tar\\.xz", 26 | "extract-files": { 27 | "upx": "{pkg_root_path}/bin/upx" 28 | } 29 | }, 30 | "upx-x86_64-linux": { 31 | "type": "ghrel", 32 | "repo": "upx/upx", 33 | "match": "upx.+-amd64_linux\\.tar\\.xz", 34 | "extract-files": { 35 | "upx": "{pkg_root_path}/bin/upx" 36 | } 37 | }, 38 | "upx-x86_64-win": { 39 | "type": "ghrel", 40 | "repo": "upx/upx", 41 | "match": "upx.+-win64\\.zip", 42 | "extract-files": { 43 | "upx-*-win64/upx.exe": "{pkg_root_path}/bin/upx.exe" 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /config/pre-built.json: -------------------------------------------------------------------------------- 1 | { 2 | "repo": "static-php/static-php-cli-hosted", 3 | "prefer-stable": true, 4 | "match-pattern": "{name}-{arch}-{os}.txz", 5 | "suffix": "txz" 6 | } -------------------------------------------------------------------------------- /docs/.vitepress/config.ts: -------------------------------------------------------------------------------- 1 | import sidebarEn from "./sidebar.en"; 2 | import sidebarZh from "./sidebar.zh"; 3 | 4 | 5 | // https://vitepress.dev/reference/site-config 6 | export default { 7 | title: "static-php-cli", 8 | description: "Build single static PHP binary, with PHP project together, with popular extensions included.", 9 | locales: { 10 | en: { 11 | label: 'English', 12 | lang: 'en', 13 | themeConfig: { 14 | nav: [ 15 | {text: 'Guide', link: '/en/guide/',}, 16 | {text: 'Advanced', link: '/en/develop/'}, 17 | {text: 'Contributing', link: '/en/contributing/'}, 18 | {text: 'FAQ', link: '/en/faq/'}, 19 | ], 20 | sidebar: sidebarEn, 21 | footer: { 22 | message: 'Released under the MIT License.', 23 | copyright: 'Copyright © 2023-present crazywhalecc' 24 | } 25 | }, 26 | }, 27 | zh: { 28 | label: '简体中文', 29 | lang: 'zh', // optional, will be added as `lang` attribute on `html` tag 30 | themeConfig: { 31 | nav: [ 32 | {text: '构建指南', link: '/zh/guide/'}, 33 | {text: '进阶', link: '/zh/develop/'}, 34 | {text: '贡献', link: '/zh/contributing/'}, 35 | {text: 'FAQ', link: '/zh/faq/'}, 36 | ], 37 | sidebar: sidebarZh, 38 | footer: { 39 | message: 'Released under the MIT License.', 40 | copyright: 'Copyright © 2023-present crazywhalecc' 41 | } 42 | }, 43 | } 44 | }, 45 | themeConfig: { 46 | // https://vitepress.dev/reference/default-theme-config 47 | nav: [], 48 | socialLinks: [ 49 | {icon: 'github', link: 'https://github.com/crazywhalecc/static-php-cli'} 50 | ] 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /docs/.vitepress/sidebar.zh.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | '/zh/guide/': [ 3 | { 4 | text: '构建指南', 5 | items: [ 6 | {text: '指南', link: '/zh/guide/'}, 7 | {text: 'Actions 构建', link: '/zh/guide/action-build'}, 8 | {text: '本地构建', link: '/zh/guide/manual-build'}, 9 | {text: '扩展列表', link: '/zh/guide/extensions'}, 10 | {text: '扩展注意事项', link: '/zh/guide/extension-notes'}, 11 | {text: '编译命令生成器', link: '/zh/guide/cli-generator'}, 12 | {text: '环境变量列表', link: '/zh/guide/env-vars'}, 13 | {text: '依赖关系图表', link: '/zh/guide/deps-map'}, 14 | ] 15 | }, 16 | { 17 | items: [ 18 | {text: '故障排除', link: '/zh/guide/troubleshooting'}, 19 | {text: '在 Windows 上构建', link: '/zh/guide/build-on-windows'}, 20 | ], 21 | } 22 | ], 23 | '/zh/develop/': [ 24 | { 25 | text: '开发指南', 26 | items: [ 27 | { text: '开发简介', link: '/zh/develop/' }, 28 | { text: '项目结构简介', link: '/zh/develop/structure' }, 29 | {text: '对 PHP 源码的修改', link: '/zh/develop/php-src-changes'}, 30 | ], 31 | }, 32 | { 33 | text: '模块', 34 | items: [ 35 | { text: 'Doctor 环境检查工具', link: '/zh/develop/doctor-module' }, 36 | { text: '资源模块', link: '/zh/develop/source-module' }, 37 | ] 38 | }, 39 | { 40 | text: '其他', 41 | items: [ 42 | {text: '系统编译工具', link: '/zh/develop/system-build-tools'}, 43 | ] 44 | } 45 | ], 46 | '/zh/contributing/': [ 47 | { 48 | text: '贡献指南', 49 | items: [ 50 | {text: '贡献指南', link: '/zh/contributing/'}, 51 | ], 52 | } 53 | ], 54 | }; 55 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/index.ts: -------------------------------------------------------------------------------- 1 | // docs/.vitepress/theme/index.ts 2 | import DefaultTheme from 'vitepress/theme' 3 | import {inBrowser, useData} from "vitepress"; 4 | import {watchEffect} from "vue"; 5 | 6 | export default { 7 | ...DefaultTheme, 8 | setup() { 9 | const { lang } = useData() 10 | watchEffect(() => { 11 | if (inBrowser) { 12 | document.cookie = `nf_lang=${lang.value}; expires=Mon, 1 Jan 2024 00:00:00 UTC; path=/` 13 | } 14 | }) 15 | } 16 | } -------------------------------------------------------------------------------- /docs/deps-map-ext.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walkor/static-php-cli/b62963489a447fa73816c2f05588cd236e14c94d/docs/deps-map-ext.md -------------------------------------------------------------------------------- /docs/deps-map-lib.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walkor/static-php-cli/b62963489a447fa73816c2f05588cd236e14c94d/docs/deps-map-lib.md -------------------------------------------------------------------------------- /docs/en/guide/cli-generator.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | # CLI Build Command Generator 6 | 7 | ::: tip 8 | The extensions selected below may contain extensions that are not supported by the selected operating system, 9 | which may cause compilation to fail. Please check [Supported Extensions](./extensions) first. 10 | ::: 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/en/guide/deps-map.md: -------------------------------------------------------------------------------- 1 | --- 2 | outline: 'deep' 3 | --- 4 | 5 | # Dependency Table 6 | 7 | When compiling PHP, each extension and library has dependencies, which may be required or optional. 8 | You can choose whether to include these optional dependencies. 9 | 10 | For example, when compiling the `gd` extension under Linux, 11 | the `zlib,libpng` libraries and the `zlib` extension are forced to be compiled, 12 | while the `libavif,libwebp,libjpeg,freetype` libraries are optional libraries and will not be compiled by default 13 | unless specified by the `--with-libs=avif,webp,jpeg,freetype` option. 14 | 15 | - For optional extensions (optional features of extensions), you need to specify them manually at compile time, for example, to enable igbinary support for Redis: `bin/spc build redis,igbinary`. 16 | - For optional libraries, you need to compile and specify them through the `--with-libs=XXX` option. 17 | - If you want to enable all optional extensions, you can use `bin/spc build redis --with-suggested-exts`. 18 | - If you want to enable all optional libraries, you can use `--with-suggested-libs`. 19 | 20 | ## Extension Dependency Table 21 | 22 | 23 | 24 | ## Library Dependency Table 25 | 26 | -------------------------------------------------------------------------------- /docs/en/guide/extensions.md: -------------------------------------------------------------------------------- 1 | # Extensions 2 | 3 | > - `yes`: supported 4 | > - _blank_: not supported yet, or WIP 5 | > - `no` with issue link: confirmed to be unavailable due to issue 6 | > - `partial` with issue link: supported but not perfect due to issue 7 | 8 | 9 | 10 | ::: tip 11 | If an extension you need is missing, you can create a [Feature Request](https://github.com/crazywhalecc/static-php-cli/issues). 12 | 13 | Some extensions or libraries that the extension depends on will have some optional features. 14 | For example, the gd library optionally supports libwebp, freetype, etc. 15 | If you only use `bin/spc build gd --build-cli` they will not be included (static-php-cli defaults to the minimum dependency principle). 16 | 17 | For more information about optional libraries, see [Extensions, Library Dependency Map](./deps-map). 18 | For optional libraries, you can also select an extension from the [Command Generator](./cli-generator) and then select optional libraries. 19 | ::: 20 | -------------------------------------------------------------------------------- /docs/en/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # https://vitepress.dev/reference/default-theme-home-page 3 | layout: home 4 | 5 | hero: 6 | name: "static-php-cli" 7 | tagline: "Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included." 8 | actions: 9 | - theme: brand 10 | text: Guide 11 | link: ./guide/ 12 | 13 | features: 14 | - title: Static CLI Binary 15 | details: You can easily compile a standalone php binary for general use. Including CLI, FPM sapi. 16 | - title: Micro Self-Extracted Executable 17 | details: You can compile a self-extracted executable and build with your php source code. 18 | - title: Dependency Management 19 | details: static-php-cli comes with dependency management and supports installation of different types of PHP extensions. 20 | --- 21 | 22 | -------------------------------------------------------------------------------- /docs/extension-notes.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walkor/static-php-cli/b62963489a447fa73816c2f05588cd236e14c94d/docs/extension-notes.md -------------------------------------------------------------------------------- /docs/extensions.md: -------------------------------------------------------------------------------- 1 | > This file is dynamically generated by `bin/spc dev:gen-ext-docs` command. 2 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # https://vitepress.dev/reference/default-theme-home-page 3 | layout: home 4 | 5 | hero: 6 | name: "static-php-cli" 7 | tagline: "Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included." 8 | actions: 9 | - theme: brand 10 | text: Get Started 11 | link: /en/guide/ 12 | - theme: alt 13 | text: 中文文档 14 | link: /zh/ 15 | 16 | features: 17 | - title: Static CLI Binary 18 | details: You can easily compile a standalone php binary for general use. Including CLI, FPM sapi. 19 | - title: Micro Self-Extracted Executable 20 | details: You can compile a self-extracted executable and build with your php source code. 21 | - title: Dependency Management 22 | details: static-php-cli comes with dependency management and supports installation of different types of PHP extensions. 23 | --- 24 | -------------------------------------------------------------------------------- /docs/public/CNAME: -------------------------------------------------------------------------------- 1 | static-php.dev -------------------------------------------------------------------------------- /docs/zh/contributing/index.md: -------------------------------------------------------------------------------- 1 | # 贡献指南 2 | 3 | 感谢你能够看到这里,本项目非常欢迎你的贡献! 4 | 5 | ## 贡献方法 6 | 7 | 如果你有代码或文档想要贡献,需要先了解以下内容。 8 | 9 | 1. 你要贡献什么类型的代码?(新扩展、修复 Bug、安全问题、项目框架优化、文档) 10 | 2. 如果你贡献了新文件或新片段,你的代码是否经过 `php-cs-fixer` 和 `phpstan` 的检查? 11 | 3. 在贡献代码前是否充分阅读了 [开发指南](../develop/)? 12 | 13 | 如果你可以回答以上问题,并已经对代码做出了修改,可以及时在项目 GitHub 仓库发起 Pull Request。待代码审查完毕后,可根据建议修改代码,或直接合并到主分支。 14 | 15 | ## 贡献类型 16 | 17 | 本项目主要用途是编译静态链接的 PHP 二进制,基于 `symfony/console` 编写了命令行处理功能。在开发之前,如果你对它不够熟悉, 18 | 可以先查看 [symfony/console 文档](https://symfony.com/doc/current/components/console.html)。 19 | 20 | ### 安全问题 21 | 22 | 因为本项目基本上是属于本地运行的 PHP 项目,一般来说不会存在远程攻击行为。但如果你发现了此类问题,请**不要**在 GitHub 仓库提交 PR 或 Issue, 23 | 你需要通过 [邮件](mailto:admin@zhamao.me) 的方式联系项目维护者(crazywhalecc)。 24 | 25 | ### 修复 Bug 26 | 27 | 修复 Bug 一般不涉及项目结构和框架的修改,所以如果你可以定位到错误代码并直接修复它,请直接提交 PR。 28 | 29 | ### 新扩展 30 | 31 | 对于添加一个新扩展来说,你需要先了解一些本项目的基本结构,以及如何根据现有的逻辑添加新扩展。在本页的下一章节将会详细介绍。 32 | 总的来说,你需要: 33 | 34 | 1. 评估扩展是否可以内联编译到 PHP 中。 35 | 2. 评估扩展的依赖库(如果有)是否可以静态编译。 36 | 3. 写出扩展的依赖库在不同平台编译命令。 37 | 4. 验证扩展及其依赖库能否与现有扩展和依赖库兼容。 38 | 5. 验证扩展在 `cli`、`micro`、`fpm`、`embed` 几种 SAPI 中均正常工作。 39 | 6. 编写文档,加入你的扩展。 40 | 41 | ### 项目框架优化 42 | 43 | 如果你已经熟悉 `symfony/console` 的工作原理,并同时要对项目的框架进行一些修改或优化,请先了解以下事情: 44 | 45 | 1. 加入扩展不属于项目框架优化,但如果你在加入新的扩展时发现不得不优化框架,则需先对框架本身进行修改,然后再加入扩展。 46 | 2. 对于一些大规模逻辑修改(例如涉及 LibraryBase、Extension 对象等的修改)时,建议先提交 Issue 或 Draft PR 进行讨论方案。 47 | 3. 项目早期为纯中文开发项目,代码中存在一部分中文的注释。国际化项目后你可以提交 PR 将这些注释翻译为英语。 48 | 4. 请不要在代码中提交包含较多无用的代码片段,例如大量未被使用的变量、方法、类、重复写了很多次的代码。 49 | -------------------------------------------------------------------------------- /docs/zh/develop/index.md: -------------------------------------------------------------------------------- 1 | # 开发简介 2 | 3 | 开发本项目需要安装部署 PHP 环境,以及一些 PHP 项目常用的扩展和 Composer。 4 | 5 | 项目的开发环境和运行环境几乎完全一致,你可以参照 **指南-本地构建** 部分安装系统 PHP 或使用本项目预构建的静态 PHP 作为环境,这里不再赘述。 6 | 7 | 抛开用途,本项目本身其实就是一个 `php-cli` 程序,你可以将它当作一个正常的 PHP 项目进行编辑和开发,同时你需要了解不同系统的 Shell 命令行。 8 | 9 | 本项目目前的目的就是为了编译静态编译的独立 PHP,但主体部分也包含编译很多依赖库的静态版本,所以你可以复用这套编译逻辑,用于构建其他程序的独立二进制版本,例如 Nginx 等。 10 | 11 | ## 环境准备 12 | 13 | 开发本项目需要 PHP 环境。你可以使用系统自带的 PHP,也可以使用本项目构建的静态 PHP。 14 | 15 | 无论是使用哪种 PHP,在开发环境,你需要安装这些扩展: 16 | 17 | ``` 18 | curl,dom,filter,mbstring,openssl,pcntl,phar,posix,sodium,tokenizer,xml,xmlwriter 19 | ``` 20 | 21 | static-php-cli 项目本身不需要这么多扩展,但在开发过程中,你会用到 Composer、PHPUnit 等工具,它们需要这些扩展。 22 | 23 | > 对于 static-php-cli 自身构建的 micro 自执行二进制,仅需要 `pcntl,posix,mbstring,tokenizer,phar`。 24 | 25 | ## 开始开发 26 | 27 | 继续向下查看项目结构的文档,你可以从中了解 `static-php-cli` 是如何运作的。 28 | -------------------------------------------------------------------------------- /docs/zh/develop/php-src-changes.md: -------------------------------------------------------------------------------- 1 | # 对 PHP 源码的修改 2 | 3 | 由于 static-php-cli 在静态编译过程中为了实现良好的兼容性、性能和安全性,对 PHP 源码进行了一些修改。下面是目前对 PHP 源码修改的说明。 4 | 5 | ## micro 相关补丁 6 | 7 | 基于 phpmicro 项目提供的补丁,static-php-cli 对 PHP 源码进行了一些修改,以适应静态编译的需求。[补丁列表](https://github.com/easysoft/phpmicro/tree/master/patches) 包含: 8 | 9 | 目前 static-php-cli 在编译时用到的补丁有: 10 | 11 | - static_opcache 12 | - static_extensions_win32 13 | - cli_checks 14 | - disable_huge_page 15 | - vcruntime140 16 | - win32 17 | - zend_stream 18 | - cli_static 19 | - macos_iconv 20 | - phar 21 | 22 | ## PHP <= 8.1 libxml 补丁 23 | 24 | 因为 PHP 官方仅对 8.1 进行安全更新,旧版本停止更新,所以 static-php-cli 对 PHP 8.1 及以下版本应用了在新版本 PHP 中已经应用的 libxml 编译补丁。 25 | 26 | ## gd 扩展 Windows 补丁 27 | 28 | 在 Windows 下编译 gd 扩展需要大幅改动 `config.w32` 文件,static-php-cli 对 gd 扩展进行了一些修改,使其在 Windows 下编译更加方便。 29 | 30 | ## yaml 扩展 Windows 补丁 31 | 32 | yaml 扩展在 Windows 下编译需要修改 `config.w32` 文件,static-php-cli 对 yaml 扩展进行了一些修改,使其在 Windows 下编译更加方便。 33 | 34 | ## static-php-cli 版本信息插入 35 | 36 | static-php-cli 在编译时会在 PHP 版本信息中插入 static-php-cli 的版本信息,以便于识别。 37 | 38 | ## 加入硬编码 INI 的选项 39 | 40 | 在使用 `-I` 参数硬编码 INI 到静态 PHP 的功能中,static-php-cli 会修改 PHP 源码以插入硬编码内容。 41 | 42 | ## Linux 系统修复补丁 43 | 44 | 部分编译环境可能缺少一些头文件或库,static-php-cli 会在编译时自动修复这些问题,如: 45 | 46 | - HAVE_STRLCAT missing problem 47 | - HAVE_STRLCPY missing problem 48 | 49 | ## Windows 系统下 Fiber 问题修复补丁 50 | 51 | 在 Windows 下编译 PHP 时,Fiber 扩展会出现一些问题,static-php-cli 会在编译时自动修复这些问题(修改 php-src 的 `config.w32`)。 52 | -------------------------------------------------------------------------------- /docs/zh/guide/action-build.md: -------------------------------------------------------------------------------- 1 | # Action 构建 2 | 3 | Action 构建指的是直接使用 GitHub Action 进行编译。 4 | 5 | 如果你不想自行编译,可以从本项目现有的 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.static-php.dev/static-php-cli/common/) 6 | 7 | > 自托管的二进制也是由 Action 构建而来,[项目仓库地址](https://github.com/static-php/static-php-cli-hosted)。 8 | 9 | ## 构建方法 10 | 11 | 使用 GitHub Action 可以方便地构建一个静态编译的 PHP 和 phpmicro,同时可以自行定义要编译的扩展。 12 | 13 | 1. Fork 本项目。 14 | 2. 进入项目的 Actions,选择 CI 开头的 Workflow(根据你需要的操作系统选择)。 15 | 3. 选择 `Run workflow`,填入你要编译的 PHP 版本、目标类型、扩展列表。(扩展列表使用英文逗号分割,例如 `bcmath,curl,mbstring`) 16 | 4. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`。 17 | 18 | 如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。 19 | 20 | > 如果你需要在其他环境构建,可以使用 [手动构建](./manual-build)。 21 | 22 | ## 扩展选择 23 | 24 | 你可以到 [扩展列表](./extensions) 中查看目前你需要的扩展是否均支持, 25 | 然后到 [在线命令生成](./cli-generator) 中选择你需要编译的扩展,复制扩展字符串到 Action 的 `extensions` 中,编译即可。 26 | -------------------------------------------------------------------------------- /docs/zh/guide/cli-generator.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | # CLI 编译命令生成器 6 | 7 | ::: tip 8 | 下面选择扩展可能包含所选操作系统不支持的扩展,这可能导致编译失败。请先查阅 [支持的扩展](./extensions)。 9 | ::: 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/zh/guide/deps-map.md: -------------------------------------------------------------------------------- 1 | --- 2 | outline: 'deep' 3 | --- 4 | 5 | # 依赖关系图表 6 | 7 | 在编译 PHP 时,每个扩展、库都有依赖关系,这些依赖关系可能是必需的,也可能是可选的。在编译 PHP 时,可以选择是否包含这些可选的依赖关系。 8 | 9 | 例如,在 Linux 下编译 `gd` 扩展时,会强制编译 `zlib,libpng` 库和 `zlib` 扩展,而 `libavif,libwebp,libjpeg,freetype` 库都是可选的库,默认不会编译,除非通过 `--with-libs=avif,webp,jpeg,freetype` 选项指定。 10 | 11 | - 对于可选扩展(扩展的可选特性),需手动在编译时指定,例如启用 Redis 的 igbinary 支持:`bin/spc build redis,igbinary`。 12 | - 对于可选库,需通过 `--with-libs=XXX` 选项编译指定。 13 | - 如果想启用所有的可选扩展,可以使用 `bin/spc build redis --with-suggested-exts` 参数。 14 | - 如果想启用所有的可选库,可以使用 `--with-suggested-libs` 参数。 15 | 16 | ## 扩展的依赖图 17 | 18 | 19 | 20 | ## 库的依赖表 21 | 22 | -------------------------------------------------------------------------------- /docs/zh/guide/extensions.md: -------------------------------------------------------------------------------- 1 | # 扩展列表 2 | 3 | > - `yes`: 已支持 4 | > - 空白: 目前还不支持,或正在支持中 5 | > - `no` with issue link: 确定不支持或无法支持 6 | > - `partial` with issue link: 已支持,但是无法完美工作 7 | 8 | 9 | 10 | ::: tip 11 | 如果缺少您需要的扩展,您可以创建 [功能请求](https://github.com/crazywhalecc/static-php-cli/issues)。 12 | 13 | 有些扩展或扩展依赖的库会有一些可选的特性,例如 gd 库可选支持 libwebp、freetype 等。 14 | 如果你只使用 `bin/spc build gd --build-cli` 是不会包含它们(static-php-cli 默认为最小依赖原则)。 15 | 16 | 有关编译可选库,请参考 [扩展、库的依赖关系图表](./deps-map)。对于可选的库,你也可以从 [编译命令生成器](./cli-generator) 中选择扩展后展开选择可选库。 17 | ::: 18 | -------------------------------------------------------------------------------- /docs/zh/guide/index.md: -------------------------------------------------------------------------------- 1 | # 指南 2 | 3 | static-php-cli 是一个用于构建静态编译的 PHP 二进制的工具,目前支持 Linux 和 macOS 系统。 4 | 5 | 在指南章节中,你将了解到如何使用 static-php-cli 构建独立的 php 程序。 6 | 7 | - [Action 构建](./action-build) 8 | - [本地构建](./manual-build) 9 | - [扩展列表](./extensions) 10 | 11 | ## 编译环境 12 | 13 | 下面是架构支持情况,:gear: 代表支持 GitHub Action 构建,:computer: 代表支持本地构建,空 代表暂不支持。 14 | 15 | | | x86_64 | aarch64 | 16 | |---------|-------------------|-------------------| 17 | | macOS | :gear: :computer: | :gear: :computer: | 18 | | Linux | :gear: :computer: | :gear: :computer: | 19 | | Windows | :gear: :computer: | | 20 | | FreeBSD | :computer: | :computer: | 21 | 22 | 其中,Linux 目前仅在 Ubuntu、Debian、Alpine 发行版测试通过,其他发行版未进行测试,不能保证编译成功。 23 | 对于未经过测试的发行版,可以使用 Docker 等方式本地编译,避免环境导致的问题。 24 | 25 | macOS 下支持 x86_64 和 Arm 两种架构,但在其中一个架构上编译的二进制无法直接在另一个架构上使用。 26 | Rosetta 2 不能保证 Arm 架构编译的程序可以完全运行在 x86_64 环境下。 27 | 28 | Windows 目前只支持 x86_64 架构,不支持 32 位 x86、不支持 arm64 架构。 29 | 30 | ## PHP 支持版本 31 | 32 | 目前,static-php-cli 对 PHP 7.4 ~ 8.3 版本是支持的,对于 PHP 7.4 及更早版本理论上支持,只需下载时选择早期版本即可。 33 | 但由于部分扩展和特殊组件已对早期版本的 PHP 停止了支持,所以 static-php-cli 不会明确支持早期版本。 34 | 我们推荐你编译尽可能新的 PHP 版本,以获得更好的体验。 35 | -------------------------------------------------------------------------------- /docs/zh/guide/troubleshooting.md: -------------------------------------------------------------------------------- 1 | # 故障排除 2 | 3 | 使用 static-php-cli 过程中可能会碰到各种各样的故障,这里将讲述如何自行查看错误并反馈 Issue。 4 | 5 | ## 下载失败问题 6 | 7 | 下载资源问题是 spc 最常见的问题之一。主要是由于 spc 下载资源使用的地址一般均为对应项目的官方网站或 GitHub 等,而这些网站可能偶尔会宕机、屏蔽 IP 地址。 8 | 目前 2.0.0 版本还没有加入自动重试机制,所以在遇到下载失败后,可以多次尝试调用下载命令。如果确认地址确实无法正常访问,可以提交 Issue 或 PR 更新地址。 9 | 10 | ## doctor 无法修复 11 | 12 | 在绝大部分情况下,doctor 模块都可以对缺失的系统环境进行自动修复和安装,但也存在特殊的环境无法正常使用自动修复功能。 13 | 14 | 部分项目由于系统局限(如 Windows 下无法自动安装 Visual Studio 等软件),无法使用自动修复功能。 15 | 在遇到无法自动修复功能时,如果遇到 `Some check items can not be fixed` 字样,则表明无法自动修复,请根据终端显示的方法提交 Issue 或自行修复环境。 16 | 17 | ## 编译错误 18 | 19 | 遇到编译错误时,如果没有开启 `--debug` 日志,请先开启调试日志,然后确定报错的命令。 20 | 报错的终端输出对于修复编译错误非常重要,请在提交 Issue 时一并将终端日志的最后报错片段(或整个终端日志输出)上传,并且包含使用的 `spc` 命令和参数。 21 | -------------------------------------------------------------------------------- /docs/zh/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # https://vitepress.dev/reference/default-theme-home-page 3 | layout: home 4 | 5 | hero: 6 | name: "static-php-cli" 7 | tagline: "在 Linux、macOS、FreeBSD、Windows 上与 PHP 项目一起构建独立的 PHP 二进制文件,并包含流行的扩展。" 8 | actions: 9 | - theme: brand 10 | text: 指南 11 | link: ./guide/ 12 | 13 | features: 14 | - title: 静态二进制 15 | details: 您可以轻松地编译一个独立的 PHP 二进制文件以供嵌入程序使用。包括 cli、fpm、micro。 16 | - title: phpmicro 自执行二进制 17 | details: 您可以使用 micro SAPI 编译一个自解压的可执行文件,并将 PHP 代码与二进制文件打包为一个文件。 18 | - title: 依赖管理 19 | details: static-php-cli 附带依赖项管理,支持安装不同类型的 PHP 扩展和不同的依赖库。 20 | --- 21 | -------------------------------------------------------------------------------- /ext-support.md: -------------------------------------------------------------------------------- 1 | # Extension List 2 | 3 | See: [Docs - Extensions](https://static-php.dev/en/guide/extensions.html) 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "docs:dev": "vitepress dev docs", 4 | "docs:build": "vitepress build docs", 5 | "docs:preview": "vitepress preview docs" 6 | }, 7 | "devDependencies": { 8 | "vitepress": "^1.0.0-rc.35", 9 | "vue": "^3.2.47" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | parameters: 2 | reportUnmatchedIgnoredErrors: false 3 | level: 4 4 | paths: 5 | - ./src/ 6 | ignoreErrors: 7 | - '#Constant .* not found#' 8 | - '#Unsafe usage of new static#' 9 | - '#class Fiber#' 10 | - '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#' 11 | - '#Function Swoole\\Coroutine\\run not found.#' 12 | dynamicConstantNames: 13 | - PHP_OS_FAMILY 14 | excludePaths: 15 | analyseAndScan: 16 | - ./src/globals/ext-tests/swoole.php 17 | - ./src/globals/ext-tests/swoole.phpt 18 | - ./src/globals/test-extensions.php -------------------------------------------------------------------------------- /src/SPC/builder/BuilderProvider.php: -------------------------------------------------------------------------------- 1 | new WindowsBuilder($input->getOptions()), 34 | 'Darwin' => new MacOSBuilder($input->getOptions()), 35 | 'Linux' => new LinuxBuilder($input->getOptions()), 36 | 'BSD' => new BSDBuilder($input->getOptions()), 37 | default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'), 38 | }; 39 | return self::$builder; 40 | } 41 | 42 | /** 43 | * @throws WrongUsageException 44 | */ 45 | public static function getBuilder(): BuilderBase 46 | { 47 | if (self::$builder === null) { 48 | throw new WrongUsageException('Builder has not been initialized'); 49 | } 50 | return self::$builder; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/SPC/builder/LibraryInterface.php: -------------------------------------------------------------------------------- 1 | builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; 24 | FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lbz2/', $this->getLibFilesString() . $frameworks); 25 | return true; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/dba.php: -------------------------------------------------------------------------------- 1 | builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : ''; 16 | return '--enable-dba' . $qdbm; 17 | } 18 | 19 | public function getWindowsConfigureArg(): string 20 | { 21 | $qdbm = $this->builder->getLib('qdbm') ? ' --with-qdbm' : ''; 22 | return '--with-dba' . $qdbm; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/enchant.php: -------------------------------------------------------------------------------- 1 | getLibFilesString() . '"'; 26 | $arg .= ' GLIB_CFLAGS=-I"' . BUILD_INCLUDE_PATH . '"'; 27 | $arg .= ' GLIB_LIBS="' . implode(' ', $glibs) . '"'; 28 | return $arg; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/event.php: -------------------------------------------------------------------------------- 1 | builder->getLib('openssl')) { 20 | $arg .= ' --with-event-openssl=' . BUILD_ROOT_PATH; 21 | } 22 | if ($this->builder->getExt('sockets')) { 23 | $arg .= ' --enable-event-sockets'; 24 | } else { 25 | $arg .= ' --disable-event-sockets'; 26 | } 27 | return $arg; 28 | } 29 | 30 | /** 31 | * @throws FileSystemException 32 | */ 33 | public function patchBeforeConfigure(): bool 34 | { 35 | FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString()); 36 | return true; 37 | } 38 | 39 | /** 40 | * @throws FileSystemException 41 | */ 42 | public function patchBeforeMake(): bool 43 | { 44 | // Prevent event extension compile error on macOS 45 | if ($this->builder instanceof MacOSBuilder) { 46 | FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); 47 | } 48 | return true; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/ffi.php: -------------------------------------------------------------------------------- 1 | builder->getLib('freetype') ? ' --with-freetype' : ''; 17 | $arg .= $this->builder->getLib('libjpeg') ? ' --with-jpeg' : ''; 18 | $arg .= $this->builder->getLib('libwebp') ? ' --with-webp' : ''; 19 | $arg .= $this->builder->getLib('libavif') ? ' --with-avif' : ''; 20 | return $arg; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/gettext.php: -------------------------------------------------------------------------------- 1 | builder instanceof MacOSBuilder) { 23 | FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gettext/config.m4', 'AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB', 'AC_CHECK_LIB(intl'); 24 | } 25 | return true; 26 | } 27 | 28 | /** 29 | * @throws WrongUsageException 30 | * @throws FileSystemException 31 | */ 32 | public function patchBeforeConfigure(): bool 33 | { 34 | if ($this->builder instanceof MacOSBuilder) { 35 | $frameworks = ' ' . $this->builder->getFrameworks(true) . ' '; 36 | FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lintl', $this->getLibFilesString() . $frameworks); 37 | } 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/glfw.php: -------------------------------------------------------------------------------- 1 | builder instanceof MacOSBuilder) { 18 | return false; 19 | } 20 | $extra_libs = $this->builder->getOption('extra-libs', ''); 21 | if (!str_contains($extra_libs, '-liconv')) { 22 | $extra_libs .= ' -liconv'; 23 | } 24 | $this->builder->setOption('extra-libs', $extra_libs); 25 | return true; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/imagick.php: -------------------------------------------------------------------------------- 1 | builder instanceof LinuxBuilder) { 19 | $extra_libs .= (empty($extra_libs) ? '' : ' ') . '-lgomp '; 20 | } 21 | f_putenv('SPC_EXTRA_LIBS=' . $extra_libs); 22 | return true; 23 | } 24 | 25 | public function getUnixConfigureArg(): string 26 | { 27 | return '--with-imagick=' . BUILD_ROOT_PATH; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/imap.php: -------------------------------------------------------------------------------- 1 | builder->getLib('openssl')) { 18 | // sometimes imap with openssl does not contain zlib (required by openssl) 19 | // we need to add it manually 20 | FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/imap/config.m4', 'TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD"', 'TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD -lz"'); 21 | return true; 22 | } 23 | return false; 24 | } 25 | 26 | /** 27 | * @throws WrongUsageException 28 | */ 29 | public function validate(): void 30 | { 31 | if ($this->builder->getOption('enable-zts')) { 32 | throw new WrongUsageException('ext-imap is not thread safe, do not build it with ZTS builds'); 33 | } 34 | } 35 | 36 | public function getUnixConfigureArg(): string 37 | { 38 | $arg = '--with-imap=' . BUILD_ROOT_PATH; 39 | if ($this->builder->getLib('openssl') !== null) { 40 | $arg .= ' --with-imap-ssl=' . BUILD_ROOT_PATH; 41 | } 42 | return $arg; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/intl.php: -------------------------------------------------------------------------------- 1 | execWithResult('$PKG_CONFIG --libs-only-l --static ldap'); 17 | if (!empty($output[1][0])) { 18 | $libs = $output[1][0]; 19 | FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lldap ', $libs . ' '); 20 | } 21 | return true; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/mbregex.php: -------------------------------------------------------------------------------- 1 | execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring" | grep regex', false); 30 | if ($ret !== 0) { 31 | throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); 32 | } 33 | } 34 | 35 | public function runCliCheckWindows(): void 36 | { 37 | [$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring"', false); 38 | if ($ret !== 0) { 39 | throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !'); 40 | } 41 | $out = implode("\n", $out); 42 | if (!str_contains($out, 'regex')) { 43 | throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/mbstring.php: -------------------------------------------------------------------------------- 1 | builder->getExt('mbregex') === null) { 17 | $arg .= ' --disable-mbregex'; 18 | } else { 19 | $arg .= ' --enable-mbregex'; 20 | } 21 | return $arg; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/memcache.php: -------------------------------------------------------------------------------- 1 | builder->getLib('openssl')) { 19 | $arg .= '--with-mongodb-ssl=openssl'; 20 | } 21 | $arg .= $this->builder->getLib('icu') ? ' --with-mongodb-icu=yes ' : ' --with-mongodb-icu=no '; 22 | $arg .= $this->builder->getLib('zstd') ? ' --with-mongodb-zstd=yes ' : ' --with-mongodb-zstd=no '; 23 | // $arg .= $this->builder->getLib('snappy') ? ' --with-mongodb-snappy=yes ' : ' --with-mongodb-snappy=no '; 24 | $arg .= $this->builder->getLib('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled '; 25 | return $arg; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/openssl.php: -------------------------------------------------------------------------------- 1 | builder->getPHPVersionID() < 80100) { 17 | $openssl_c = file_get_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c'); 18 | $openssl_c = preg_replace('/REGISTER_LONG_CONSTANT\s*\(\s*"OPENSSL_SSLV23_PADDING"\s*.+;/', '', $openssl_c); 19 | file_put_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c', $openssl_c); 20 | return true; 21 | } 22 | 23 | return false; 24 | } 25 | 26 | public function getUnixConfigureArg(): string 27 | { 28 | return '--with-openssl=' . BUILD_ROOT_PATH . ' --with-openssl-dir=' . BUILD_ROOT_PATH; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/parallel.php: -------------------------------------------------------------------------------- 1 | builder->getOption('enable-zts')) { 17 | throw new WrongUsageException('ext-parallel must be built with ZTS builds. Use "--enable-zts" option!'); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/password_argon2.php: -------------------------------------------------------------------------------- 1 | execWithResult(BUILD_ROOT_PATH . '/bin/php -r "assert(defined(\'PASSWORD_ARGON2I\'));"'); 22 | if ($ret !== 0) { 23 | throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/pdo_sqlite.php: -------------------------------------------------------------------------------- 1 | getLibFilesString() 24 | ); 25 | return true; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/protobuf.php: -------------------------------------------------------------------------------- 1 | builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { 16 | throw new \RuntimeException('The latest protobuf extension requires PHP 8.0 or later'); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/rar.php: -------------------------------------------------------------------------------- 1 | = 15.0) 22 | if ($this->builder instanceof MacOSBuilder) { 23 | FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/rar/config.m4', '-Wall -fvisibility=hidden', '-Wall -Wno-incompatible-function-pointer-types -fvisibility=hidden'); 24 | return true; 25 | } 26 | return false; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/readline.php: -------------------------------------------------------------------------------- 1 | getLibFilesString() 24 | ); 25 | return true; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/redis.php: -------------------------------------------------------------------------------- 1 | builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session'; 17 | $arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary'; 18 | if ($this->builder->getLib('zstd')) { 19 | $arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"'; 20 | } 21 | if ($this->builder->getLib('liblz4')) { 22 | $arg .= ' --enable-redis-lz4 --with-liblz4="' . BUILD_ROOT_PATH . '"'; 23 | } 24 | return $arg; 25 | } 26 | 27 | public function getWindowsConfigureArg(): string 28 | { 29 | $arg = '--enable-redis'; 30 | $arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session'; 31 | $arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary'; 32 | return $arg; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/simdjson.php: -------------------------------------------------------------------------------- 1 | builder->getPHPVersionID(); 17 | FileSystem::replaceFileRegex( 18 | SOURCE_PATH . '/php-src/ext/simdjson/config.m4', 19 | '/php_version=(`.*`)$/m', 20 | 'php_version=' . strval($php_ver) 21 | ); 22 | FileSystem::replaceFileStr( 23 | SOURCE_PATH . '/php-src/ext/simdjson/config.m4', 24 | 'if test -z "$PHP_CONFIG"; then', 25 | 'if false; then' 26 | ); 27 | FileSystem::replaceFileStr( 28 | SOURCE_PATH . '/php-src/ext/simdjson/config.w32', 29 | "'yes',", 30 | 'PHP_SIMDJSON_SHARED,' 31 | ); 32 | return true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/snappy.php: -------------------------------------------------------------------------------- 1 | getLibFilesString() . ($this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++') 25 | ); 26 | return true; 27 | } 28 | 29 | public function getUnixConfigureArg(): string 30 | { 31 | return '--enable-snappy --with-snappy-includedir="' . BUILD_ROOT_PATH . '"'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/sodium.php: -------------------------------------------------------------------------------- 1 | removeLineContainingString(); 17 | } 18 | 19 | private function removeLineContainingString(): bool 20 | { 21 | $path = SOURCE_PATH . '/php-src/ext/sodium/config.m4'; 22 | $search = '-Wno-logical-op'; 23 | if (!file_exists($path)) { 24 | return false; 25 | } 26 | $content = file_get_contents($path); 27 | $lines = preg_split('/\r\n|\n/', $content); 28 | $filteredLines = array_filter($lines, function ($line) use ($search) { 29 | return strpos($line, $search) === false; 30 | }); 31 | $newContent = implode("\n", $filteredLines); 32 | file_put_contents($path, $newContent); 33 | return true; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/spx.php: -------------------------------------------------------------------------------- 1 | builder->getOption('enable-zts')) { 20 | throw new WrongUsageException('ext-spx is not thread safe, do not build it with ZTS builds'); 21 | } 22 | } 23 | 24 | public function getUnixConfigureArg(): string 25 | { 26 | $arg = '--enable-spx'; 27 | if ($this->builder->getExt('zlib') === null) { 28 | $arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH; 29 | } 30 | return $arg; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/sqlsrv.php: -------------------------------------------------------------------------------- 1 | builder->getExt('pdo_sqlsrv') === null) { 19 | // support sqlsrv without pdo_sqlsrv 20 | FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/sqlsrv/config.w32', 'PHP_PDO_SQLSRV', '"no"'); 21 | $this->pdo_sqlsrv_patched = true; 22 | return true; 23 | } 24 | return false; 25 | } 26 | 27 | public function patchBeforeConfigure(): bool 28 | { 29 | if ($this->pdo_sqlsrv_patched) { 30 | // revert pdo_sqlsrv patch 31 | FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/sqlsrv/config.w32', '"no" == "no"', 'PHP_PDO_SQLSRV == "no"'); 32 | return true; 33 | } 34 | return false; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/ssh2.php: -------------------------------------------------------------------------------- 1 | getLibFilesString() 24 | ); 25 | return true; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/swoole_hook_mysql.php: -------------------------------------------------------------------------------- 1 | builder->getExt('swoole') === null) { 30 | return; 31 | } 32 | [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "swoole"', false); 33 | $out = implode('', $out); 34 | if ($ret !== 0) { 35 | throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); 36 | } 37 | if (!str_contains($out, 'mysqlnd')) { 38 | throw new RuntimeException('swoole mysql hook is not enabled correctly.'); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/swoole_hook_pgsql.php: -------------------------------------------------------------------------------- 1 | builder->getExt('pdo_pgsql') !== null) { 24 | throw new WrongUsageException('swoole-hook-pgsql provides pdo_pgsql, if you enable pgsql hook for swoole, you must remove pdo_pgsql extension.'); 25 | } 26 | } 27 | 28 | public function getUnixConfigureArg(): string 29 | { 30 | // enable swoole pgsql hook 31 | return '--enable-swoole-pgsql'; 32 | } 33 | 34 | public function runCliCheckUnix(): void 35 | { 36 | // skip if not enable swoole 37 | if ($this->builder->getExt('swoole') === null) { 38 | return; 39 | } 40 | [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "swoole"', false); 41 | $out = implode('', $out); 42 | if ($ret !== 0) { 43 | throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); 44 | } 45 | if (!str_contains($out, 'coroutine_pgsql')) { 46 | throw new RuntimeException('swoole pgsql hook is not enabled correctly.'); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/swoole_hook_sqlite.php: -------------------------------------------------------------------------------- 1 | builder->getExt('pdo_sqlite') !== null) { 24 | throw new WrongUsageException('swoole-hook-sqlite provides pdo_sqlite, if you enable sqlite hook for swoole, you must remove pdo_sqlite extension.'); 25 | } 26 | } 27 | 28 | public function getUnixConfigureArg(): string 29 | { 30 | // enable swoole pgsql hook 31 | return '--enable-swoole-sqlite'; 32 | } 33 | 34 | public function runCliCheckUnix(): void 35 | { 36 | // skip if not enable swoole 37 | if ($this->builder->getExt('swoole') === null) { 38 | return; 39 | } 40 | [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "swoole"', false); 41 | $out = implode('', $out); 42 | if ($ret !== 0) { 43 | throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); 44 | } 45 | if (!str_contains($out, 'coroutine_sqlite')) { 46 | throw new RuntimeException('swoole sqlite hook is not enabled correctly.'); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/swow.php: -------------------------------------------------------------------------------- 1 | builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { 17 | throw new RuntimeException('The latest swow extension requires PHP 8.0 or later'); 18 | } 19 | } 20 | 21 | public function getConfigureArg(): string 22 | { 23 | $arg = '--enable-swow'; 24 | $arg .= $this->builder->getLib('openssl') ? ' --enable-swow-ssl' : ' --disable-swow-ssl'; 25 | $arg .= $this->builder->getLib('curl') ? ' --enable-swow-curl' : ' --disable-swow-curl'; 26 | return $arg; 27 | } 28 | 29 | /** 30 | * @throws RuntimeException 31 | */ 32 | public function patchBeforeBuildconf(): bool 33 | { 34 | if ($this->builder->getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) { 35 | if (PHP_OS_FAMILY === 'Windows') { 36 | f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && mklink /D swow swow-src\ext'); 37 | } else { 38 | f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && ln -s swow-src/ext swow'); 39 | } 40 | return true; 41 | } 42 | return false; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/uv.php: -------------------------------------------------------------------------------- 1 | builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { 16 | throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later'); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/xhprof.php: -------------------------------------------------------------------------------- 1 | builder->getLib('openssl')) { 17 | $arg .= ' --with-openssl=' . BUILD_ROOT_PATH; 18 | } 19 | return $arg; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/SPC/builder/extension/yac.php: -------------------------------------------------------------------------------- 1 | execWithResult('sysctl -n hw.ncpu'); 24 | if ($ret !== 0) { 25 | throw new RuntimeException('Failed to get cpu count'); 26 | } 27 | 28 | return (int) $output[0]; 29 | } 30 | 31 | /** 32 | * Get Target Arch CFlags 33 | * 34 | * @param string $arch Arch Name 35 | * @return string return Arch CFlags string 36 | * @throws WrongUsageException 37 | */ 38 | public static function getArchCFlags(string $arch): string 39 | { 40 | return match ($arch) { 41 | 'amd64', 'x86_64' => '--target=x86_64-unknown-freebsd', 42 | 'arm64','aarch64' => '--target=aarch-unknown-freebsd', 43 | default => throw new WrongUsageException('unsupported arch: ' . $arch), 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/SPC/builder/freebsd/library/BSDLibraryBase.php: -------------------------------------------------------------------------------- 1 | builder; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/SPC/builder/freebsd/library/bzip2.php: -------------------------------------------------------------------------------- 1 | builder->getLib('openssl')) { 17 | $this->builder->setOption('extra-libs', $this->builder->getOption('extra-libs') . ' /usr/lib/libpthread.a /usr/lib/libdl.a'); 18 | } 19 | return $libs; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/SPC/builder/freebsd/library/onig.php: -------------------------------------------------------------------------------- 1 | true,代表依赖 curl 但可选 24 | */ 25 | protected array $dep_names; 26 | 27 | public function __construct(protected LinuxBuilder $builder) 28 | { 29 | parent::__construct(); 30 | } 31 | 32 | public function getBuilder(): BuilderBase 33 | { 34 | return $this->builder; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/SPC/builder/linux/library/brotli.php: -------------------------------------------------------------------------------- 1 | builder->getLib('openssl')) { 17 | $libs .= ' -ldl -lpthread'; 18 | } 19 | return $libs; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/SPC/builder/linux/library/freetype.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir . '/source') 21 | ->exec( 22 | "{$cppflags} {$cxxflags} {$ldflags} " . 23 | './runConfigureICU Linux ' . 24 | '--enable-static ' . 25 | '--disable-shared ' . 26 | '--with-data-packaging=static ' . 27 | '--enable-release=yes ' . 28 | '--enable-extras=no ' . 29 | '--enable-icuio=yes ' . 30 | '--enable-dyload=no ' . 31 | '--enable-tools=yes ' . 32 | '--enable-tests=no ' . 33 | '--enable-samples=no ' . 34 | '--prefix=' . BUILD_ROOT_PATH 35 | ) 36 | ->exec('make clean') 37 | ->exec("make -j{$this->builder->concurrency}") 38 | ->exec('make install'); 39 | 40 | $this->patchPkgconfPrefix(['icu-i18n.pc', 'icu-io.pc', 'icu-uc.pc'], PKGCONF_PATCH_PREFIX); 41 | FileSystem::removeDir(BUILD_LIB_PATH . '/icu'); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/SPC/builder/linux/library/imagemagick.php: -------------------------------------------------------------------------------- 1 | source_dir . '/Makefile', 'LIBRARY_REL ?= lib/x86_64-linux-gnu', 'LIBRARY_REL ?= lib'); 18 | return true; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/SPC/builder/linux/library/libavif.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * lwmbs is licensed under Mulan PSL v2. You can use this 6 | * software according to the terms and conditions of the 7 | * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: 8 | * 9 | * http://license.coscl.org.cn/MulanPSL2 10 | * 11 | * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 13 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 14 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 15 | * 16 | * See the Mulan PSL v2 for more details. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace SPC\builder\linux\library; 22 | 23 | class libwebp extends LinuxLibraryBase 24 | { 25 | use \SPC\builder\unix\library\libwebp; 26 | 27 | public const NAME = 'libwebp'; 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/linux/library/libxslt.php: -------------------------------------------------------------------------------- 1 | execWithResult('sysctl -n hw.ncpu', false); 24 | if ($ret !== 0) { 25 | throw new RuntimeException('Failed to get cpu count'); 26 | } 27 | 28 | return (int) $output[0]; 29 | } 30 | 31 | /** 32 | * Get Target Arch CFlags 33 | * 34 | * @param string $arch Arch Name 35 | * @return string return Arch CFlags string 36 | * @throws WrongUsageException 37 | */ 38 | public static function getArchCFlags(string $arch): string 39 | { 40 | return match ($arch) { 41 | 'x86_64' => '--target=x86_64-apple-darwin', 42 | 'arm64','aarch64' => '--target=arm64-apple-darwin', 43 | default => throw new WrongUsageException('unsupported arch: ' . $arch), 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/MacOSLibraryBase.php: -------------------------------------------------------------------------------- 1 | builder; 29 | } 30 | 31 | /** 32 | * @throws WrongUsageException 33 | * @throws FileSystemException 34 | */ 35 | public function getFrameworks(): array 36 | { 37 | return Config::getLib(static::NAME, 'frameworks', []); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/brotli.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * lwmbs is licensed under Mulan PSL v2. You can use this 6 | * software according to the terms and conditions of the 7 | * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: 8 | * 9 | * http://license.coscl.org.cn/MulanPSL2 10 | * 11 | * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 13 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 14 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 15 | * 16 | * See the Mulan PSL v2 for more details. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace SPC\builder\macos\library; 22 | 23 | class brotli extends MacOSLibraryBase 24 | { 25 | use \SPC\builder\unix\library\brotli; 26 | 27 | public const NAME = 'brotli'; 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/bzip2.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * lwmbs is licensed under Mulan PSL v2. You can use this 6 | * software according to the terms and conditions of the 7 | * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: 8 | * 9 | * http://license.coscl.org.cn/MulanPSL2 10 | * 11 | * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 13 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 14 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 15 | * 16 | * See the Mulan PSL v2 for more details. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace SPC\builder\macos\library; 22 | 23 | class bzip2 extends MacOSLibraryBase 24 | { 25 | use \SPC\builder\unix\library\bzip2; 26 | 27 | public const NAME = 'bzip2'; 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/curl.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * lwmbs is licensed under Mulan PSL v2. You can use this 6 | * software according to the terms and conditions of the 7 | * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: 8 | * 9 | * http://license.coscl.org.cn/MulanPSL2 10 | * 11 | * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 13 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 14 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 15 | * 16 | * See the Mulan PSL v2 for more details. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace SPC\builder\macos\library; 22 | 23 | use SPC\exception\FileSystemException; 24 | use SPC\store\FileSystem; 25 | 26 | class curl extends MacOSLibraryBase 27 | { 28 | use \SPC\builder\unix\library\curl; 29 | 30 | public const NAME = 'curl'; 31 | 32 | /** 33 | * @throws FileSystemException 34 | */ 35 | public function patchBeforeBuild(): bool 36 | { 37 | FileSystem::replaceFileRegex( 38 | SOURCE_PATH . '/curl/CMakeLists.txt', 39 | '/NOT COREFOUNDATION_FRAMEWORK/m', 40 | 'FALSE' 41 | ); 42 | FileSystem::replaceFileRegex( 43 | SOURCE_PATH . '/curl/CMakeLists.txt', 44 | '/NOT SYSTEMCONFIGURATION_FRAMEWORK/m', 45 | 'FALSE' 46 | ); 47 | FileSystem::replaceFileRegex( 48 | SOURCE_PATH . '/curl/CMakeLists.txt', 49 | '/NOT CORESERVICES_FRAMEWORK/m', 50 | 'FALSE' 51 | ); 52 | return true; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/freetype.php: -------------------------------------------------------------------------------- 1 | cd(SOURCE_PATH . '/ext-glfw/vendor/glfw') 22 | ->exec("cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF") 23 | ->exec("make -j{$this->builder->concurrency}") 24 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 25 | // patch pkgconf 26 | $this->patchPkgconfPrefix(['glfw3.pc']); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/gmp.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir . '/source') 19 | ->exec("./runConfigureICU MacOSX --enable-static --disable-shared --disable-extras --disable-samples --disable-tests --prefix={$root}") 20 | ->exec('make clean') 21 | ->exec("make -j{$this->builder->concurrency}") 22 | ->exec('make install'); 23 | 24 | $this->patchPkgconfPrefix(['icu-i18n.pc', 'icu-io.pc', 'icu-uc.pc'], PKGCONF_PATCH_PREFIX); 25 | FileSystem::removeDir(BUILD_LIB_PATH . '/icu'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/imagemagick.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * lwmbs is licensed under Mulan PSL v2. You can use this 6 | * software according to the terms and conditions of the 7 | * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: 8 | * 9 | * http://license.coscl.org.cn/MulanPSL2 10 | * 11 | * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 13 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 14 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 15 | * 16 | * See the Mulan PSL v2 for more details. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace SPC\builder\macos\library; 22 | 23 | class libavif extends MacOSLibraryBase 24 | { 25 | use \SPC\builder\unix\library\libavif; 26 | 27 | public const NAME = 'libavif'; 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/libcares.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 22 | ->exec( 23 | './configure ' . 24 | '--enable-static ' . 25 | '--disable-shared ' . 26 | "--host={$this->builder->getOption('arch')}-apple-darwin " . 27 | "--target={$this->builder->getOption('arch')}-apple-darwin " . 28 | '--prefix= ' // use prefix=/ 29 | ) 30 | ->exec('make clean') 31 | ->exec("make -j{$this->builder->concurrency}") 32 | ->exec("make install DESTDIR={$destdir}"); 33 | $this->patchPkgconfPrefix(['libffi.pc']); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/libiconv.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * lwmbs is licensed under Mulan PSL v2. You can use this 6 | * software according to the terms and conditions of the 7 | * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: 8 | * 9 | * http://license.coscl.org.cn/MulanPSL2 10 | * 11 | * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 13 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 14 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 15 | * 16 | * See the Mulan PSL v2 for more details. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace SPC\builder\macos\library; 22 | 23 | class libiconv extends MacOSLibraryBase 24 | { 25 | use \SPC\builder\unix\library\libiconv; 26 | 27 | public const NAME = 'libiconv'; 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/libjpeg.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 19 | ->exec('chmod +x configure') 20 | ->exec( 21 | './configure ' . 22 | '--enable-static --disable-shared ' . 23 | '--disable-sasl ' . 24 | "--prefix={$rootdir}" 25 | ) 26 | ->exec('make clean') 27 | ->exec('sed -ie "s/-Werror//g" ' . $this->source_dir . '/Makefile') 28 | ->exec("make -j{$this->builder->concurrency}") 29 | ->exec('make install'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/librabbitmq.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * lwmbs is licensed under Mulan PSL v2. You can use this 6 | * software according to the terms and conditions of the 7 | * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: 8 | * 9 | * http://license.coscl.org.cn/MulanPSL2 10 | * 11 | * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 13 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 14 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 15 | * 16 | * See the Mulan PSL v2 for more details. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace SPC\builder\macos\library; 22 | 23 | class libwebp extends MacOSLibraryBase 24 | { 25 | use \SPC\builder\unix\library\libwebp; 26 | 27 | public const NAME = 'libwebp'; 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/libxslt.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * lwmbs is licensed under Mulan PSL v2. You can use this 6 | * software according to the terms and conditions of the 7 | * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: 8 | * 9 | * http://license.coscl.org.cn/MulanPSL2 10 | * 11 | * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 13 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 14 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 15 | * 16 | * See the Mulan PSL v2 for more details. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace SPC\builder\macos\library; 22 | 23 | class nghttp2 extends MacOSLibraryBase 24 | { 25 | use \SPC\builder\unix\library\nghttp2; 26 | 27 | public const NAME = 'nghttp2'; 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/onig.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * lwmbs is licensed under Mulan PSL v2. You can use this 6 | * software according to the terms and conditions of the 7 | * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: 8 | * 9 | * http://license.coscl.org.cn/MulanPSL2 10 | * 11 | * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 13 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 14 | * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 15 | * 16 | * See the Mulan PSL v2 for more details. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace SPC\builder\macos\library; 22 | 23 | class zlib extends MacOSLibraryBase 24 | { 25 | use \SPC\builder\unix\library\zlib; 26 | 27 | public const NAME = 'zlib'; 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/macos/library/zstd.php: -------------------------------------------------------------------------------- 1 | source_dir . '/build-dir'); 20 | shell()->cd($this->source_dir . '/build-dir') 21 | ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) 22 | ->execWithEnv( 23 | 'cmake ' . 24 | "{$this->builder->makeCmakeArgs()} " . 25 | '-DBUILD_SHARED_LIBS=OFF ' . 26 | '..' 27 | ) 28 | ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") 29 | ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); 30 | $this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']); 31 | shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a'); 32 | foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { 33 | if (str_starts_with($filename, 'libbrotli') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) { 34 | unlink(BUILD_ROOT_PATH . '/lib/' . $filename); 35 | } 36 | } 37 | 38 | if (file_exists(BUILD_BIN_PATH . '/brotli')) { 39 | unlink(BUILD_BIN_PATH . '/brotli'); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/bzip2.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 12 | ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) 13 | ->execWithEnv("make PREFIX='" . BUILD_ROOT_PATH . "' clean") 14 | ->execWithEnv("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a") 15 | ->exec('cp libbz2.a ' . BUILD_LIB_PATH) 16 | ->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/gettext.php: -------------------------------------------------------------------------------- 1 | builder->getLib('ncurses') ? ('--with-libncurses-prefix=' . BUILD_ROOT_PATH . ' ') : ''; 12 | $extra .= $this->builder->getLib('libxml2') ? ('--with-libxml2-prefix=' . BUILD_ROOT_PATH . ' ') : ''; 13 | shell()->cd($this->source_dir) 14 | ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) 15 | ->execWithEnv( 16 | './configure ' . 17 | '--enable-static ' . 18 | '--disable-shared ' . 19 | '--disable-java ' . 20 | '--disable-c+ ' . 21 | $extra . 22 | '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . 23 | '--prefix=' . BUILD_ROOT_PATH 24 | ) 25 | ->execWithEnv('make clean') 26 | ->execWithEnv("make -j{$this->builder->concurrency}") 27 | ->execWithEnv('make install'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/gmp.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 19 | ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) 20 | ->execWithEnv( 21 | './configure ' . 22 | '--enable-static --disable-shared ' . 23 | '--prefix=' 24 | ) 25 | ->execWithEnv('make clean') 26 | ->execWithEnv("make -j{$this->builder->concurrency}") 27 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 28 | $this->patchPkgconfPrefix(['gmp.pc']); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/gmssl.php: -------------------------------------------------------------------------------- 1 | source_dir . '/build'); 21 | // Start build 22 | shell()->cd($this->source_dir . '/build') 23 | ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) 24 | ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..") 25 | ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") 26 | ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/icu.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 14 | ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) 15 | ->exec("make PREFIX='' clean") 16 | ->execWithEnv("make -j{$this->builder->concurrency} PREFIX=''") 17 | ->execWithEnv("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH); 18 | 19 | $this->patchPkgconfPrefix(['libargon2.pc']); 20 | 21 | foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { 22 | if (str_starts_with($filename, 'libargon2') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) { 23 | unlink(BUILD_ROOT_PATH . '/lib/' . $filename); 24 | } 25 | } 26 | 27 | if (file_exists(BUILD_BIN_PATH . '/argon2')) { 28 | unlink(BUILD_BIN_PATH . '/argon2'); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/libavif.php: -------------------------------------------------------------------------------- 1 | source_dir . '/build'); 23 | // Start build 24 | shell()->cd($this->source_dir . '/build') 25 | ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) 26 | ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DAVIF_LIBYUV=OFF ..") 27 | ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") 28 | ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); 29 | // patch pkgconfig 30 | $this->patchPkgconfPrefix(['libavif.pc']); 31 | $this->cleanLaFiles(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/libcares.php: -------------------------------------------------------------------------------- 1 | source_dir . '/src/lib/thirdparty/apple/dnsinfo.h')) { 15 | FileSystem::createDir($this->source_dir . '/src/lib/thirdparty/apple'); 16 | copy(ROOT_DIR . '/src/globals/extra/libcares_dnsinfo.h', $this->source_dir . '/src/lib/thirdparty/apple/dnsinfo.h'); 17 | return true; 18 | } 19 | return false; 20 | } 21 | 22 | /** 23 | * @throws RuntimeException 24 | */ 25 | protected function build(): void 26 | { 27 | shell()->cd($this->source_dir) 28 | ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) 29 | ->execWithEnv('./configure --prefix= --enable-static --disable-shared --disable-tests') 30 | ->execWithEnv("make -j {$this->builder->concurrency}") 31 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 32 | 33 | $this->patchPkgconfPrefix(['libcares.pc'], PKGCONF_PATCH_PREFIX); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/libiconv.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 14 | ->exec( 15 | './configure ' . 16 | '--enable-static ' . 17 | '--disable-shared ' . 18 | '--enable-extra-encodings ' . 19 | '--prefix=' 20 | ) 21 | ->exec('make clean') 22 | ->exec("make -j{$this->builder->concurrency}") 23 | ->exec('make install DESTDIR=' . $destdir); 24 | 25 | if (file_exists(BUILD_BIN_PATH . '/iconv')) { 26 | unlink(BUILD_BIN_PATH . '/iconv'); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/libjpeg.php: -------------------------------------------------------------------------------- 1 | source_dir . '/build'); 23 | // Start build 24 | shell()->cd($this->source_dir . '/build') 25 | ->exec( 26 | "cmake {$this->builder->makeCmakeArgs()} " . 27 | '-DENABLE_STATIC=ON ' . 28 | '-DENABLE_SHARED=OFF ' . 29 | '..' 30 | ) 31 | ->exec("cmake --build . -j {$this->builder->concurrency}") 32 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 33 | // patch pkgconfig 34 | $this->patchPkgconfPrefix(['libjpeg.pc', 'libturbojpeg.pc']); 35 | $this->cleanLaFiles(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/liblz4.php: -------------------------------------------------------------------------------- 1 | source_dir . '/programs/Makefile', 'install: lz4', "install: lz4\n\ninstallewfwef: lz4"); 15 | return true; 16 | } 17 | 18 | protected function build(): void 19 | { 20 | shell()->cd($this->source_dir) 21 | ->exec("make PREFIX='' clean") 22 | ->exec("make -j{$this->builder->concurrency} PREFIX=''") 23 | ->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH); 24 | 25 | $this->patchPkgconfPrefix(['liblz4.pc']); 26 | 27 | foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { 28 | if (str_starts_with($filename, 'liblz4') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) { 29 | unlink(BUILD_ROOT_PATH . '/lib/' . $filename); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/librabbitmq.php: -------------------------------------------------------------------------------- 1 | source_dir . '/build'); 21 | // Start build 22 | shell()->cd($this->source_dir . '/build') 23 | ->exec( 24 | 'cmake ' . 25 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . 26 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 27 | '-DCMAKE_BUILD_TYPE=Release ' . 28 | '-DBUILD_SHARED_LIBS=OFF ' . 29 | '-DBUILD_STATIC_LIBS=ON ' . 30 | '..' 31 | ) 32 | ->exec("cmake --build . -j {$this->builder->concurrency}") 33 | ->exec('make install'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/libsodium.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 12 | ->exec('./configure --enable-static --disable-shared --prefix=') 13 | ->exec('make clean') 14 | ->exec("make -j{$this->builder->concurrency}") 15 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 16 | 17 | $this->patchPkgconfPrefix(['libsodium.pc'], PKGCONF_PATCH_PREFIX); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/libssh2.php: -------------------------------------------------------------------------------- 1 | builder->getLib('zlib') !== null ? 'ON' : 'OFF'; 20 | 21 | FileSystem::resetDir($this->source_dir . '/build'); 22 | shell()->cd($this->source_dir . '/build') 23 | ->exec( 24 | 'cmake ' . 25 | "{$this->builder->makeCmakeArgs()} " . 26 | '-DBUILD_SHARED_LIBS=OFF ' . 27 | '-DBUILD_EXAMPLES=OFF ' . 28 | '-DBUILD_TESTING=OFF ' . 29 | "-DENABLE_ZLIB_COMPRESSION={$enable_zlib} " . 30 | '..' 31 | ) 32 | ->exec("cmake --build . -j {$this->builder->concurrency}") 33 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 34 | $this->patchPkgconfPrefix(['libssh2.pc']); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/libtiff.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 19 | ->exec( 20 | './configure ' . 21 | '--enable-static --disable-shared ' . 22 | '--disable-cxx ' . 23 | '--prefix=' 24 | ); 25 | 26 | // TODO: Remove this check when https://gitlab.com/libtiff/libtiff/-/merge_requests/635 will be merged and released 27 | if (file_exists($this->source_dir . '/html')) { 28 | $shell->exec('make clean'); 29 | } 30 | 31 | $shell 32 | ->exec("make -j{$this->builder->concurrency}") 33 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 34 | $this->patchPkgconfPrefix(['libtiff-4.pc']); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/libuuid.php: -------------------------------------------------------------------------------- 1 | source_dir . '/build'); 20 | shell()->cd($this->source_dir . '/build') 21 | ->exec( 22 | 'cmake ' . 23 | "{$this->builder->makeCmakeArgs()} " . 24 | '..' 25 | ) 26 | ->exec("cmake --build . -j {$this->builder->concurrency}"); 27 | copy($this->source_dir . '/build/libuuid.a', BUILD_LIB_PATH . '/libuuid.a'); 28 | FileSystem::createDir(BUILD_INCLUDE_PATH . '/uuid'); 29 | copy($this->source_dir . '/uuid.h', BUILD_INCLUDE_PATH . '/uuid/uuid.h'); 30 | $pc = FileSystem::readFile($this->source_dir . '/uuid.pc.in'); 31 | $pc = str_replace([ 32 | '@prefix@', 33 | '@exec_prefix@', 34 | '@libdir@', 35 | '@includedir@', 36 | '@LIBUUID_VERSION@', 37 | ], [ 38 | BUILD_ROOT_PATH, 39 | '${prefix}', 40 | '${prefix}/lib', 41 | '${prefix}/include', 42 | '1.0.3', 43 | ], $pc); 44 | FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/uuid.pc', $pc); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/libuv.php: -------------------------------------------------------------------------------- 1 | source_dir . '/build'); 21 | // Start build 22 | shell()->cd($this->source_dir . '/build') 23 | ->exec("cmake {$this->builder->makeCmakeArgs()} -DLIBUV_BUILD_SHARED=OFF ..") 24 | ->exec("cmake --build . -j {$this->builder->concurrency}") 25 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 26 | // patch pkgconfig 27 | $this->patchPkgconfPrefix(['libuv-static.pc']); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/libwebp.php: -------------------------------------------------------------------------------- 1 | source_dir . '/build'); 23 | // Start build 24 | shell()->cd($this->source_dir . '/build') 25 | ->exec( 26 | 'cmake ' . 27 | $this->builder->makeCmakeArgs() . ' ' . 28 | '-DBUILD_SHARED_LIBS=OFF ' . 29 | '-DWEBP_BUILD_EXTRAS=ON ' . 30 | '..' 31 | ) 32 | ->exec("cmake --build . -j {$this->builder->concurrency}") 33 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 34 | // patch pkgconfig 35 | $this->patchPkgconfPrefix(['libsharpyuv.pc', 'libwebp.pc', 'libwebpdecoder.pc', 'libwebpdemux.pc', 'libwebpmux.pc'], PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR); 36 | $this->patchPkgconfPrefix(['libsharpyuv.pc'], PKGCONF_PATCH_CUSTOM, ['/^includedir=.*$/m', 'includedir=${prefix}/include/webp']); 37 | $this->cleanLaFiles(); 38 | // fix imagemagick binary linking issue 39 | $this->patchPkgconfPrefix(['libwebp.pc'], PKGCONF_PATCH_CUSTOM, ['/-lwebp$/m', '-lwebp -lsharpyuv']); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/nghttp2.php: -------------------------------------------------------------------------------- 1 | builder->makeAutoconfArgs(static::NAME, [ 21 | 'zlib' => null, 22 | 'openssl' => null, 23 | 'libxml2' => null, 24 | 'libev' => null, 25 | 'libcares' => null, 26 | 'libngtcp2' => null, 27 | 'libnghttp3' => null, 28 | 'libbpf' => null, 29 | 'libevent-openssl' => null, 30 | 'jansson' => null, 31 | 'jemalloc' => null, 32 | 'systemd' => null, 33 | 'cunit' => null, 34 | ]); 35 | 36 | [,,$destdir] = SEPARATED_PATH; 37 | 38 | shell()->cd($this->source_dir) 39 | ->exec( 40 | './configure ' . 41 | '--enable-static ' . 42 | '--disable-shared ' . 43 | '--enable-lib-only ' . 44 | '--with-boost=no ' . 45 | $args . ' ' . 46 | '--prefix=' 47 | ) 48 | ->exec('make clean') 49 | ->exec("make -j{$this->builder->concurrency}") 50 | ->exec("make install DESTDIR={$destdir}"); 51 | $this->patchPkgconfPrefix(['libnghttp2.pc']); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/onig.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 21 | ->exec('./configure --enable-static --disable-shared --prefix=') 22 | ->exec('make clean') 23 | ->exec("make -j{$this->builder->concurrency}") 24 | ->exec("make install DESTDIR={$destdir}"); 25 | $this->patchPkgconfPrefix(['oniguruma.pc']); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/pkgconfig.php: -------------------------------------------------------------------------------- 1 | builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion" : ''; 12 | $ldflags = PHP_OS_FAMILY !== 'Linux' ? '' : '--static'; 13 | 14 | shell()->cd($this->source_dir) 15 | ->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $cflags, 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()]) 16 | ->execWithEnv( 17 | './configure ' . 18 | '--disable-shared ' . 19 | '--enable-static ' . 20 | '--with-internal-glib ' . 21 | '--disable-host-tool ' . 22 | '--with-pic ' . 23 | '--prefix=' . BUILD_ROOT_PATH . ' ' . 24 | '--without-sysroot ' . 25 | '--without-system-include-path ' . 26 | '--without-system-library-path ' . 27 | '--without-pc-path' 28 | ) 29 | ->exec('make clean') 30 | ->execWithEnv("make -j{$this->builder->concurrency}") 31 | ->execWithEnv('make install-exec'); 32 | shell()->exec('strip ' . BUILD_ROOT_PATH . '/bin/pkg-config'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/qdbm.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 21 | ->exec( 22 | './configure ' . 23 | '--enable-static --disable-shared ' . 24 | '--prefix=' 25 | ) 26 | ->exec('make clean'); 27 | FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/MYLIBS = libqdbm.a.*/m', 'MYLIBS = libqdbm.a'); 28 | shell()->cd($this->source_dir) 29 | ->exec("make -j{$this->builder->concurrency}" . ($this instanceof MacOSLibraryBase ? ' mac' : '')) 30 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 31 | $this->patchPkgconfPrefix(['qdbm.pc']); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/readline.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 19 | ->exec( 20 | './configure ' . 21 | '--enable-static=yes ' . 22 | '--enable-shared=no ' . 23 | '--prefix= ' . 24 | '--with-curses ' . 25 | '--enable-multibyte=yes' 26 | ) 27 | ->exec('make clean') 28 | ->exec("make -j{$this->builder->concurrency}") 29 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 30 | $this->patchPkgconfPrefix(['readline.pc']); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/snappy.php: -------------------------------------------------------------------------------- 1 | source_dir . '/cmake/build'); 20 | 21 | shell()->cd($this->source_dir . '/cmake/build') 22 | ->exec( 23 | 'cmake ' . 24 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 25 | "{$this->builder->makeCmakeArgs()} " . 26 | '-DSNAPPY_BUILD_TESTS=OFF ' . 27 | '-DSNAPPY_BUILD_BENCHMARKS=OFF ' . 28 | '../..' 29 | ) 30 | ->exec("cmake --build . -j {$this->builder->concurrency}") 31 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/sqlite.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 12 | ->exec('./configure --enable-static --disable-shared --prefix=') 13 | ->exec('make clean') 14 | ->exec("make -j{$this->builder->concurrency}") 15 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 16 | $this->patchPkgconfPrefix(['sqlite3.pc']); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/tidy.php: -------------------------------------------------------------------------------- 1 | source_dir . '/build-dir'); 20 | shell()->cd($this->source_dir . '/build-dir') 21 | ->exec( 22 | 'cmake ' . 23 | "{$this->builder->makeCmakeArgs()} " . 24 | '-DBUILD_SHARED_LIB=OFF ' . 25 | '-DSUPPORT_CONSOLE_APP=OFF ' . 26 | '..' 27 | ) 28 | ->exec("cmake --build . -j {$this->builder->concurrency}") 29 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 30 | $this->patchPkgconfPrefix(['tidy.pc']); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/unixodbc.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 19 | ->exec( 20 | './configure ' . 21 | '--enable-static --disable-shared ' . 22 | '--disable-debug ' . 23 | '--disable-dependency-tracking ' . 24 | '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . 25 | '--with-included-ltdl ' . 26 | '--enable-gui=no ' . 27 | '--prefix=' 28 | ) 29 | ->exec('make clean') 30 | ->exec("make -j{$this->builder->concurrency}") 31 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 32 | $this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']); 33 | $this->cleanLaFiles(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/xz.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 19 | ->exec( 20 | './configure ' . 21 | '--enable-static ' . 22 | '--disable-shared ' . 23 | '--disable-scripts ' . 24 | '--disable-doc ' . 25 | '--with-libiconv ' . 26 | '--prefix=' 27 | ) 28 | ->exec('make clean') 29 | ->exec("make -j{$this->builder->concurrency}") 30 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 31 | $this->patchPkgconfPrefix(['liblzma.pc']); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/zlib.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 21 | ->exec('./configure --static --prefix=') 22 | ->exec('make clean') 23 | ->exec("make -j{$this->builder->concurrency}") 24 | ->exec("make install DESTDIR={$destdir}"); 25 | $this->patchPkgconfPrefix(['zlib.pc']); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/SPC/builder/unix/library/zstd.php: -------------------------------------------------------------------------------- 1 | source_dir . '/build/cmake/build'); 20 | shell()->cd($this->source_dir . '/build/cmake/build') 21 | ->exec( 22 | 'cmake ' . 23 | "{$this->builder->makeCmakeArgs()} " . 24 | '-DZSTD_BUILD_STATIC=ON ' . 25 | '-DZSTD_BUILD_SHARED=OFF ' . 26 | '..' 27 | ) 28 | ->exec("cmake --build . -j {$this->builder->concurrency}") 29 | ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); 30 | $this->patchPkgconfPrefix(['libzstd.pc']); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/bzip2.php: -------------------------------------------------------------------------------- 1 | builder->makeSimpleWrapper('nmake /nologo /f Makefile.msc CFLAGS="-DWIN32 -MT -Ox -D_FILE_OFFSET_BITS=64 -nologo"'); 14 | cmd()->cd($this->source_dir) 15 | ->execWithWrapper($nmake, 'clean') 16 | ->execWithWrapper($nmake, 'lib'); 17 | copy($this->source_dir . '\libbz2.lib', BUILD_LIB_PATH . '\libbz2.lib'); 18 | copy($this->source_dir . '\libbz2.lib', BUILD_LIB_PATH . '\libbz2_a.lib'); 19 | copy($this->source_dir . '\bzlib.h', BUILD_INCLUDE_PATH . '\bzlib.h'); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/curl.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir . '\winbuild') 17 | ->execWithWrapper( 18 | $this->builder->makeSimpleWrapper('nmake'), 19 | '/f Makefile.vc WITH_DEVEL=' . BUILD_ROOT_PATH . ' ' . 20 | 'WITH_PREFIX=' . BUILD_ROOT_PATH . ' ' . 21 | 'mode=static RTLIBCFG=static WITH_SSL=static WITH_NGHTTP2=static WITH_SSH2=static ENABLE_IPV6=yes WITH_ZLIB=static MACHINE=x64 DEBUG=no' 22 | ); 23 | FileSystem::copyDir($this->source_dir . '\include\curl', BUILD_INCLUDE_PATH . '\curl'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/freetype.php: -------------------------------------------------------------------------------- 1 | source_dir . '\build'); 17 | 18 | // start build 19 | cmd()->cd($this->source_dir) 20 | ->execWithWrapper( 21 | $this->builder->makeSimpleWrapper('cmake'), 22 | '-B build ' . 23 | '-A x64 ' . 24 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 25 | '-DCMAKE_BUILD_TYPE=Release ' . 26 | '-DBUILD_SHARED_LIBS=OFF ' . 27 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 28 | ) 29 | ->execWithWrapper( 30 | $this->builder->makeSimpleWrapper('cmake'), 31 | "--build build --config Release --target install -j{$this->builder->concurrency}" 32 | ); 33 | // freetype.lib to libfreetype_a.lib 34 | copy(BUILD_LIB_PATH . '\freetype.lib', BUILD_LIB_PATH . '\libfreetype_a.lib'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/gmssl.php: -------------------------------------------------------------------------------- 1 | source_dir . '\builddir'); 17 | 18 | // start build 19 | cmd()->cd($this->source_dir . '\builddir') 20 | ->execWithWrapper( 21 | $this->builder->makeSimpleWrapper('cmake .. -G "NMake Makefiles" -DWIN32=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" -DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH), 22 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH 23 | ); 24 | 25 | FileSystem::writeFile($this->source_dir . '\builddir\cmake_install.cmake', 'set(CMAKE_INSTALL_PREFIX "' . str_replace('\\', '/', BUILD_ROOT_PATH) . '")' . PHP_EOL . FileSystem::readFile($this->source_dir . '\builddir\cmake_install.cmake')); 26 | 27 | cmd()->cd($this->source_dir . '\builddir') 28 | ->execWithWrapper( 29 | $this->builder->makeSimpleWrapper('nmake'), 30 | 'install XCFLAGS=/MT' 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/libavif.php: -------------------------------------------------------------------------------- 1 | source_dir . '\build'); 17 | 18 | // start build 19 | cmd()->cd($this->source_dir) 20 | ->execWithWrapper( 21 | $this->builder->makeSimpleWrapper('cmake'), 22 | '-B build ' . 23 | '-A x64 ' . 24 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 25 | '-DCMAKE_BUILD_TYPE=Release ' . 26 | '-DBUILD_SHARED_LIBS=OFF ' . 27 | '-DAVIF_BUILD_APPS=OFF ' . 28 | '-DAVIF_BUILD_TESTS=OFF ' . 29 | '-DAVIF_LIBYUV=OFF ' . 30 | '-DAVID_ENABLE_GTEST=OFF ' . 31 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 32 | ) 33 | ->execWithWrapper( 34 | $this->builder->makeSimpleWrapper('cmake'), 35 | "--build build --config Release --target install -j{$this->builder->concurrency}" 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/libiconv_win.php: -------------------------------------------------------------------------------- 1 | '/MSVC17', 19 | 'vs16' => '/MSVC16', 20 | default => throw new RuntimeException('Current VS version is not supported yet!'), 21 | }; 22 | 23 | // start build 24 | cmd()->cd($this->source_dir . $vs_ver_dir) 25 | ->execWithWrapper( 26 | $this->builder->makeSimpleWrapper('msbuild'), 27 | 'libiconv.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64' 28 | ); 29 | FileSystem::createDir(BUILD_LIB_PATH); 30 | FileSystem::createDir(BUILD_INCLUDE_PATH); 31 | copy($this->source_dir . $vs_ver_dir . '\x64\lib\libiconv.lib', BUILD_LIB_PATH . '\libiconv.lib'); 32 | copy($this->source_dir . $vs_ver_dir . '\x64\lib\libiconv_a.lib', BUILD_LIB_PATH . '\libiconv_a.lib'); 33 | copy($this->source_dir . '\source\include\iconv.h', BUILD_INCLUDE_PATH . '\iconv.h'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/libjpeg.php: -------------------------------------------------------------------------------- 1 | builder->getLib('zlib') ? 'ON' : 'OFF'; 16 | // reset cmake 17 | FileSystem::resetDir($this->source_dir . '\build'); 18 | 19 | // start build 20 | cmd()->cd($this->source_dir) 21 | ->execWithWrapper( 22 | $this->builder->makeSimpleWrapper('cmake'), 23 | '-B build ' . 24 | '-A x64 ' . 25 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 26 | '-DCMAKE_BUILD_TYPE=Release ' . 27 | '-DENABLE_SHARED=OFF ' . 28 | '-DENABLE_STATIC=ON ' . 29 | '-DBUILD_TESTING=OFF ' . 30 | '-DWITH_JAVA=OFF ' . 31 | '-DWITH_CRT_DLL=OFF ' . 32 | "-DENABLE_ZLIB_COMPRESSION={$zlib} " . 33 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 34 | ) 35 | ->execWithWrapper( 36 | $this->builder->makeSimpleWrapper('cmake'), 37 | "--build build --config Release --target install -j{$this->builder->concurrency}" 38 | ); 39 | copy(BUILD_LIB_PATH . '\jpeg-static.lib', BUILD_LIB_PATH . '\libjpeg_a.lib'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/libpng.php: -------------------------------------------------------------------------------- 1 | source_dir . '\build'); 17 | 18 | // start build 19 | cmd()->cd($this->source_dir) 20 | ->execWithWrapper( 21 | $this->builder->makeSimpleWrapper('cmake'), 22 | '-B build ' . 23 | '-A x64 ' . 24 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 25 | '-DCMAKE_BUILD_TYPE=Release ' . 26 | '-DSKIP_INSTALL_PROGRAM=ON ' . 27 | '-DSKIP_INSTALL_FILES=ON ' . 28 | '-DBUILD_SHARED_LIBS=OFF ' . 29 | '-DPNG_STATIC=ON ' . 30 | '-DPNG_SHARED=OFF ' . 31 | '-DPNG_TESTS=OFF ' . 32 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 33 | ) 34 | ->execWithWrapper( 35 | $this->builder->makeSimpleWrapper('cmake'), 36 | "--build build --config Release --target install -j{$this->builder->concurrency}" 37 | ); 38 | copy(BUILD_LIB_PATH . '\libpng16_static.lib', BUILD_LIB_PATH . '\libpng_a.lib'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/librabbitmq.php: -------------------------------------------------------------------------------- 1 | source_dir . '\build'); 17 | 18 | // start build 19 | cmd()->cd($this->source_dir) 20 | ->execWithWrapper( 21 | $this->builder->makeSimpleWrapper('cmake'), 22 | '-B build ' . 23 | '-A x64 ' . 24 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 25 | '-DCMAKE_BUILD_TYPE=Release ' . 26 | '-DBUILD_SHARED_LIBS=OFF ' . 27 | '-DBUILD_STATIC_LIBS=ON ' . 28 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 29 | ) 30 | ->execWithWrapper( 31 | $this->builder->makeSimpleWrapper('cmake'), 32 | "--build build --config Release --target install -j{$this->builder->concurrency}" 33 | ); 34 | rename(BUILD_LIB_PATH . '\librabbitmq.4.lib', BUILD_LIB_PATH . '\rabbitmq.4.lib'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/libssh2.php: -------------------------------------------------------------------------------- 1 | builder->getLib('zlib') ? 'ON' : 'OFF'; 16 | // reset cmake 17 | FileSystem::resetDir($this->source_dir . '\build'); 18 | 19 | // start build 20 | cmd()->cd($this->source_dir) 21 | ->execWithWrapper( 22 | $this->builder->makeSimpleWrapper('cmake'), 23 | '-B build ' . 24 | '-A x64 ' . 25 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 26 | '-DCMAKE_BUILD_TYPE=Release ' . 27 | '-DBUILD_SHARED_LIBS=OFF ' . 28 | '-DBUILD_STATIC_LIBS=ON ' . 29 | '-DBUILD_TESTING=OFF ' . 30 | "-DENABLE_ZLIB_COMPRESSION={$zlib} " . 31 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 32 | ) 33 | ->execWithWrapper( 34 | $this->builder->makeSimpleWrapper('cmake'), 35 | "--build build --config Release --target install -j{$this->builder->concurrency}" 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/libzip.php: -------------------------------------------------------------------------------- 1 | source_dir . '\build'); 17 | 18 | $openssl = $this->builder->getLib('openssl') ? 'ON' : 'OFF'; 19 | $zstd = $this->builder->getLib('zstd') ? 'ON' : 'OFF'; 20 | 21 | // start build 22 | cmd()->cd($this->source_dir) 23 | ->execWithWrapper( 24 | $this->builder->makeSimpleWrapper('cmake'), 25 | '-B build ' . 26 | '-A x64 ' . 27 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 28 | '-DCMAKE_BUILD_TYPE=Release ' . 29 | '-DBUILD_SHARED_LIBS=OFF ' . 30 | '-DENABLE_BZIP2=ON ' . 31 | '-DENABLE_LZMA=ON ' . 32 | "-DENABLE_ZSTD={$zstd} " . 33 | "-DENABLE_OPENSSL={$openssl} " . 34 | '-DBUILD_TOOLS=OFF ' . 35 | '-DBUILD_DOC=OFF ' . 36 | '-DBUILD_EXAMPLES=OFF ' . 37 | '-DBUILD_REGRESS=OFF ' . 38 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 39 | ) 40 | ->execWithWrapper( 41 | $this->builder->makeSimpleWrapper('cmake'), 42 | "--build build --config Release --target install -j{$this->builder->concurrency}" 43 | ); 44 | copy(BUILD_LIB_PATH . '\zip.lib', BUILD_LIB_PATH . '\libzip_a.lib'); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/nghttp2.php: -------------------------------------------------------------------------------- 1 | source_dir . '\build'); 17 | 18 | // start build 19 | cmd()->cd($this->source_dir) 20 | ->execWithWrapper( 21 | $this->builder->makeSimpleWrapper('cmake'), 22 | '-B build ' . 23 | '-A x64 ' . 24 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 25 | '-DCMAKE_BUILD_TYPE=Release ' . 26 | '-DENABLE_SHARED_LIB=OFF ' . 27 | '-DENABLE_STATIC_LIB=ON ' . 28 | '-DBUILD_STATIC_LIBS=ON ' . 29 | '-DBUILD_SHARED_LIBS=OFF ' . 30 | '-DENABLE_STATIC_CRT=ON ' . 31 | '-DENABLE_LIB_ONLY=ON ' . 32 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 33 | ) 34 | ->execWithWrapper( 35 | $this->builder->makeSimpleWrapper('cmake'), 36 | "--build build --config Release --target install -j{$this->builder->concurrency}" 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/onig.php: -------------------------------------------------------------------------------- 1 | source_dir . '\build'); 17 | 18 | // start build 19 | cmd()->cd($this->source_dir) 20 | ->execWithWrapper( 21 | $this->builder->makeSimpleWrapper('cmake'), 22 | '-B build ' . 23 | '-A x64 ' . 24 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 25 | '-DCMAKE_BUILD_TYPE=Release ' . 26 | '-DBUILD_SHARED_LIBS=OFF ' . 27 | '-DBUILD_STATIC_LIBS=ON ' . 28 | '-DMSVC_STATIC_RUNTIME=ON ' . 29 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 30 | ) 31 | ->execWithWrapper( 32 | $this->builder->makeSimpleWrapper('cmake'), 33 | "--build build --config Release --target install -j{$this->builder->concurrency}" 34 | ); 35 | copy(BUILD_LIB_PATH . '/onig.lib', BUILD_LIB_PATH . '/onig_a.lib'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/pthreads4w.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 14 | ->execWithWrapper( 15 | $this->builder->makeSimpleWrapper( 16 | 'nmake /E /nologo /f Makefile ' . 17 | 'DESTROOT=' . BUILD_ROOT_PATH . ' ' . 18 | 'XCFLAGS="/MT" ' . // no dll 19 | 'EHFLAGS="/I. /DHAVE_CONFIG_H /Os /Ob2 /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED"' 20 | ), 21 | 'pthreadVC3.inlined_static_stamp' 22 | ); 23 | copy($this->source_dir . '\libpthreadVC3.lib', BUILD_LIB_PATH . '\libpthreadVC3.lib'); 24 | copy($this->source_dir . '\_ptw32.h', BUILD_INCLUDE_PATH . '\_ptw32.h'); 25 | copy($this->source_dir . '\pthread.h', BUILD_INCLUDE_PATH . '\pthread.h'); 26 | copy($this->source_dir . '\sched.h', BUILD_INCLUDE_PATH . '\sched.h'); 27 | copy($this->source_dir . '\semaphore.h', BUILD_INCLUDE_PATH . '\semaphore.h'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/qdbm.php: -------------------------------------------------------------------------------- 1 | cd($this->source_dir) 16 | ->execWithWrapper( 17 | $this->builder->makeSimpleWrapper('nmake'), 18 | '/f VCMakefile' 19 | ); 20 | copy($this->source_dir . '\qdbm_a.lib', BUILD_LIB_PATH . '\qdbm_a.lib'); 21 | copy($this->source_dir . '\depot.h', BUILD_INCLUDE_PATH . '\depot.h'); 22 | // FileSystem::copyDir($this->source_dir . '\include\curl', BUILD_INCLUDE_PATH . '\curl'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/sqlite.php: -------------------------------------------------------------------------------- 1 | source_dir . '/Makefile'); 14 | return true; 15 | } 16 | 17 | protected function build(): void 18 | { 19 | cmd()->cd($this->source_dir)->execWithWrapper($this->builder->makeSimpleWrapper('nmake'), 'PREFIX=' . BUILD_ROOT_PATH . ' install-static'); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/xz.php: -------------------------------------------------------------------------------- 1 | source_dir . '\build'); 17 | 18 | // start build 19 | cmd()->cd($this->source_dir) 20 | ->execWithWrapper( 21 | $this->builder->makeSimpleWrapper('cmake'), 22 | '-B build ' . 23 | '-A x64 ' . 24 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 25 | '-DCMAKE_BUILD_TYPE=Release ' . 26 | '-DBUILD_SHARED_LIBS=OFF ' . 27 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 28 | ) 29 | ->execWithWrapper( 30 | $this->builder->makeSimpleWrapper('cmake'), 31 | "--build build --config Release --target install -j{$this->builder->concurrency}" 32 | ); 33 | 34 | // copy liblzma.lib to liblzma_a.lib 35 | copy(BUILD_LIB_PATH . '/liblzma.lib', BUILD_LIB_PATH . '/liblzma_a.lib'); 36 | // patch lzma.h 37 | FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '/lzma.h', 'defined(LZMA_API_STATIC)', 'defined(_WIN32)'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/SPC/builder/windows/library/zlib.php: -------------------------------------------------------------------------------- 1 | source_dir . '\build'); 17 | 18 | // start build 19 | cmd()->cd($this->source_dir) 20 | ->execWithWrapper( 21 | $this->builder->makeSimpleWrapper('cmake'), 22 | '-B build ' . 23 | '-A x64 ' . 24 | "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . 25 | '-DCMAKE_BUILD_TYPE=Release ' . 26 | '-DBUILD_SHARED_LIBS=OFF ' . 27 | '-DSKIP_INSTALL_FILES=ON ' . 28 | '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' 29 | ) 30 | ->execWithWrapper( 31 | $this->builder->makeSimpleWrapper('cmake'), 32 | "--build build --config Release --target install -j{$this->builder->concurrency}" 33 | ); 34 | copy(BUILD_LIB_PATH . '\zlibstatic.lib', BUILD_LIB_PATH . '\zlib_a.lib'); 35 | unlink(BUILD_ROOT_PATH . '\bin\zlib.dll'); 36 | unlink(BUILD_LIB_PATH . '\zlib.lib'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/SPC/command/BuildCommand.php: -------------------------------------------------------------------------------- 1 | addOption('with-sdk-binary-dir', null, InputOption::VALUE_REQUIRED, 'path to binary sdk'); 18 | $this->addOption('vs-ver', null, InputOption::VALUE_REQUIRED, 'vs version, e.g. "17" for Visual Studio 2022'); 19 | $this->addOption('arch', null, InputOption::VALUE_REQUIRED, 'architecture, "x64" or "arm64"', 'x64'); 20 | break; 21 | case 'Linux': 22 | case 'Darwin': 23 | $this->addOption('cc', null, InputOption::VALUE_REQUIRED, 'C compiler'); 24 | $this->addOption('cxx', null, InputOption::VALUE_REQUIRED, 'C++ compiler'); 25 | $this->addOption('ar', null, InputOption::VALUE_REQUIRED, 'ar'); 26 | $this->addOption('ld', null, InputOption::VALUE_REQUIRED, 'ld'); 27 | $this->addOption('arch', null, InputOption::VALUE_REQUIRED, 'architecture', php_uname('m')); 28 | break; 29 | } 30 | 31 | $this->addOption('with-clean', null, null, 'fresh build, remove `source` dir before `make`'); 32 | $this->addOption('bloat', null, null, 'add all libraries into binary'); 33 | $this->addOption('rebuild', 'r', null, 'Delete old build and rebuild'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/SPC/command/ExtractCommand.php: -------------------------------------------------------------------------------- 1 | addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated'); 23 | } 24 | 25 | /** 26 | * @throws WrongUsageException 27 | * @throws FileSystemException 28 | * @throws RuntimeException 29 | */ 30 | public function handle(): int 31 | { 32 | $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); 33 | if (empty($sources)) { 34 | $this->output->writeln('sources cannot be empty, at least contain one !'); 35 | return static::FAILURE; 36 | } 37 | SourceManager::initSource(sources: $sources); 38 | logger()->info('Extract done !'); 39 | return static::SUCCESS; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/SPC/command/dev/PhpVerCommand.php: -------------------------------------------------------------------------------- 1 | no_motd = true; 18 | parent::initialize($input, $output); 19 | } 20 | 21 | public function handle(): int 22 | { 23 | // Find php from source/php-src 24 | $file = SOURCE_PATH . '/php-src/main/php_version.h'; 25 | if (!file_exists($file)) { 26 | $this->output->writeln('PHP source not found, maybe you need to extract first ?'); 27 | 28 | return static::FAILURE; 29 | } 30 | 31 | $result = preg_match('/#define PHP_VERSION "([^"]+)"/', file_get_contents($file), $match); 32 | if ($result === false) { 33 | $this->output->writeln('PHP source not found, maybe you need to extract first ?'); 34 | 35 | return static::FAILURE; 36 | } 37 | 38 | $this->output->writeln('' . $match[1] . ''); 39 | return static::SUCCESS; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/SPC/doctor/AsCheckItem.php: -------------------------------------------------------------------------------- 1 | message; 24 | } 25 | 26 | public function getFixItem(): string 27 | { 28 | return $this->fix_item; 29 | } 30 | 31 | public function getFixParams(): array 32 | { 33 | return $this->fix_params; 34 | } 35 | 36 | public function isOK(): bool 37 | { 38 | return $this->ok; 39 | } 40 | 41 | public function setFixItem(string $fix_item = '', array $fix_params = []): void 42 | { 43 | $this->fix_item = $fix_item; 44 | $this->fix_params = $fix_params; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/SPC/doctor/item/OSCheckList.php: -------------------------------------------------------------------------------- 1 | whoops = new $whoops_class(); 20 | $this->whoops->allowQuit(false); 21 | $this->whoops->writeToOutput(false); 22 | $this->whoops->pushHandler(new $collision_class()); 23 | $this->whoops->register(); 24 | } 25 | } 26 | 27 | public static function getInstance(): ExceptionHandler 28 | { 29 | if (self::$obj === null) { 30 | self::$obj = new self(); 31 | } 32 | return self::$obj; 33 | } 34 | 35 | public function handle(\Throwable $e): void 36 | { 37 | if (is_null($this->whoops)) { 38 | logger()->error('Uncaught ' . get_class($e) . ': ' . $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')'); 39 | logger()->error($e->getTraceAsString()); 40 | return; 41 | } 42 | $this->whoops->handleException($e); 43 | 44 | logger()->critical('You can report this exception to static-php-cli GitHub repo.'); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/SPC/exception/FileSystemException.php: -------------------------------------------------------------------------------- 1 | info("using basic github token for {$method} {$url}"); 25 | } else { 26 | $auth = getenv('GITHUB_TOKEN'); 27 | $headers[] = "Authorization: Bearer {$auth}"; 28 | logger()->info("using bearer github token for {$method} {$url}"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/SPC/store/source/CustomSourceBase.php: -------------------------------------------------------------------------------- 1 | 'https://www.postgresql.org/ftp/source/', 31 | 'regex' => '/href="(?v(?[^"]+)\/)"/', 32 | ]); 33 | return [ 34 | 'type' => 'url', 35 | 'url' => "https://ftp.postgresql.org/pub/source/{$filename}postgresql-{$version}.tar.gz", 36 | ]; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/SPC/util/CustomExt.php: -------------------------------------------------------------------------------- 1 | getAttributes(CustomExt::class) as $attribute) { 30 | self::$custom_ext_class[$attribute->getArguments()[0]] = $class; 31 | } 32 | } 33 | } 34 | 35 | public static function getExtClass(string $ext_name): string 36 | { 37 | return self::$custom_ext_class[$ext_name] ?? Extension::class; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/globals/ext-tests/bcmath.php: -------------------------------------------------------------------------------- 1 | loadHtml('Hello'); 8 | assert($doc->getElementById('app')->nodeValue === 'Hello'); 9 | -------------------------------------------------------------------------------- /src/globals/ext-tests/filter.php: -------------------------------------------------------------------------------- 1 | parse('1.100')) === '1100'); 9 | -------------------------------------------------------------------------------- /src/globals/ext-tests/msgpack.php: -------------------------------------------------------------------------------- 1 | runChecks(); 20 | foreach ($id as $item) { 21 | $this->assertInstanceOf('SPC\doctor\AsCheckItem', $item); 22 | } 23 | } 24 | } 25 | --------------------------------------------------------------------------------