diff --git a/.github/workflows/build-linux-arm.yml b/.github/workflows/build-linux-arm.yml index cd5acd53..34912f21 100644 --- a/.github/workflows/build-linux-arm.yml +++ b/.github/workflows/build-linux-arm.yml @@ -12,9 +12,10 @@ on: version: required: true description: php version to compile - default: '8.2' + default: '8.3' type: choice options: + - '8.4' - '8.3' - '8.2' - '8.1' diff --git a/.github/workflows/build-linux-x86_64.yml b/.github/workflows/build-linux-x86_64.yml index a637dd7c..8fb28667 100644 --- a/.github/workflows/build-linux-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -6,9 +6,10 @@ on: version: required: true description: php version to compile - default: '8.2' + default: '8.3' type: choice options: + - '8.4' - '8.3' - '8.2' - '8.1' diff --git a/.github/workflows/build-macos-aarch64.yml b/.github/workflows/build-macos-aarch64.yml index 0ffe4bd2..f8d6033f 100644 --- a/.github/workflows/build-macos-aarch64.yml +++ b/.github/workflows/build-macos-aarch64.yml @@ -6,9 +6,10 @@ on: version: required: true description: php version to compile - default: '8.2' + default: '8.3' type: choice options: + - '8.4' - '8.3' - '8.2' - '8.1' diff --git a/.github/workflows/build-macos-x86_64.yml b/.github/workflows/build-macos-x86_64.yml index d02bd09f..488f7f3e 100644 --- a/.github/workflows/build-macos-x86_64.yml +++ b/.github/workflows/build-macos-x86_64.yml @@ -6,14 +6,13 @@ on: version: required: true description: php version to compile - default: '8.2' + default: '8.3' type: choice options: + - '8.4' - '8.3' - '8.2' - '8.1' - - '8.0' - - '7.4' build-cli: description: build cli binary default: true @@ -35,6 +34,10 @@ on: debug: description: enable debug logs type: boolean + no-strip: + description: keep debug symbols for debugging + type: boolean + default: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -80,13 +83,15 @@ jobs: uses: actions/cache@v4 with: path: downloads - key: php-${{ env.INPUT_HASH }} + key: php-${{ inputs.version }}-macos-x86_64 # With or without debug - if: inputs.debug == true run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV - if: inputs.prefer-pre-built == true run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV + - if: inputs.no-strip == true + run: echo "SPC_NO_STRIP=--no-strip" >> $env:GITHUB_ENV # With target select: cli, micro or both - if: ${{ inputs.build-cli == true }} @@ -97,11 +102,10 @@ jobs: run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV # If there's no dependencies cache, fetch sources, with or without debug - - if: steps.cache-download.outputs.cache-hit != 'true' - run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }} + - run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }} --ignore-cache-sources=php-src # Run build command - - run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} + - run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_NO_STRIP }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} # Upload cli executable - if: ${{ inputs.build-cli == true }} diff --git a/.github/workflows/build-windows-x86_64.yml b/.github/workflows/build-windows-x86_64.yml index 17664851..32b63652 100644 --- a/.github/workflows/build-windows-x86_64.yml +++ b/.github/workflows/build-windows-x86_64.yml @@ -9,6 +9,7 @@ on: default: '8.2' type: choice options: + - '8.4' - '8.3' - '8.2' - '8.1' diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml new file mode 100644 index 00000000..4e7bd314 --- /dev/null +++ b/.github/workflows/ext-matrix-tests.yml @@ -0,0 +1,148 @@ +name: "Extension matrix tests" + +on: + workflow_dispatch: + pull_request: + branches: [ "main" ] + paths: + - '.github/workflows/ext-matrix-tests.yml' + +jobs: + test: + name: "${{ matrix.extension }} (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})" + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + extension: + - amqp + - apcu + - bcmath + - bz2 + - calendar + - ctype + - curl + - dba + - dom + - ds + - event + - exif + - filter + - fileinfo + - ftp + - gd + - gettext + - gmp + - iconv + - igbinary + - imagick + - imap + - intl + - ldap + - mbstring,mbregex + - memcache + - mysqli,mysqlnd,pdo_mysql + - opcache + - openssl + - pcntl + - password-argon2 + - pcntl + - pdo + - pgsql,pdo_pgsql + - phar + - posix + - rar + - protobuf + - readline + - redis + - session + - shmop + - simdjson + - simplexml,xml + - snappy + - soap + - sockets + - sodium + - sqlite3,pdo_sqlite + - sqlsrv + - ssh2 + - swoole + - swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite + - swow + - sysvmsg,sysvsem,sysvshm + - tidy + - tokenizer + - uuid + - uv + - xhprof + - xlswriter + - xmlwriter,xmlreader + - xsl + - yac + - yaml + - zip + - zlib + - zstd + php-version: + - "8.4" + operating-system: + - "ubuntu-latest" + #- "macos-13" + #- "debian-arm64-self-hosted" + - "macos-14" + + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + + - name: OS type + id: os-type + run: | + OS="" + if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then + OS="linux-x86_64" + elif [ "${{ matrix.operating-system }}" = "macos-13" ]; then + OS="macos-x86_64" + elif [ "${{ matrix.operating-system }}" = "debian-arm64-self-hosted" ]; then + OS="linux-aarch64" + elif [ "${{ matrix.operating-system }}" = "macos-14" ]; then + OS="macos-aarch64" + fi + echo "OS=$OS" >> $GITHUB_ENV + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + tools: pecl, composer + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + env: + phpts: nts + + - name: "Install Dependencies" + run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - id: cache-download + uses: actions/cache@v4 + with: + path: downloads + key: php-${{ matrix.php-version }}-dependencies-for-tests + + # If there's no dependencies cache, fetch sources + - name: "Download sources" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./bin/spc download --with-php=${{ matrix.php-version }} --for-extensions=${{ matrix.extension }} --debug --ignore-cache-sources=php-src + + - name: "Build library: ${{ matrix.library }}" + run: | + SPC_USE_SUDO=yes ./bin/spc doctor --auto-fix + if [ "${{ env.OS }}" = "linux-x86_64" ]; then + ./bin/spc install-pkg upx + UPX=--with-upx-pack + elif [ "${{ env.OS }}" = "linux-aarch64" ]; then + ./bin/spc install-pkg upx + UPX=--with-upx-pack + fi + ./bin/spc build --build-cli --build-micro --build-fpm ${{ matrix.extension }} --debug $UPX --with-suggested-libs --with-suggested-exts diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1088c104..fc91093c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -82,6 +82,7 @@ jobs: - php: '8.1' - php: '8.2' - php: '8.3' + - php: '8.4' steps: - name: "Checkout" @@ -109,24 +110,41 @@ jobs: - name: "Run PHPUnit Tests" run: | - vendor/bin/phpunit tests/ --no-coverage + SPC_NO_MUSL_PATH=yes vendor/bin/phpunit tests/ --no-coverage + + define-matrix: + name: "Define Matrix" + runs-on: ubuntu-latest + outputs: + php: ${{ steps.gendef.outputs.php }} + os: ${{ steps.gendef.outputs.os }} + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + + - name: Define + id: gendef + run: | + PHP_VERSIONS=$(php src/globals/test-extensions.php php) + OS_VERSIONS=$(php src/globals/test-extensions.php os) + echo 'php='"$PHP_VERSIONS" >> "$GITHUB_OUTPUT" + echo 'os='"$OS_VERSIONS" >> "$GITHUB_OUTPUT" + build: name: "Build PHP Test (PHP ${{ matrix.php }} ${{ matrix.os }})" runs-on: ${{ matrix.os }} + needs: define-matrix timeout-minutes: 120 strategy: matrix: - php: - - "8.0" - - "8.1" - - "8.2" - - "8.3" - os: - - ubuntu-latest - - macos-13 - - windows-latest - - macos-14 + php: ${{ fromJSON(needs.define-matrix.outputs.php) }} + os: ${{ fromJSON(needs.define-matrix.outputs.os) }} fail-fast: false steps: - name: "Checkout" @@ -139,6 +157,8 @@ jobs: tools: pecl, composer extensions: curl, openssl, mbstring ini-values: memory_limit=-1 + env: + phpts: nts - name: "Cache composer packages" id: composer-cache @@ -154,13 +174,13 @@ jobs: uses: actions/cache@v4 with: path: downloads - key: php-${{ matrix.php }}-dependencies + key: php-dependencies-${{ matrix.os }} - name: "Install Dependencies" run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - name: "Run Build Tests (doctor)" - run: bin/spc doctor --auto-fix + run: bin/spc doctor --auto-fix --debug - name: "Prepare UPX for Windows" if: matrix.os == 'windows-latest' @@ -175,19 +195,11 @@ jobs: echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $GITHUB_ENV - name: "Run Build Tests (download)" - run: | - bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=5 --shallow-clone + run: php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }} - - name: "Download pre-built libraries for pkg-config" + - name: "Run Build Tests (build)" + run: php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }} + + - name: "Run Build Tests (build - embed for non-windows)" if: matrix.os != 'windows-latest' - run: | - bin/spc del-download pkg-config - bin/spc download pkg-config --prefer-pre-built --debug - - - name: "Run Build Tests (build, *nix)" - if: matrix.os != 'windows-latest' - run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) $(php src/globals/test-extensions.php no_strip) $UPX_CMD --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug - - - name: "Run Build Tests (build, windows)" - if: matrix.os == 'windows-latest' - run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) $(php src/globals/test-extensions.php no_strip) $env:UPX_CMD --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --debug \ No newline at end of file + run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }} diff --git a/README-zh.md b/README-zh.md index 3f8c31df..b9f74c81 100755 --- a/README-zh.md +++ b/README-zh.md @@ -82,16 +82,18 @@ static-php-cli(简称 `spc`)有许多特性: > > :x: 不支持 -| PHP Version | Status | Comment | -|-------------|--------------------|------------------------------| -| 7.2 | :x: | | -| 7.3 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | -| 7.4 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | -| 8.0 | :heavy_check_mark: | PHP 官方已停止 8.0 的维护 | -| 8.1 | :heavy_check_mark: | PHP 官方仅对 8.1 提供安全更新 | -| 8.2 | :heavy_check_mark: | | -| 8.3 | :heavy_check_mark: | | -| 8.4 | :x: | WIP | +| PHP Version | Status | Comment | +|-------------|--------------------|----------------------------------------------| +| 7.2 | :x: | | +| 7.3 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | +| 7.4 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | +| 8.0 | :warning: | PHP 官方已停止 8.0 的维护,我们不再处理 8.0 相关的 backport 支持 | +| 8.1 | :heavy_check_mark: | PHP 官方仅对 8.1 提供安全更新 | +| 8.2 | :heavy_check_mark: | | +| 8.3 | :heavy_check_mark: | | +| 8.4 | :heavy_check_mark: | | + +> 这个表格的支持状态是 static-php-cli 对构建对应版本的支持情况,不是 PHP 官方对该版本的支持情况。 ### 支持的扩展 diff --git a/README.md b/README.md index 6ef29db8..2288b028 100755 --- a/README.md +++ b/README.md @@ -89,16 +89,19 @@ Currently supported PHP versions for compilation: > > :x: not supported -| PHP Version | Status | Comment | -|-------------|--------------------|---------------------------------------------------| -| 7.2 | :x: | | -| 7.3 | :warning: | phpmicro and some extensions not supported on 7.x | -| 7.4 | :warning: | phpmicro and some extensions not supported on 7.x | -| 8.0 | :heavy_check_mark: | PHP official has stopped maintenance of 8.0 | -| 8.1 | :heavy_check_mark: | PHP official has security fixes only | -| 8.2 | :heavy_check_mark: | | -| 8.3 | :heavy_check_mark: | | -| 8.4 | :x: | WIP | +| PHP Version | Status | Comment | +|-------------|--------------------|----------------------------------------------------------------------------------------------------| +| 7.2 | :x: | | +| 7.3 | :x: | phpmicro and some extensions not supported on 7.x | +| 7.4 | :x: | phpmicro and some extensions not supported on 7.x | +| 8.0 | :warning: | PHP official has stopped maintenance of 8.0, we no longer provide backport support for version 8.0 | +| 8.1 | :heavy_check_mark: | PHP official has security fixes only | +| 8.2 | :heavy_check_mark: | | +| 8.3 | :heavy_check_mark: | | +| 8.4 | :heavy_check_mark: | | + +> This table shows the support status for static-php-cli in building the corresponding version, +> not the official PHP support status for that version. ### Supported Extensions @@ -142,7 +145,7 @@ curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-m # macOS aarch64 (Apple) curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64 # Windows (x86_64, win10 build 17063 or later) -curl.exe -fsSL -o spc.exehttps://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe +curl.exe -fsSL -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe # Add execute perm (Linux and macOS only) chmod +x ./spc diff --git a/bin/setup-runtime.ps1 b/bin/setup-runtime.ps1 index e9c152dd..d2b5c021 100644 --- a/bin/setup-runtime.ps1 +++ b/bin/setup-runtime.ps1 @@ -51,10 +51,10 @@ if ($action -eq 'add-path') { } # get php 8.1 specific version -$API = (Invoke-WebRequest -Uri "https://www.php.net/releases/index.php?json&version=8.1") | ConvertFrom-Json +$API = (Invoke-WebRequest -Uri "https://www.php.net/releases/index.php?json&version=8.3") | ConvertFrom-Json # php windows download -$PHPRuntimeUrl = "https://windows.php.net/downloads/releases/php-" + $API.version + "-Win32-vs16-x64.zip" +$PHPRuntimeUrl = "https://windows.php.net/downloads/releases/php-" + $API.version + "-nts-Win32-vs16-x64.zip" $ComposerUrl = "https://getcomposer.org/download/latest-stable/composer.phar" # create dir diff --git a/composer.json b/composer.json index 6bee5fba..d362aa81 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "require": { "php": ">= 8.1", "ext-mbstring": "*", + "ext-zlib": "*", "laravel/prompts": "^0.1.12", "symfony/console": "^5.4 || ^6 || ^7", "zhamao/logger": "^1.0" @@ -19,10 +20,10 @@ "captainhook/captainhook-phar": "^5.23", "captainhook/hook-installer": "^1.0", "friendsofphp/php-cs-fixer": "^3.25", - "humbug/box": "^4.5", + "humbug/box": "^4.5.0 || ^4.6.0", "nunomaduro/collision": "^7.8", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.3 || ^9" + "phpunit/phpunit": "^10.3 || ^9.5" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index fbdcb19e..a5378127 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "186e104804f9b096eaf08f153e52fb36", + "content-hash": "c76ada2dbca6ca234d4e03e07d947736", "packages": [ { "name": "illuminate/collections", - "version": "v10.48.13", + "version": "v10.48.22", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "994cedcd2060b65918efe46da805ac31b0563034" + "reference": "37c863cffb345869dd134eff8e646bc82a19cc96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/994cedcd2060b65918efe46da805ac31b0563034", - "reference": "994cedcd2060b65918efe46da805ac31b0563034", + "url": "https://api.github.com/repos/illuminate/collections/zipball/37c863cffb345869dd134eff8e646bc82a19cc96", + "reference": "37c863cffb345869dd134eff8e646bc82a19cc96", "shasum": "" }, "require": { @@ -59,11 +59,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-06-04T13:31:47+00:00" + "time": "2024-06-19T14:25:05+00:00" }, { "name": "illuminate/conditionable", - "version": "v10.48.13", + "version": "v10.48.22", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -109,7 +109,7 @@ }, { "name": "illuminate/contracts", - "version": "v10.48.13", + "version": "v10.48.22", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -157,7 +157,7 @@ }, { "name": "illuminate/macroable", - "version": "v10.48.13", + "version": "v10.48.22", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -203,16 +203,16 @@ }, { "name": "laravel/prompts", - "version": "v0.1.24", + "version": "v0.1.25", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "409b0b4305273472f3754826e68f4edbd0150149" + "reference": "7b4029a84c37cb2725fc7f011586e2997040bc95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/409b0b4305273472f3754826e68f4edbd0150149", - "reference": "409b0b4305273472f3754826e68f4edbd0150149", + "url": "https://api.github.com/repos/laravel/prompts/zipball/7b4029a84c37cb2725fc7f011586e2997040bc95", + "reference": "7b4029a84c37cb2725fc7f011586e2997040bc95", "shasum": "" }, "require": { @@ -255,9 +255,9 @@ "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.24" + "source": "https://github.com/laravel/prompts/tree/v0.1.25" }, - "time": "2024-06-17T13:58:22+00:00" + "time": "2024-08-12T22:06:33+00:00" }, { "name": "psr/container", @@ -314,16 +314,16 @@ }, { "name": "psr/log", - "version": "3.0.0", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", - "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", "shasum": "" }, "require": { @@ -358,9 +358,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/3.0.0" + "source": "https://github.com/php-fig/log/tree/3.0.2" }, - "time": "2021-07-14T16:46:02+00:00" + "time": "2024-09-11T13:17:53+00:00" }, { "name": "psr/simple-cache", @@ -415,16 +415,16 @@ }, { "name": "symfony/console", - "version": "v6.4.8", + "version": "v6.4.12", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "be5854cee0e8c7b110f00d695d11debdfa1a2a91" + "reference": "72d080eb9edf80e36c19be61f72c98ed8273b765" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/be5854cee0e8c7b110f00d695d11debdfa1a2a91", - "reference": "be5854cee0e8c7b110f00d695d11debdfa1a2a91", + "url": "https://api.github.com/repos/symfony/console/zipball/72d080eb9edf80e36c19be61f72c98ed8273b765", + "reference": "72d080eb9edf80e36c19be61f72c98ed8273b765", "shasum": "" }, "require": { @@ -489,7 +489,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.8" + "source": "https://github.com/symfony/console/tree/v6.4.12" }, "funding": [ { @@ -505,7 +505,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:49:08+00:00" + "time": "2024-09-20T08:15:52+00:00" }, { "name": "symfony/deprecation-contracts", @@ -576,20 +576,20 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540" + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-ctype": "*" @@ -635,7 +635,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" }, "funding": [ { @@ -651,24 +651,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a" + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/64647a7c30b2283f5d49b874d84a18fc22054b7a", - "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "suggest": { "ext-intl": "For best performance" @@ -713,7 +713,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0" }, "funding": [ { @@ -729,24 +729,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb" + "reference": "3833d7255cc303546435cb650316bff708a1c75c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/a95281b0be0d9ab48050ebd988b967875cdb9fdb", - "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", + "reference": "3833d7255cc303546435cb650316bff708a1c75c", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "suggest": { "ext-intl": "For best performance" @@ -794,7 +794,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0" }, "funding": [ { @@ -810,24 +810,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-mbstring": "*" @@ -874,7 +874,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" }, "funding": [ { @@ -890,7 +890,7 @@ "type": "tidelift" } ], - "time": "2024-06-19T12:30:46+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/service-contracts", @@ -977,16 +977,16 @@ }, { "name": "symfony/string", - "version": "v6.4.8", + "version": "v6.4.12", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "a147c0f826c4a1f3afb763ab8e009e37c877a44d" + "reference": "f8a1ccebd0997e16112dfecfd74220b78e5b284b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/a147c0f826c4a1f3afb763ab8e009e37c877a44d", - "reference": "a147c0f826c4a1f3afb763ab8e009e37c877a44d", + "url": "https://api.github.com/repos/symfony/string/zipball/f8a1ccebd0997e16112dfecfd74220b78e5b284b", + "reference": "f8a1ccebd0997e16112dfecfd74220b78e5b284b", "shasum": "" }, "require": { @@ -1043,7 +1043,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.8" + "source": "https://github.com/symfony/string/tree/v6.4.12" }, "funding": [ { @@ -1059,7 +1059,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:49:08+00:00" + "time": "2024-09-20T08:15:52+00:00" }, { "name": "zhamao/logger", @@ -1679,7 +1679,7 @@ }, { "name": "captainhook/captainhook-phar", - "version": "5.23.1", + "version": "5.23.5", "source": { "type": "git", "url": "https://github.com/captainhookphp/captainhook-phar.git", @@ -1733,7 +1733,7 @@ ], "support": { "issues": "https://github.com/captainhookphp/captainhook/issues", - "source": "https://github.com/captainhookphp/captainhook-phar/tree/5.23.1" + "source": "https://github.com/captainhookphp/captainhook-phar/tree/5.23.5" }, "funding": [ { @@ -1856,30 +1856,38 @@ }, { "name": "composer/pcre", - "version": "3.1.4", + "version": "3.3.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "04229f163664973f68f38f6f73d917799168ef24" + "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/04229f163664973f68f38f6f73d917799168ef24", - "reference": "04229f163664973f68f38f6f73d917799168ef24", + "url": "https://api.github.com/repos/composer/pcre/zipball/63aaeac21d7e775ff9bc9d45021e1745c97521c4", + "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4", "shasum": "" }, "require": { "php": "^7.4 || ^8.0" }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, "require-dev": { - "phpstan/phpstan": "^1.3", + "phpstan/phpstan": "^1.11.10", "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^5" + "phpunit/phpunit": "^8 || ^9" }, "type": "library", "extra": { "branch-alias": { "dev-main": "3.x-dev" + }, + "phpstan": { + "includes": [ + "extension.neon" + ] } }, "autoload": { @@ -1907,7 +1915,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.4" + "source": "https://github.com/composer/pcre/tree/3.3.1" }, "funding": [ { @@ -1923,28 +1931,28 @@ "type": "tidelift" } ], - "time": "2024-05-27T13:40:54+00:00" + "time": "2024-08-27T18:44:43+00:00" }, { "name": "composer/semver", - "version": "3.4.0", + "version": "3.4.3", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" + "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32", - "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", + "url": "https://api.github.com/repos/composer/semver/zipball/4313d26ada5e0c4edfbd1dc481a92ff7bff91f12", + "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^1.4", - "symfony/phpunit-bridge": "^4.2 || ^5" + "phpstan/phpstan": "^1.11", + "symfony/phpunit-bridge": "^3 || ^7" }, "type": "library", "extra": { @@ -1988,7 +1996,7 @@ "support": { "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.4.0" + "source": "https://github.com/composer/semver/tree/3.4.3" }, "funding": [ { @@ -2004,7 +2012,7 @@ "type": "tidelift" } ], - "time": "2023-08-31T09:50:34+00:00" + "time": "2024-09-19T14:15:21+00:00" }, { "name": "composer/xdebug-handler", @@ -2322,16 +2330,16 @@ }, { "name": "fidry/cpu-core-counter", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/theofidry/cpu-core-counter.git", - "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42" + "reference": "8520451a140d3f46ac33042715115e290cf5785f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/f92996c4d5c1a696a6a970e20f7c4216200fcc42", - "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/8520451a140d3f46ac33042715115e290cf5785f", + "reference": "8520451a140d3f46ac33042715115e290cf5785f", "shasum": "" }, "require": { @@ -2371,7 +2379,7 @@ ], "support": { "issues": "https://github.com/theofidry/cpu-core-counter/issues", - "source": "https://github.com/theofidry/cpu-core-counter/tree/1.1.0" + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.2.0" }, "funding": [ { @@ -2379,7 +2387,7 @@ "type": "github" } ], - "time": "2024-02-07T09:43:46+00:00" + "time": "2024-08-06T10:04:20+00:00" }, { "name": "fidry/filesystem", @@ -2450,26 +2458,26 @@ }, { "name": "filp/whoops", - "version": "2.15.4", + "version": "2.16.0", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546" + "reference": "befcdc0e5dce67252aa6322d82424be928214fa2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/a139776fa3f5985a50b509f2a02ff0f709d2a546", - "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546", + "url": "https://api.github.com/repos/filp/whoops/zipball/befcdc0e5dce67252aa6322d82424be928214fa2", + "reference": "befcdc0e5dce67252aa6322d82424be928214fa2", "shasum": "" }, "require": { - "php": "^5.5.9 || ^7.0 || ^8.0", + "php": "^7.1 || ^8.0", "psr/log": "^1.0.1 || ^2.0 || ^3.0" }, "require-dev": { - "mockery/mockery": "^0.9 || ^1.0", - "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.3", - "symfony/var-dumper": "^2.6 || ^3.0 || ^4.0 || ^5.0" + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.3.3", + "symfony/var-dumper": "^4.0 || ^5.0" }, "suggest": { "symfony/var-dumper": "Pretty print complex values better with var-dumper available", @@ -2509,7 +2517,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.15.4" + "source": "https://github.com/filp/whoops/tree/2.16.0" }, "funding": [ { @@ -2517,20 +2525,20 @@ "type": "github" } ], - "time": "2023-11-03T12:00:00+00:00" + "time": "2024-09-25T12:00:00+00:00" }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.59.3", + "version": "v3.65.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "30ba9ecc2b0e5205e578fe29973c15653d9bfd29" + "reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/30ba9ecc2b0e5205e578fe29973c15653d9bfd29", - "reference": "30ba9ecc2b0e5205e578fe29973c15653d9bfd29", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/79d4f3e77b250a7d8043d76c6af8f0695e8a469f", + "reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f", "shasum": "" }, "require": { @@ -2540,7 +2548,7 @@ "ext-filter": "*", "ext-json": "*", "ext-tokenizer": "*", - "fidry/cpu-core-counter": "^1.0", + "fidry/cpu-core-counter": "^1.2", "php": "^7.4 || ^8.0", "react/child-process": "^0.6.5", "react/event-loop": "^1.0", @@ -2560,18 +2568,18 @@ "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { - "facile-it/paraunit": "^1.3 || ^2.3", - "infection/infection": "^0.29.5", - "justinrainbow/json-schema": "^5.2", + "facile-it/paraunit": "^1.3.1 || ^2.4", + "infection/infection": "^0.29.8", + "justinrainbow/json-schema": "^5.3 || ^6.0", "keradus/cli-executor": "^2.1", - "mikey179/vfsstream": "^1.6.11", + "mikey179/vfsstream": "^1.6.12", "php-coveralls/php-coveralls": "^2.7", "php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5", - "phpunit/phpunit": "^9.6.19 || ^10.5.21 || ^11.2", - "symfony/var-dumper": "^5.4 || ^6.0 || ^7.0", - "symfony/yaml": "^5.4 || ^6.0 || ^7.0" + "phpunit/phpunit": "^9.6.21 || ^10.5.38 || ^11.4.3", + "symfony/var-dumper": "^5.4.47 || ^6.4.15 || ^7.1.8", + "symfony/yaml": "^5.4.45 || ^6.4.13 || ^7.1.6" }, "suggest": { "ext-dom": "For handling output formats in XML", @@ -2612,7 +2620,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.59.3" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.65.0" }, "funding": [ { @@ -2620,7 +2628,7 @@ "type": "github" } ], - "time": "2024-06-16T14:17:03+00:00" + "time": "2024-11-25T00:39:24+00:00" }, { "name": "humbug/box", @@ -2872,20 +2880,20 @@ }, { "name": "justinrainbow/json-schema", - "version": "v5.2.13", + "version": "5.3.0", "source": { "type": "git", "url": "https://github.com/jsonrainbow/json-schema.git", - "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793" + "reference": "feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", - "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8", + "reference": "feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "require-dev": { "friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1", @@ -2896,11 +2904,6 @@ "bin/validate-json" ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0.x-dev" - } - }, "autoload": { "psr-4": { "JsonSchema\\": "src/JsonSchema/" @@ -2936,32 +2939,33 @@ ], "support": { "issues": "https://github.com/jsonrainbow/json-schema/issues", - "source": "https://github.com/jsonrainbow/json-schema/tree/v5.2.13" + "source": "https://github.com/jsonrainbow/json-schema/tree/5.3.0" }, - "time": "2023-09-26T02:20:38+00:00" + "time": "2024-07-06T21:00:26+00:00" }, { "name": "laravel/serializable-closure", - "version": "v1.3.3", + "version": "v1.3.5", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "3dbf8a8e914634c48d389c1234552666b3d43754" + "reference": "1dc4a3dbfa2b7628a3114e43e32120cce7cdda9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/3dbf8a8e914634c48d389c1234552666b3d43754", - "reference": "3dbf8a8e914634c48d389c1234552666b3d43754", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/1dc4a3dbfa2b7628a3114e43e32120cce7cdda9c", + "reference": "1dc4a3dbfa2b7628a3114e43e32120cce7cdda9c", "shasum": "" }, "require": { "php": "^7.3|^8.0" }, "require-dev": { - "nesbot/carbon": "^2.61", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0", + "nesbot/carbon": "^2.61|^3.0", "pestphp/pest": "^1.21.3", "phpstan/phpstan": "^1.8.2", - "symfony/var-dumper": "^5.4.11" + "symfony/var-dumper": "^5.4.11|^6.2.0|^7.0.0" }, "type": "library", "extra": { @@ -2998,7 +3002,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2023-11-08T14:08:06+00:00" + "time": "2024-09-23T13:33:08+00:00" }, { "name": "myclabs/deep-copy", @@ -3114,16 +3118,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.19.1", + "version": "v4.19.4", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b" + "reference": "715f4d25e225bc47b293a8b997fe6ce99bf987d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4e1b88d21c69391150ace211e9eaf05810858d0b", - "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/715f4d25e225bc47b293a8b997fe6ce99bf987d2", + "reference": "715f4d25e225bc47b293a8b997fe6ce99bf987d2", "shasum": "" }, "require": { @@ -3132,7 +3136,7 @@ }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "bin": [ "bin/php-parse" @@ -3164,9 +3168,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.4" }, - "time": "2024-03-17T08:10:35+00:00" + "time": "2024-09-29T15:01:53+00:00" }, { "name": "nunomaduro/collision", @@ -3585,16 +3589,16 @@ }, { "name": "phar-io/gnupg", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/phar-io/gnupg.git", - "reference": "3c106d39f62ba3941f830ca24e125cb1b9290a87" + "reference": "ed8ab1740ac4e9db99500e7252911f2821357093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/gnupg/zipball/3c106d39f62ba3941f830ca24e125cb1b9290a87", - "reference": "3c106d39f62ba3941f830ca24e125cb1b9290a87", + "url": "https://api.github.com/repos/phar-io/gnupg/zipball/ed8ab1740ac4e9db99500e7252911f2821357093", + "reference": "ed8ab1740ac4e9db99500e7252911f2821357093", "shasum": "" }, "require": { @@ -3627,9 +3631,9 @@ "description": "Thin GnuPG wrapper class around the gnupg binary, mimicking the pecl/gnupg api", "support": { "issues": "https://github.com/phar-io/gnupg/issues", - "source": "https://github.com/phar-io/gnupg/tree/1.0.2" + "source": "https://github.com/phar-io/gnupg/tree/1.0.3" }, - "time": "2020-11-30T10:21:26+00:00" + "time": "2024-08-22T20:45:57+00:00" }, { "name": "phar-io/manifest", @@ -3926,16 +3930,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.29.1", + "version": "1.32.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4" + "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fcaefacf2d5c417e928405b71b400d4ce10daaf4", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6ca22b154efdd9e3c68c56f5d94670920a1c19a4", + "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4", "shasum": "" }, "require": { @@ -3967,22 +3971,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.32.0" }, - "time": "2024-05-31T08:52:43+00:00" + "time": "2024-09-26T07:23:32+00:00" }, { "name": "phpstan/phpstan", - "version": "1.11.5", + "version": "1.12.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "490f0ae1c92b082f154681d7849aee776a7c1443" + "reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/490f0ae1c92b082f154681d7849aee776a7c1443", - "reference": "490f0ae1c92b082f154681d7849aee776a7c1443", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17", + "reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17", "shasum": "" }, "require": { @@ -4027,39 +4031,39 @@ "type": "github" } ], - "time": "2024-06-17T15:10:54+00:00" + "time": "2024-09-26T12:45:22+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.31", + "version": "9.2.32", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.18 || ^5.0", + "nikic/php-parser": "^4.19.1 || ^5.1.0", "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.6" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -4068,7 +4072,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-main": "9.2.x-dev" } }, "autoload": { @@ -4097,7 +4101,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" }, "funding": [ { @@ -4105,7 +4109,7 @@ "type": "github" } ], - "time": "2024-03-02T06:37:42+00:00" + "time": "2024-08-22T04:23:01+00:00" }, { "name": "phpunit/php-file-iterator", @@ -4350,45 +4354,45 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.19", + "version": "9.6.21", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" + "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", + "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1 || ^2", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.28", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, "suggest": { @@ -4433,7 +4437,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21" }, "funding": [ { @@ -4449,7 +4453,7 @@ "type": "tidelift" } ], - "time": "2024-04-05T04:35:58+00:00" + "time": "2024-09-19T10:50:18+00:00" }, { "name": "psr/event-dispatcher", @@ -4875,31 +4879,31 @@ }, { "name": "react/socket", - "version": "v1.15.0", + "version": "v1.16.0", "source": { "type": "git", "url": "https://github.com/reactphp/socket.git", - "reference": "216d3aec0b87f04a40ca04f481e6af01bdd1d038" + "reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/socket/zipball/216d3aec0b87f04a40ca04f481e6af01bdd1d038", - "reference": "216d3aec0b87f04a40ca04f481e6af01bdd1d038", + "url": "https://api.github.com/repos/reactphp/socket/zipball/23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1", + "reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1", "shasum": "" }, "require": { "evenement/evenement": "^3.0 || ^2.0 || ^1.0", "php": ">=5.3.0", - "react/dns": "^1.11", + "react/dns": "^1.13", "react/event-loop": "^1.2", - "react/promise": "^3 || ^2.6 || ^1.2.1", - "react/stream": "^1.2" + "react/promise": "^3.2 || ^2.6 || ^1.2.1", + "react/stream": "^1.4" }, "require-dev": { "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/async": "^4 || ^3 || ^2", + "react/async": "^4.3 || ^3.3 || ^2", "react/promise-stream": "^1.4", - "react/promise-timer": "^1.10" + "react/promise-timer": "^1.11" }, "type": "library", "autoload": { @@ -4943,7 +4947,7 @@ ], "support": { "issues": "https://github.com/reactphp/socket/issues", - "source": "https://github.com/reactphp/socket/tree/v1.15.0" + "source": "https://github.com/reactphp/socket/tree/v1.16.0" }, "funding": [ { @@ -4951,7 +4955,7 @@ "type": "open_collective" } ], - "time": "2023-12-15T11:02:10+00:00" + "time": "2024-07-26T10:38:09+00:00" }, { "name": "react/stream", @@ -5996,23 +6000,23 @@ }, { "name": "seld/jsonlint", - "version": "1.10.2", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/Seldaek/jsonlint.git", - "reference": "9bb7db07b5d66d90f6ebf542f09fc67d800e5259" + "reference": "1748aaf847fc731cfad7725aec413ee46f0cc3a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/9bb7db07b5d66d90f6ebf542f09fc67d800e5259", - "reference": "9bb7db07b5d66d90f6ebf542f09fc67d800e5259", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/1748aaf847fc731cfad7725aec413ee46f0cc3a2", + "reference": "1748aaf847fc731cfad7725aec413ee46f0cc3a2", "shasum": "" }, "require": { "php": "^5.3 || ^7.0 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^1.5", + "phpstan/phpstan": "^1.11", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^8.5.13" }, "bin": [ @@ -6044,7 +6048,7 @@ ], "support": { "issues": "https://github.com/Seldaek/jsonlint/issues", - "source": "https://github.com/Seldaek/jsonlint/tree/1.10.2" + "source": "https://github.com/Seldaek/jsonlint/tree/1.11.0" }, "funding": [ { @@ -6056,7 +6060,7 @@ "type": "tidelift" } ], - "time": "2024-02-07T12:57:50+00:00" + "time": "2024-07-11T14:55:45+00:00" }, { "name": "symfony/event-dispatcher", @@ -6216,16 +6220,16 @@ }, { "name": "symfony/filesystem", - "version": "v6.4.8", + "version": "v6.4.12", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "4d37529150e7081c51b3c5d5718c55a04a9503f3" + "reference": "f810e3cbdf7fdc35983968523d09f349fa9ada12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/4d37529150e7081c51b3c5d5718c55a04a9503f3", - "reference": "4d37529150e7081c51b3c5d5718c55a04a9503f3", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/f810e3cbdf7fdc35983968523d09f349fa9ada12", + "reference": "f810e3cbdf7fdc35983968523d09f349fa9ada12", "shasum": "" }, "require": { @@ -6262,7 +6266,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.4.8" + "source": "https://github.com/symfony/filesystem/tree/v6.4.12" }, "funding": [ { @@ -6278,20 +6282,20 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:49:08+00:00" + "time": "2024-09-16T16:01:33+00:00" }, { "name": "symfony/finder", - "version": "v6.4.8", + "version": "v6.4.11", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "3ef977a43883215d560a2cecb82ec8e62131471c" + "reference": "d7eb6daf8cd7e9ac4976e9576b32042ef7253453" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/3ef977a43883215d560a2cecb82ec8e62131471c", - "reference": "3ef977a43883215d560a2cecb82ec8e62131471c", + "url": "https://api.github.com/repos/symfony/finder/zipball/d7eb6daf8cd7e9ac4976e9576b32042ef7253453", + "reference": "d7eb6daf8cd7e9ac4976e9576b32042ef7253453", "shasum": "" }, "require": { @@ -6326,7 +6330,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.4.8" + "source": "https://github.com/symfony/finder/tree/v6.4.11" }, "funding": [ { @@ -6342,7 +6346,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:49:08+00:00" + "time": "2024-08-13T14:27:37+00:00" }, { "name": "symfony/options-resolver", @@ -6413,20 +6417,20 @@ }, { "name": "symfony/polyfill-iconv", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "c027e6a3c6aee334663ec21f5852e89738abc805" + "reference": "48becf00c920479ca2e910c22a5a39e5d47ca956" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/c027e6a3c6aee334663ec21f5852e89738abc805", - "reference": "c027e6a3c6aee334663ec21f5852e89738abc805", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/48becf00c920479ca2e910c22a5a39e5d47ca956", + "reference": "48becf00c920479ca2e910c22a5a39e5d47ca956", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-iconv": "*" @@ -6473,7 +6477,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-iconv/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-iconv/tree/v1.31.0" }, "funding": [ { @@ -6489,20 +6493,20 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/process", - "version": "v6.4.8", + "version": "v6.4.12", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "8d92dd79149f29e89ee0f480254db595f6a6a2c5" + "reference": "3f94e5f13ff58df371a7ead461b6e8068900fbb3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/8d92dd79149f29e89ee0f480254db595f6a6a2c5", - "reference": "8d92dd79149f29e89ee0f480254db595f6a6a2c5", + "url": "https://api.github.com/repos/symfony/process/zipball/3f94e5f13ff58df371a7ead461b6e8068900fbb3", + "reference": "3f94e5f13ff58df371a7ead461b6e8068900fbb3", "shasum": "" }, "require": { @@ -6534,7 +6538,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.4.8" + "source": "https://github.com/symfony/process/tree/v6.4.12" }, "funding": [ { @@ -6550,7 +6554,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:49:08+00:00" + "time": "2024-09-17T12:47:12+00:00" }, { "name": "symfony/stopwatch", @@ -6616,16 +6620,16 @@ }, { "name": "symfony/var-dumper", - "version": "v6.4.8", + "version": "v6.4.11", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "ad23ca4312395f0a8a8633c831ef4c4ee542ed25" + "reference": "ee14c8254a480913268b1e3b1cba8045ed122694" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/ad23ca4312395f0a8a8633c831ef4c4ee542ed25", - "reference": "ad23ca4312395f0a8a8633c831ef4c4ee542ed25", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/ee14c8254a480913268b1e3b1cba8045ed122694", + "reference": "ee14c8254a480913268b1e3b1cba8045ed122694", "shasum": "" }, "require": { @@ -6681,7 +6685,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.4.8" + "source": "https://github.com/symfony/var-dumper/tree/v6.4.11" }, "funding": [ { @@ -6697,7 +6701,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:49:08+00:00" + "time": "2024-08-30T16:03:21+00:00" }, { "name": "thecodingmachine/safe", @@ -6954,8 +6958,9 @@ "prefer-lowest": false, "platform": { "php": ">= 8.1", - "ext-mbstring": "*" + "ext-mbstring": "*", + "ext-zlib": "*" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" } diff --git a/config/env.ini b/config/env.ini new file mode 100644 index 00000000..3d504baf --- /dev/null +++ b/config/env.ini @@ -0,0 +1,134 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; static-php-cli (spc) env configuration +; +; This file is used to set default env vars for static-php-cli build. +; As dynamic build process, some of these vars can be overwritten by CLI options. +; And you can also overwrite these vars by setting them in your shell environment. +; +; We need to use some pre-defined internal env vars, like `BUILD_ROOT_PATH`, `DOWNLOAD_PATH`, etc. +; Please note that these vars cannot be defined in this file, they are only be defined before static-php-cli running. +; Here's a list of these pre-defined internal env vars, these vars are only be defined in the static-php-cli build process if not set in the shell environment: +; +; BUILD_ROOT_PATH: the root path of the build process. (default: `$(pwd)/buildroot`) +; BUILD_INCLUDE_PATH: the path of the include files. (default: `$BUILD_ROOT_PATH/include`) +; BUILD_LIB_PATH: the path of the lib files. (default: `$BUILD_ROOT_PATH/lib`) +; BUILD_BIN_PATH: the path of the bin files. (default: `$BUILD_ROOT_PATH/bin`) +; PKG_ROOT_PATH: the root path of the package files. (default: `$(pwd)/pkgroot`) +; SOURCE_PATH: the path of the source files. (default: `$(pwd)/source`) +; DOWNLOAD_PATH: the path of the download files. (default: `$(pwd)/downloads`) +; CPU_COUNT: the count of the CPU cores. (default: `$(nproc)`) +; GNU_ARCH: the GNU arch of the current system. (default: `$(uname -m)`, e.g. `x86_64`, `aarch64`) +; MAC_ARCH: the MAC arch of the current system. (default: `$(uname -m)`, e.g. `x86_64`, `arm64`) +; +; Here's a list of env vars, these value cannot be changed anywhere: +; +; WORKING_DIR: the working directory of the build process. (default: `$(pwd)`) +; ROOT_DIR: the root directory of static-php-cli. (default: `/path/to/static-php-cli`, when running in phar or micro mode: `phar://path/to/spc.phar`) +; +; * These vars are only be defined in Unix (macOS, Linux, FreeBSD)Builder * +; PATH: static-php-cli will add `$BUILD_BIN_PATH` to PATH. +; PKG_CONFIG: static-php-cli will set `$BUILD_BIN_PATH/pkg-config` to PKG_CONFIG. +; PKG_CONFIG_PATH: static-php-cli will set `$BUILD_LIB_PATH/pkgconfig` to PKG_CONFIG_PATH. +; SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS: the default optimization CFLAGS for compiling php. (if --no-strip option is set: `-g -O0`, else: `-g -Os`) +; +; * These vars are only be defined in LinuxBuilder * +; SPC_LINUX_DEFAULT_CC: the default compiler for linux. (For alpine linux: `gcc`, default: `$GNU_ARCH-linux-musl-gcc`) +; SPC_LINUX_DEFAULT_CXX: the default c++ compiler for linux. (For alpine linux: `g++`, default: `$GNU_ARCH-linux-musl-g++`) +; SPC_LINUX_DEFAULT_AR: the default archiver for linux. (For alpine linux: `ar`, default: `$GNU_ARCH-linux-musl-ar`) +; SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD: the default LD_LIBRARY_PATH for php. (linux: `LD_LIBRARY_PATH=/usr/local/musl/$GNU_ARCH-linux-musl/lib`, default: empty) + + +[global] +; Build concurrency for make -jN, default is CPU_COUNT, this value are used in every libs. +SPC_CONCURRENCY=${CPU_COUNT} +; Ignore PHP version check before building some extensions +SPC_SKIP_PHP_VERSION_CHECK="no" +; Ignore some check item for bin/spc doctor command, comma separated (e.g. SPC_SKIP_DOCTOR_CHECK_ITEMS="if homebrew has installed") +SPC_SKIP_DOCTOR_CHECK_ITEMS="" + +[windows] +; php-sdk-binary-tools path +PHP_SDK_PATH="${WORKING_DIR}\php-sdk-binary-tools" +; upx executable path +UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe" +; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches +SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static + +[linux] +; include PATH for musl libc. +SPC_NO_MUSL_PATH=no +; compiler environments +CC=${SPC_LINUX_DEFAULT_CC} +CXX=${SPC_LINUX_DEFAULT_CXX} +AR=${SPC_LINUX_DEFAULT_AR} +LD=ld.gold +; default compiler flags, used in CMake toolchain file, openssl and pkg-config build +SPC_DEFAULT_C_FLAGS= +SPC_DEFAULT_CXX_FLAGS= +; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated) +SPC_EXTRA_LIBS= +; upx executable path +UPX_EXEC=${PKG_ROOT_PATH}/bin/upx +; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches +SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream + +; *** default build command for building php *** +; buildconf command +SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force" +; configure command +SPC_CMD_PREFIX_PHP_CONFIGURE="${SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD} ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg" +; make command +SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}" + +; *** default build vars for building php *** +; CFLAGS for configuring php +SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS}" +; CPPFLAGS for configuring php +SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}" +; LDFLAGS for configuring php +SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}" +; LIBS for configuring php +SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm" +; EXTRA_CFLAGS for `make` php +SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="${SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS} -fno-ident -fPIE" +; EXTRA_LIBS for `make` php +SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="" +; EXTRA_LDFLAGS_PROGRAM for `make` php +SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-all-static -Wl,-O1 -pie" + +[macos] +; compiler environments +CC=clang +CXX=clang++ +; default compiler flags, used in CMake toolchain file, openssl and pkg-config build +SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin" +SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin" +; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated) +SPC_EXTRA_LIBS= +; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches +SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,macos_iconv + +; *** default build command for building php *** +; buildconf command +SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force" +; configure command +SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg" +; make command +SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}" + +; *** default build vars for building php *** +; CFLAGS for configuring php +SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -Werror=unknown-warning-option" +; CPPFLAGS for configuring php +SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}" +; LDFLAGS for configuring php +SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}" +; EXTRA_CFLAGS for `make` php +SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="${SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS}" +; EXTRA_LIBS for `make` php +SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-lresolv" + +[freebsd] +; compiler environments +CC=clang +CXX=clang++ diff --git a/config/ext.json b/config/ext.json index 9555dfb1..7b7bf677 100644 --- a/config/ext.json +++ b/config/ext.json @@ -199,6 +199,19 @@ "gmssl" ] }, + "grpc": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "grpc", + "arg-type-unix": "custom", + "cpp-extension": true, + "lib-depends": [ + "grpc" + ] + }, "iconv": { "support": { "BSD": "wip" @@ -242,7 +255,8 @@ "BSD": "wip" }, "notes": true, - "type": "builtin", + "type": "external", + "source": "ext-imap", "arg-type": "custom", "lib-depends": [ "imap" @@ -510,7 +524,7 @@ }, "notes": true, "type": "builtin", - "arg-type": "with-prefix", + "arg-type": "custom", "lib-depends": [ "postgresql" ] diff --git a/config/lib.json b/config/lib.json index 5718cfb5..b7d8b51a 100644 --- a/config/lib.json +++ b/config/lib.json @@ -139,6 +139,20 @@ "Security" ] }, + "grpc": { + "source": "grpc", + "static-libs-unix": [ + "libgrpc.a", + "libcares.a" + ], + "lib-depends": [ + "zlib", + "openssl" + ], + "frameworks": [ + "CoreFoundation" + ] + }, "icu": { "source": "icu", "cpp-library": true, @@ -654,7 +668,7 @@ "liblzma.a" ], "static-libs-windows": [ - "liblzma.lib", + "lzma.lib", "liblzma_a.lib" ], "headers-unix": [ diff --git a/config/source.json b/config/source.json index f2896957..cb444e0d 100644 --- a/config/source.json +++ b/config/source.json @@ -36,9 +36,13 @@ } }, "bzip2": { - "type": "filelist", - "url": "https://sourceware.org/pub/bzip2/", - "regex": "/href=\"(?bzip2-(?[^\"]+)\\.tar\\.gz)\"/", + "alt": { + "type": "filelist", + "url": "https://sourceware.org/pub/bzip2/", + "regex": "/href=\"(?bzip2-(?[^\"]+)\\.tar\\.gz)\"/" + }, + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/bzip2/bzip2-1.0.8.tar.gz", "provide-pre-built": true, "license": { "type": "text", @@ -119,6 +123,18 @@ "path": "LICENSE" } }, + "ext-imap": { + "type": "url", + "url": "https://pecl.php.net/get/imap", + "path": "php-src/ext/imap", + "filename": "imap.tgz", + "license": { + "type": "file", + "path": [ + "LICENSE" + ] + } + }, "ext-memcache": { "type": "url", "url": "https://pecl.php.net/get/memcache", @@ -228,6 +244,16 @@ "path": "LICENSE" } }, + "grpc": { + "type": "git", + "rev": "v1.68.x", + "url": "https://github.com/grpc/grpc.git", + "provide-pre-built": true, + "license": { + "type": "file", + "path": "LICENSE" + } + }, "icu": { "type": "ghrel", "repo": "unicode-org/icu", @@ -530,7 +556,7 @@ "micro": { "type": "git", "path": "php-src/sapi/micro", - "rev": "master", + "rev": "84beta", "url": "https://github.com/static-php/phpmicro", "license": { "type": "file", @@ -691,10 +717,10 @@ } }, "redis": { - "type": "git", + "type": "url", + "url": "https://pecl.php.net/get/redis", "path": "php-src/ext/redis", - "rev": "release/6.0.2", - "url": "https://github.com/phpredis/phpredis", + "filename": "redis.tgz", "license": { "type": "file", "path": [ @@ -743,13 +769,18 @@ } }, "swoole": { - "type": "ghtar", "path": "php-src/ext/swoole", - "repo": "swoole/swoole-src", - "prefer-stable": true, + "type": "git", + "rev": "master", + "url": "https://github.com/swoole/swoole-src.git", "license": { "type": "file", "path": "LICENSE" + }, + "alt": { + "type": "ghtar", + "repo": "swoole/swoole-src", + "prefer-stable": true } }, "swow": { diff --git a/docs/.vitepress/components/CliGenerator.vue b/docs/.vitepress/components/CliGenerator.vue index 3a44ecdd..ca44f189 100644 --- a/docs/.vitepress/components/CliGenerator.vue +++ b/docs/.vitepress/components/CliGenerator.vue @@ -2,17 +2,29 @@

{{ I18N[lang].selectedSystem }}

- +
+
+ +

{{ I18N[lang].selectExt }}{{ checkedExts.length > 0 ? (' (' + checkedExts.length + ')') : '' }}

-
- - - + +
+
+ + +
@@ -20,7 +32,7 @@
{{ I18N[lang].selectCommon }}
{{ I18N[lang].selectNone }}
-
+
{{ I18N[lang].buildLibs }}{{ checkedLibs.length > 0 ? (' (' + checkedLibs.length + ')') : '' }}
@@ -135,24 +147,33 @@

WARNING

{{ I18N[lang].windowsDownSPCWarning }}

+ https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
{{ I18N[lang].downloadExtOnlyCommand }} -
{{ spcCommand }} download --with-php={{ selectedPhpVersion }} --for-extensions "{{ extList }}"{{ preBuilt ? ' --prefer-pre-built' : '' }}{{ debug ? ' --debug' : '' }}
+
+ {{ downloadExtCommand }} +
{{ I18N[lang].downloadAllCommand }} -
{{ spcCommand }} download --all --with-php={{ selectedPhpVersion }}{{ preBuilt ? ' --prefer-pre-built' : '' }}{{ debug ? ' --debug' : '' }}
+
+ {{ downloadAllCommand }} +
{{ I18N[lang].downloadUPXCommand }} -
{{ spcCommand }} install-pkg upx{{ debug ? ' --debug' : '' }}
+
+ {{ downloadPkgCommand }} +
{{ I18N[lang].compileCommand }} -
{{ spcCommand }} build {{ buildCommand }} "{{ extList }}"{{ additionalLibs }}{{ debug ? ' --debug' : '' }}{{ zts ? ' --enable-zts' : '' }}{{ enableUPX ? ' --with-upx-pack' : '' }}{{ displayINI }}
+
+ {{ buildCommandString }} +
@@ -170,6 +191,15 @@ import libData from '../config/lib.json'; import { getAllExtLibsByDeps } from './DependencyUtil.js'; const ext = ref(extData); +const extFilter = computed(() => { + const ls = []; + for (const [name, item] of Object.entries(ext.value)) { + if (isSupported(name, selectedSystem.value)) { + ls.push(name); + } + } + return ls; +}); const lib = ref(libData); const libContain = ref([]); @@ -234,7 +264,7 @@ const I18N = { microUnavailable: 'micro 不支持 PHP 7.4 及更早版本!', windowsSAPIUnavailable: 'Windows 目前不支持 fpm、embed 构建!', useUPX: '是否开启 UPX 压缩(减小二进制体积)', - windowsDownSPCWarning: 'Windows 下请手动下载 spc.exe 二进制文件并解压到当前目录!', + windowsDownSPCWarning: 'Windows 下请手动下载 spc.exe 二进制文件,解压到当前目录并重命名为 spc.exe!', usePreBuilt: '如果可能,下载预编译的依赖库(减少编译时间)', }, en: { @@ -268,7 +298,7 @@ const I18N = { microUnavailable: 'Micro does not support PHP 7.4 and earlier versions!', windowsSAPIUnavailable: 'Windows does not support fpm and embed build!', useUPX: 'Enable UPX compression (reduce binary size)', - windowsDownSPCWarning: 'Please download the spc.exe binary file manually and extract it to the current directory on Windows!', + windowsDownSPCWarning: 'Please download the binary file manually, extract it to the current directory and rename to spc.exe on Windows!', usePreBuilt: 'Download pre-built dependencies if possible (reduce compile time)', } }; @@ -325,7 +355,7 @@ const libDisableList = ref([]); const checkedTargets = ref(['cli']); // chosen env -const selectedEnv = ref('native'); +const selectedEnv = ref('spc'); // chosen php version const selectedPhpVersion = ref('8.2'); @@ -348,6 +378,13 @@ const enableUPX = ref(0); const hardcodedINIData = ref(''); const selectedSystem = ref('linux'); + +watch(selectedSystem, () => { + if (selectedSystem.value === 'windows') { + selectedArch.value = 'x86_64'; + } +}); + const selectedArch = ref('x86_64'); // spc command string, alt: spc-alpine-docker, spc @@ -381,6 +418,25 @@ const displayINI = computed(() => { return ' ' + str.map((x) => '-I "' + x + '"').join(' '); }); +const filterText = ref(''); + +const highlightItem = (item, step) => { + if (item.includes(filterText.value)) { + if (step === 0) { + return item.substring(0, item.indexOf(filterText.value)); + } else if (step === 1) { + return filterText.value; + } else { + return item.substring(item.indexOf(filterText.value) + filterText.value.length); + } + } else { + if (step === 0) { + return item; + } + return ''; + } +}; + const onTargetChange = (event) => { let id; if (checkedTargets.value.indexOf('all') !== -1 && event.target.value === 'all') { @@ -427,6 +483,22 @@ const calculateExtDepends = (input) => { return Array.from(result); }; +const downloadAllCommand = computed(() => { + return `${spcCommand.value} download --all --with-php=${selectedPhpVersion.value}${preBuilt.value ? ' --prefer-pre-built' : ''}${debug.value ? ' --debug' : ''}`; +}); + +const downloadExtCommand = computed(() => { + return `${spcCommand.value} download --with-php=${selectedPhpVersion.value} --for-extensions "${extList.value}"${preBuilt.value ? ' --prefer-pre-built' : ''}${debug.value ? ' --debug' : ''}`; +}); + +const downloadPkgCommand = computed(() => { + return `${spcCommand.value} install-pkg upx${debug.value ? ' --debug' : ''}`; +}); + +const buildCommandString = computed(() => { + return `${spcCommand.value} build ${buildCommand.value} "${extList.value}"${additionalLibs.value}${debug.value ? ' --debug' : ''}${zts.value ? ' --enable-zts' : ''}${enableUPX.value ? ' --with-upx-pack' : ''}${displayINI.value}`; +}); + const calculateExtLibDepends = (input) => { const result = new Set(); @@ -539,9 +611,12 @@ h2 { .command-preview { padding: 1.2rem; background: var(--vp-c-divider); + border-radius: 8px; + word-break: break-all; font-family: monospace; overflow-wrap: break-word; } + .option-line { padding: 4px 8px; } @@ -582,12 +657,38 @@ select { background-color: var(--vp-button-alt-active-bg); } .textarea { - border: 1px solid var(--vp-button-alt-border); - padding: 0 4px; - min-width: 300px; + border: 1px solid var(--vp-c-divider); + border-radius: 4px; + width: calc(100% - 12px); + padding: 4px 8px; +} + +.input { + display: block; + border: 1px solid var(--vp-c-divider); + border-radius: 4px; + width: 100%; + padding: 4px 8px; } .command-container { margin-bottom: 24px; } +.modal-button { + padding: 4px 8px; + border-radius: 4px; + border-color: var(--vp-button-alt-border); + color: var(--vp-button-alt-text); + background-color: var(--vp-button-alt-bg); +} +.modal-button:hover { + border-color: var(--vp-button-alt-hover-border); + color: var(--vp-button-alt-hover-text); + background-color: var(--vp-button-alt-hover-bg) +} +.modal-button:active { + border-color: var(--vp-button-alt-active-border); + color: var(--vp-button-alt-active-text); + background-color: var(--vp-button-alt-active-bg) +} diff --git a/docs/.vitepress/components/SearchTable.vue b/docs/.vitepress/components/SearchTable.vue new file mode 100644 index 00000000..6cfdc680 --- /dev/null +++ b/docs/.vitepress/components/SearchTable.vue @@ -0,0 +1,79 @@ + + + + + + + \ No newline at end of file diff --git a/docs/en/faq/index.md b/docs/en/faq/index.md index 7c0b381d..7cef18f6 100644 --- a/docs/en/faq/index.md +++ b/docs/en/faq/index.md @@ -2,7 +2,19 @@ Here will be some questions that you may encounter easily. There are currently many, but I need to take time to organize them. -## Can statically compiled PHP install extensions? +## What is the path of php.ini ? + +On Linux, macOS and FreeBSD, the path of `php.ini` is `/usr/local/etc/php/php.ini`. +On Windows, the path is `C:\windows\php.ini` or the current directory of `php.exe`. +The directory where to look for `php.ini` can be changed on *nix using the manual build option `--with-config-file-path`. + +In addition, on Linux, macOS and FreeBSD, `.ini` files present in the `/usr/local/etc/php/conf.d` directory will also be loaded. +On Windows, this path is empty by default. +The directory can be changed using the manual build option `--with-config-file-scan-dir`. + +`php.ini` will also be searched for in [the other standard locations](https://www.php.net/manual/configuration.file.php). + +## Can statically-compiled PHP install extensions? Because the principle of installing extensions in PHP under the traditional architecture is to install new extensions using `.so` type dynamic link libraries, and statically linked PHP compiled using this project cannot **directly** install new extensions using dynamic link libraries. @@ -72,3 +84,11 @@ For Linux systems, you can download the [cacert.pem](https://curl.se/docs/caextr For the certificate locations of different distros, please refer to [Golang docs](https://go.dev/src/crypto/x509/root_linux.go). > INI configuration `openssl.cafile` cannot be set dynamically using the `ini_set()` function, because `openssl.cafile` is a `PHP_INI_SYSTEM` type configuration and can only be set in the `php.ini` file. + +## Why don't we support older versions of PHP? + +Because older versions of PHP have many problems, such as security issues, performance issues, and functional issues. +In addition, many older versions of PHP are not compatible with the latest dependency libraries, +which is one of the reasons why older versions of PHP are not supported. + +You can use older versions compiled earlier by static-php-cli, such as PHP 8.0, but earlier versions will not be explicitly supported. diff --git a/docs/en/guide/build-on-windows.md b/docs/en/guide/build-on-windows.md index e3cf1c4e..e5c0c459 100644 --- a/docs/en/guide/build-on-windows.md +++ b/docs/en/guide/build-on-windows.md @@ -74,6 +74,12 @@ bin/setup-runtime -action add-path bin/setup-runtime -action remove-path ``` +Finally, now that you have PHP and Composer installed, you need to install static-php-cli's Composer dependencies: + +```shell +composer install +``` + ### Install other Tools (automatic) For `php-sdk-binary-tools`, `strawberry-perl`, and `nasm`, @@ -159,7 +165,8 @@ You can try to use the following commands: - `--with-clean`: clean up old make files before compiling PHP - `--enable-zts`: Make compiled PHP thread-safe version (default is NTS version) -- `--with-libs=XXX,YYY`: Compile the specified dependent library before compiling PHP, and activate some extension optional functions +- `--with-libs=XXX,YYY`: Compile the specified dependent library before compiling PHP, and activate some extension optional functions +- `--with-config-file-scan-dir=XXX`: Set the directory to scan for `.ini` files after reading `php.ini` (Check [here](../faq/index.html#what-is-the-path-of-php-ini) for default paths) - `-I xxx=yyy`: Hard compile INI options into PHP before compiling (support multiple options, alias is `--with-hardcoded-ini`) - `--with-micro-fake-cli`: When compiling micro, let micro's `PHP_SAPI` pretend to be `cli` (for compatibility with some programs that check `PHP_SAPI`) - `--disable-opcache-jit`: Disable opcache jit (enabled by default) diff --git a/docs/en/guide/cli-generator.md b/docs/en/guide/cli-generator.md index b11c0002..87163d00 100644 --- a/docs/en/guide/cli-generator.md +++ b/docs/en/guide/cli-generator.md @@ -1,3 +1,7 @@ +--- +aside: false +--- + diff --git a/docs/en/guide/env-vars.md b/docs/en/guide/env-vars.md index f60b1d2d..10581733 100644 --- a/docs/en/guide/env-vars.md +++ b/docs/en/guide/env-vars.md @@ -1,12 +1,23 @@ ---- -aside: false ---- - # Environment variables All environment variables mentioned in the list on this page have default values unless otherwise noted. You can override the default values by setting these environment variables. +## Environment variables list + +Starting from version 2.3.5, we have centralized the environment variables in the `config/env.ini` file. +You can set environment variables by modifying this file. + +We divide the environment variables supported by static-php-cli into three types: + +- Global internal environment variables: declared after static-php-cli starts, you can use `getenv()` to get them internally in static-php-cli, and you can override them before starting static-php-cli. +- Fixed environment variables: declared after static-php-cli starts, you can only use `getenv()` to get them, but you cannot override them through shell scripts. +- Config file environment variables: declared before static-php-cli build, you can set these environment variables by modifying the `config/env.ini` file or through shell scripts. + +You can read the comments for each parameter in [config/env.ini](https://github.com/crazywhalecc/static-php-cli/blob/main/config/env.ini) to understand its purpose. + +## Custom environment variables + Generally, you don't need to modify any of the following environment variables as they are already set to optimal values. However, if you have special needs, you can set these environment variables to meet your needs (for example, you need to debug PHP performance under different compilation parameters). @@ -22,94 +33,13 @@ bin/spc build mbstring,pcntl --build-cli SPC_CONCURRENCY=4 bin/spc build mbstring,pcntl --build-cli ``` -## General environment variables +Or, if you need to modify an environment variable for a long time, you can modify the `config/env.ini` file. -General environment variables can be used by all build targets. +`config/env.ini` is divided into three sections, `[global]` is globally effective, `[windows]`, `[macos]`, `[linux]` are only effective for the corresponding operating system. -| var name | default value | comment | -|------------------------------|---------------------------|-------------------------------------------------| -| `BUILD_ROOT_PATH` | `{pwd}/buildroot` | The root directory of the build target | -| `BUILD_LIB_PATH` | `{pwd}/buildroot/lib` | The root directory of compilation libraries | -| `BUILD_INCLUDE_PATH` | `{pwd}/buildroot/include` | Header file directory for compiling libraries | -| `BUILD_BIN_PATH` | `{pwd}/buildroot/bin` | Compiled binary file directory | -| `PKG_ROOT_PATH` | `{pwd}/pkgroot` | Directory where precompiled tools are installed | -| `SOURCE_PATH` | `{pwd}/source` | The source code extract directory | -| `DOWNLOAD_PATH` | `{pwd}/downloads` | Downloaded file directory | -| `SPC_CONCURRENCY` | Depends on CPU cores | Number of parallel compilations | -| `SPC_SKIP_PHP_VERSION_CHECK` | empty | Skip PHP version check when set to `yes` | +For example, if you need to modify the `./configure` command for compiling PHP, you can find the `SPC_CMD_PREFIX_PHP_CONFIGURE` environment variable in the `config/env.ini` file, and then modify its value. -## OS specific variables - -These environment variables are system-specific and will only take effect on a specific OS. - -### Windows - -| var name | default value | comment | -|---------------------|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| -| `PHP_SDK_PATH` | `{pwd}\php-sdk-binary-tools` | PHP SDK tools path | -| `UPX_EXEC` | `$PKG_ROOT_PATH\bin\upx.exe` | UPX compression tool path | -| `SPC_MICRO_PATCHES` | `static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static` | Used phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) | - -### macOS - -| var name | default value | comment | -|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| -| `CC` | `clang` | C Compiler | -| `CXX` | `clang++` | C++ Compiler | -| `SPC_DEFAULT_C_FLAGS` | `--target=arm64-apple-darwin` or `--target=x86_64-apple-darwin` | Default C flags (not the same as `CFLAGS`) | -| `SPC_DEFAULT_CXX_FLAGS` | `--target=arm64-apple-darwin` or `--target=x86_64-apple-darwin` | Default C flags (not the same as `CPPFLAGS`) | -| `SPC_CMD_PREFIX_PHP_BUILDCONF` | `./buildconf --force` | PHP `buildconf` command prefix | -| `SPC_CMD_PREFIX_PHP_CONFIGURE` | `./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg` | PHP `configure` command prefix | -| `SPC_CMD_PREFIX_PHP_MAKE` | `make -j$SPC_CONCURRENCY` | PHP `make` command prefix | -| `SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS` | `$SPC_DEFAULT_C_FLAGS -Werror=unknown-warning-option` | `CFLAGS` variable of PHP `configure` command | -| `SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS` | `-I$BUILD_INCLUDE_PATH` | `CPPFLAGS` variable of PHP `configure` command | -| `SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS` | `-L$BUILD_LIB_PATH` | `LDFLAGS` variable of PHP `configure` command | -| `SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS` | `-g0 -Os` or `-g -O0` (the latter when using `--no-strip`) | `EXTRA_CFLAGS` variable of PHP `make` command | -| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | `-lresolv` | Extra `EXTRA_LIBS` variables for PHP `make` command | -| `SPC_MICRO_PATCHES` | `static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,macos_iconv` | Used phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) | - -### Linux - -| var name | default value | comment | -|----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| -| `UPX_EXEC` | `$PKG_ROOT_PATH/bin/upx` | UPX compression tool path | -| `GNU_ARCH` | `x86_64` or `aarch64` | CPU architecture | -| `CC` | Alpine: `gcc`, Other: `$GNU_ARCH-linux-musl-gcc` | C Compiler | -| `CXX` | Alpine: `g++`, Other: `$GNU_ARCH-linux-musl-g++` | C++ Compiler | -| `AR` | Alpine: `ar`, Other: `$GNU_ARCH-linux-musl-ar` | Static library tools | -| `LD` | `ld.gold` | Linker | -| `PATH` | `/usr/local/musl/bin:/usr/local/musl/$GNU_ARCH-linux-musl/bin:$PATH` | System PATH | -| `SPC_DEFAULT_C_FLAGS` | empty | Default C flags | -| `SPC_DEFAULT_CXX_FLAGS` | empty | Default C++ flags | -| `SPC_CMD_PREFIX_PHP_BUILDCONF` | `./buildconf --force` | PHP `buildconf` command prefix | -| `SPC_CMD_PREFIX_PHP_CONFIGURE` | `LD_LIBRARY_PATH={ld_lib_path} ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg` | PHP `configure` command prefix | -| `SPC_CMD_PREFIX_PHP_MAKE` | `make -j$SPC_CONCURRENCY` | PHP `make` command prefix | -| `SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS` | `$SPC_DEFAULT_C_FLAGS` | `CFLAGS` variable of PHP `configure` command | -| `SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS` | `-I$BUILD_INCLUDE_PATH` | `CPPFLAGS` variable of PHP `configure` command | -| `SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS` | `-L$BUILD_LIB_PATH` | `LDFLAGS` variable of PHP `configure` command | -| `SPC_CMD_VAR_PHP_CONFIGURE_LIBS` | `-ldl -lpthread` | `LIBS` variable of PHP `configure` command | -| `SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS` | `-g0 -Os -fno-ident -fPIE` or `-g -O0 -fno-ident -fPIE` (the latter when using `--no-strip`) | `EXTRA_CFLAGS` variable of PHP `make` command | -| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | empty | Extra `EXTRA_LIBS` variables for PHP `make` command | -| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM` | `-all-static` (when using `clang`: `-Xcompiler -fuse-ld=lld -all-static`) | Additional `LDFLAGS` variable for `make` command | -| `SPC_NO_MUSL_PATH` | empty | Whether to not insert the PATH of the musl toolchain (not inserted when the value is `yes`) | -| `SPC_MICRO_PATCHES` | `static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream` | Used phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) | -> `{ld_lib_path}` value is `/usr/local/musl/$GNU_ARCH-linux-musl/lib`。 - -### FreeBSD - -Due to the small number of users of the FreeBSD system, we do not provide environment variables for the FreeBSD system for the time being. - -### Unix - -For Unix systems such as macOS, Linux, FreeBSD, etc., the following environment variables are common. - -| var name | default value | comment | -|-------------------|------------------------------|----------------------------| -| `PATH` | `$BUILD_BIN_PATH:$PATH` | System PATH | -| `PKG_CONFIG_PATH` | `$BUILD_LIB_PATH/pkgconfig` | pkg-config search path | -| `PKG_CONFIG` | `$BUILD_BIN_PATH/pkg-config` | pkg-config executable path | - -## Library Environment variables (Unix only) +## Library environment variables (Unix only) Starting from 2.2.0, static-php-cli supports custom environment variables for all compilation dependent library commands of macOS, Linux, FreeBSD and other Unix systems. diff --git a/docs/en/guide/extension-notes.md b/docs/en/guide/extension-notes.md index fc6b170f..95145653 100644 --- a/docs/en/guide/extension-notes.md +++ b/docs/en/guide/extension-notes.md @@ -46,7 +46,7 @@ This extension contains an implementation of the coroutine environment for `pdo_ ## swow -1. Only PHP version >= 8.0 is supported. +1. Only PHP 8.0 ~ 8.4 is supported. ## imap diff --git a/docs/en/guide/extensions.md b/docs/en/guide/extensions.md index 14ec91d2..9ce53f63 100644 --- a/docs/en/guide/extensions.md +++ b/docs/en/guide/extensions.md @@ -1,3 +1,7 @@ + + # Extensions > - `yes`: supported @@ -5,7 +9,7 @@ > - `no` with issue link: confirmed to be unavailable due to issue > - `partial` with issue link: supported but not perfect due to issue - + ::: tip If an extension you need is missing, you can create a [Feature Request](https://github.com/crazywhalecc/static-php-cli/issues). diff --git a/docs/en/guide/index.md b/docs/en/guide/index.md index 41a6b383..6ae37db7 100644 --- a/docs/en/guide/index.md +++ b/docs/en/guide/index.md @@ -36,7 +36,7 @@ Windows currently only supports the x86_64 architecture, and does not support 32 ## Supported PHP Version -Currently, static php cli supports PHP versions 8.0 to 8.3, and theoretically supports PHP 7.4 and earlier versions. +Currently, static php cli supports PHP versions 8.1 to 8.4, and theoretically supports PHP 8.0 and earlier versions. Simply select the earlier version when downloading. However, due to some extensions and special components that have stopped supporting earlier versions of PHP, static-php-cli will not explicitly support earlier versions. diff --git a/docs/en/guide/manual-build.md b/docs/en/guide/manual-build.md index 487d3329..a0b02b08 100644 --- a/docs/en/guide/manual-build.md +++ b/docs/en/guide/manual-build.md @@ -142,9 +142,9 @@ including php-src and the source code of various dependent libraries. # Download all dependencies bin/spc download --all -# Download all dependent packages, and specify the main version of PHP to download, optional: 7.3, 7.4, 8.0, 8.1, 8.2, 8.3 +# Download all dependent packages, and specify the main version of PHP to download, optional: 8.1, 8.2, 8.3, 8.4 # Also supports specific version of php release: 8.3.10, 8.2.22, etc. -bin/spc download --all --with-php=8.2 +bin/spc download --all --with-php=8.3 # Show download progress bar while downloading (curl) bin/spc download --all --debug @@ -272,12 +272,12 @@ If you want to build multiple versions of PHP and don't want to build other depe you can use `switch-php-version` to quickly switch to another version and compile after compiling one version: ```shell -# switch to 8.3 -bin/spc switch-php-version 8.3 +# switch to 8.4 +bin/spc switch-php-version 8.4 # build bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli -# switch to 8.0 -bin/spc switch-php-version 8.0 +# switch to 8.1 +bin/spc switch-php-version 8.1 # build bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli ``` @@ -304,6 +304,8 @@ You can try to use the following commands: - `--enable-zts`: Make compiled PHP thread-safe version (default is NTS version) - `--no-strip`: Do not run `strip` after compiling the PHP library to trim the binary file to reduce its size (the macOS binary file without trim can use dynamically linked third-party extensions) - `--with-libs=XXX,YYY`: Compile the specified dependent library before compiling PHP, and activate some extended optional functions (such as libavif of the gd library, etc.) +- `--with-config-file-path=XXX`: Set the path in which to look for `php.ini` (Check [here](../faq/index.html#what-is-the-path-of-php-ini) for default paths) +- `--with-config-file-scan-dir=XXX`: Set the directory to scan for `.ini` files after reading `php.ini` (Check [here](../faq/index.html#what-is-the-path-of-php-ini) for default paths) - `-I xxx=yyy`: Hard compile INI options into PHP before compiling (support multiple options, alias is `--with-hardcoded-ini`) - `--with-micro-fake-cli`: When compiling micro, let micro's `PHP_SAPI` pretend to be `cli` (for compatibility with some programs that check `PHP_SAPI`) - `--disable-opcache-jit`: Disable opcache jit (enabled by default) @@ -551,3 +553,76 @@ If you need to build multiple times locally, the following method can save you t - If you want to rebuild once, but do not re-download the source code, you can first `rm -rf buildroot source` to delete the compilation directory and source code directory, and then rebuild. - If you want to update a version of a dependency, you can use `bin/spc del-download ` to delete the specified source code, and then use `download ` to download it again. - If you want to update all dependent versions, you can use `bin/spc download --clean` to delete all downloaded sources, and then download them again. + +## embed usage + +If you want to embed static-php into other C language programs, you can use `--build-embed` to build an embed version of PHP. + +```bash +bin/spc build {your extensions} --build-embed --debug +``` + +Under normal circumstances, PHP embed will generate `php-config` after compilation. +For static-php, we provide `spc-config` to obtain the parameters during compilation. +In addition, when using embed SAPI (libphp.a), you need to use the same compiler as libphp, otherwise there will be a link error. + +Here is the basic usage of spc-config: + +```bash +# output all flags and options +bin/spc spc-config curl,zlib,phar,openssl + +# output libs +bin/spc spc-config curl,zlib,phar,openssl --libs + +# output includes +bin/spc spc-config curl,zlib,phar,openssl --includes +``` + +By default, static-php uses the following compilers on different systems: + +- macOS: `clang` +- Linux (Alpine Linux): `gcc` +- Linux (glibc based distros, x86_64): `/usr/local/musl/bin/x86_64-linux-musl-gcc` +- Linux (glibc based distros, aarch64): `/usr/local/musl/bin/aarch64-linux-musl-gcc` +- FreeBSD: `clang` + +Here is an example of using embed SAPI: + +```c +// embed.c +#include + +int main(int argc,char **argv){ + + PHP_EMBED_START_BLOCK(argc,argv) + + zend_file_handle file_handle; + + zend_stream_init_filename(&file_handle,"embed.php"); + + if(php_execute_script(&file_handle) == FAILURE){ + php_printf("Failed to execute PHP script.\n"); + } + + PHP_EMBED_END_BLOCK() + return 0; +} +``` + + +```php + INI 配置 `openssl.cafile` 不可以使用 `ini_set()` 函数动态设置,因为 `openssl.cafile` 是一个 `PHP_INI_SYSTEM` 类型的配置,只能在 `php.ini` 文件中设置。 \ No newline at end of file +> INI 配置 `openssl.cafile` 不可以使用 `ini_set()` 函数动态设置,因为 `openssl.cafile` 是一个 `PHP_INI_SYSTEM` 类型的配置,只能在 `php.ini` 文件中设置。 + +## 为什么不支持旧版本 PHP ? + +因为旧版本的 PHP 有很多问题,比如安全问题、性能问题、功能问题等。此外,旧版本的 PHP 很多都无法与最新的依赖库兼容,这也是不支持旧版本 PHP 的原因之一。 + +你可以使用 static-php-cli 早期编译好的旧版本,如 PHP 8.0,但是不会明确支持早期版本。 diff --git a/docs/zh/guide/build-on-windows.md b/docs/zh/guide/build-on-windows.md index b2933aab..0eb587fc 100644 --- a/docs/zh/guide/build-on-windows.md +++ b/docs/zh/guide/build-on-windows.md @@ -146,6 +146,7 @@ bin/spc build "openssl" --build-cli --debug - `--with-clean`: 编译 PHP 前先清理旧的 make 产生的文件 - `--enable-zts`: 让编译的 PHP 为线程安全版本(默认为 NTS 版本) - `--with-libs=XXX,YYY`: 编译 PHP 前先编译指定的依赖库,激活部分扩展的可选功能 +- `--with-config-file-scan-dir=XXX`: 读取 `php.ini` 后扫描 `.ini` 文件的目录(在 [这里](../faq/index.html#php-ini-的路径是什么) 查看默认路径) - `-I xxx=yyy`: 编译前将 INI 选项硬编译到 PHP 内(支持多个选项,别名是 `--with-hardcoded-ini`) - `--with-micro-fake-cli`: 在编译 micro 时,让 micro 的 SAPI 伪装为 `cli`(用于兼容一些检查 `PHP_SAPI` 的程序) - `--disable-opcache-jit`: 禁用 opcache jit(默认启用) diff --git a/docs/zh/guide/cli-generator.md b/docs/zh/guide/cli-generator.md index 3b382ed3..c3936dea 100644 --- a/docs/zh/guide/cli-generator.md +++ b/docs/zh/guide/cli-generator.md @@ -1,3 +1,7 @@ +--- +aside: false +--- + diff --git a/docs/zh/guide/env-vars.md b/docs/zh/guide/env-vars.md index 6c467542..7a42d32c 100644 --- a/docs/zh/guide/env-vars.md +++ b/docs/zh/guide/env-vars.md @@ -1,11 +1,21 @@ ---- -aside: false ---- - -# 环境变量列表 +# 环境变量 本页面的环境变量列表中所提到的所有环境变量都具有默认值,除非另有说明。你可以通过设置这些环境变量来覆盖默认值。 +## 环境变量列表 + +在 2.3.5 版本之后,我们将环境变量集中到了 `config/env.ini` 文件中,你可以通过修改这个文件来设置环境变量。 + +我们将 static-php-cli 支持的环境变量分为三种: + +- 全局内部环境变量:在 static-php-cli 启动后即声明,你可以在 static-php-cli 的内部使用 `getenv()` 来获取他们,也可以在启动 static-php-cli 前覆盖。 +- 固定环境变量:在 static-php-cli 启动后声明,你仅可使用 `getenv()` 获取,但无法通过 shell 脚本对其覆盖。 +- 配置文件环境变量:在 static-php-cli 构建前声明,你可以通过修改 `config/env.ini` 文件或通过 shell 脚本来设置这些环境变量。 + +你可以阅读 [config/env.ini](https://github.com/crazywhalecc/static-php-cli/blob/main/config/env.ini) 中每项参数的注释来了解其作用(仅限英文版)。 + +## 自定义环境变量 + 一般情况下,你不需要修改任何以下环境变量,因为它们已经被设置为最佳值。 但是,如果你有特殊需求,你可以通过设置这些环境变量来满足你的需求(比如你需要调试不同编译参数下的 PHP 性能表现)。 @@ -20,93 +30,11 @@ bin/spc build mbstring,pcntl --build-cli SPC_CONCURRENCY=4 bin/spc build mbstring,pcntl --build-cli ``` -## 通用环境变量 +或者,如果你需要长期修改某个环境变量,你可以通过修改 `config/env.ini` 文件来实现。 -通用环境变量是所有构建目标都可以使用的环境变量。 +`config/env.ini` 分为三段,其中 `[global]` 全局有效,`[windows]`、`[macos]`、`[linux]` 仅对应的操作系统有效。 -| var name | default value | comment | -|------------------------------|---------------------------|-----------------------------| -| `BUILD_ROOT_PATH` | `{pwd}/buildroot` | 编译目标的根目录 | -| `BUILD_LIB_PATH` | `{pwd}/buildroot/lib` | 编译依赖库的根目录 | -| `BUILD_INCLUDE_PATH` | `{pwd}/buildroot/include` | 编译依赖库的头文件目录 | -| `BUILD_BIN_PATH` | `{pwd}/buildroot/bin` | 编译依赖库的二进制文件目录 | -| `PKG_ROOT_PATH` | `{pwd}/pkgroot` | 闭源或预编译工具下载后安装的目录 | -| `SOURCE_PATH` | `{pwd}/source` | 编译项目的源码解压缩目录 | -| `DOWNLOAD_PATH` | `{pwd}/downloads` | 下载的文件存放目录 | -| `SPC_CONCURRENCY` | 取决于当前 CPU 核心数量 | 并行编译的数量 | -| `SPC_SKIP_PHP_VERSION_CHECK` | 空 | 设置为 `yes` 时,跳过扩展对 PHP 版本的检查 | - -## 系统特定变量 - -这些环境变量是特定于系统的,它们只在特定的系统上才会生效。 - -### Windows - -| var name | default value | comment | -|---------------------|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| -| `PHP_SDK_PATH` | `{pwd}\php-sdk-binary-tools` | PHP SDK 工具的安装目录 | -| `UPX_EXEC` | `$PKG_ROOT_PATH\bin\upx.exe` | UPX 压缩工具的路径 | -| `SPC_MICRO_PATCHES` | `static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static` | 使用的 phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) | - -### macOS - -| var name | default value | comment | -|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| -| `CC` | `clang` | C 编译器 | -| `CXX` | `clang++` | C++ 编译器 | -| `SPC_DEFAULT_C_FLAGS` | `--target=arm64-apple-darwin` 或 `--target=x86_64-apple-darwin` | 默认 C 编译标志(与 `CFLAGS` 不同) | -| `SPC_DEFAULT_CXX_FLAGS` | `--target=arm64-apple-darwin` 或 `--target=x86_64-apple-darwin` | 默认 C++ 编译标志(与 `CXXFLAGS` 不同) | -| `SPC_CMD_PREFIX_PHP_BUILDCONF` | `./buildconf --force` | 编译 PHP `buildconf` 命令前缀 | -| `SPC_CMD_PREFIX_PHP_CONFIGURE` | `./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg` | 编译 PHP `configure` 命令前缀 | -| `SPC_CMD_PREFIX_PHP_MAKE` | `make -j$SPC_CONCURRENCY` | 编译 PHP `make` 命令前缀 | -| `SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS` | `$SPC_DEFAULT_C_FLAGS -Werror=unknown-warning-option` | PHP `configure` 命令的 `CFLAGS` 变量 | -| `SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS` | `-I$BUILD_INCLUDE_PATH` | PHP `configure` 命令的 `CPPFLAGS` 变量 | -| `SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS` | `-L$BUILD_LIB_PATH` | PHP `configure` 命令的 `LDFLAGS` 变量 | -| `SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS` | `-g0 -Os` 或 `-g -O0`(当使用 `--no-strip` 时为后者) | PHP `make` 命令的 `EXTRA_CFLAGS` 变量 | -| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | `-lresolv` | PHP `make` 命令的额外 `EXTRA_LIBS` 变量 | -| `SPC_MICRO_PATCHES` | `static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,macos_iconv` | 使用的 phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) | - -### Linux - -| var name | default value | comment | -|----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| -| `UPX_EXEC` | `$PKG_ROOT_PATH/bin/upx` | UPX 压缩工具的路径 | -| `GNU_ARCH` | `x86_64` 或 `aarch64` | 当前环境的 CPU 架构 | -| `CC` | Alpine: `gcc`, Other: `$GNU_ARCH-linux-musl-gcc` | C 编译器 | -| `CXX` | Alpine: `g++`, Other: `$GNU_ARCH-linux-musl-g++` | C++ 编译器 | -| `AR` | Alpine: `ar`, Other: `$GNU_ARCH-linux-musl-ar` | 静态库工具 | -| `LD` | `ld.gold` | 链接器 | -| `PATH` | `/usr/local/musl/bin:/usr/local/musl/$GNU_ARCH-linux-musl/bin:$PATH` | 系统 PATH | -| `SPC_DEFAULT_C_FLAGS` | empty | 默认 C 编译标志 | -| `SPC_DEFAULT_CXX_FLAGS` | empty | 默认 C++ 编译标志 | -| `SPC_CMD_PREFIX_PHP_BUILDCONF` | `./buildconf --force` | 编译 PHP `buildconf` 命令前缀 | -| `SPC_CMD_PREFIX_PHP_CONFIGURE` | `LD_LIBRARY_PATH={ld_lib_path} ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg` | 编译 PHP `configure` 命令前缀 | -| `SPC_CMD_PREFIX_PHP_MAKE` | `make -j$SPC_CONCURRENCY` | 编译 PHP `make` 命令前缀 | -| `SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS` | `$SPC_DEFAULT_C_FLAGS` | PHP `configure` 命令的 `CFLAGS` 变量 | -| `SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS` | `-I$BUILD_INCLUDE_PATH` | PHP `configure` 命令的 `CPPFLAGS` 变量 | -| `SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS` | `-L$BUILD_LIB_PATH` | PHP `configure` 命令的 `LDFLAGS` 变量 | -| `SPC_CMD_VAR_PHP_CONFIGURE_LIBS` | `-ldl -lpthread` | PHP `configure` 命令的 `LIBS` 变量 | -| `SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS` | `-g0 -Os -fno-ident -fPIE` 或 `-g -O0 -fno-ident -fPIE`(当使用 `--no-strip` 时为后者) | PHP `make` 命令的 `EXTRA_CFLAGS` 变量 | -| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS` | empty | PHP `make` 命令的额外 `EXTRA_LIBS` 变量 | -| `SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM` | `-all-static`(当使用 `clang` 时:`-Xcompiler -fuse-ld=lld -all-static`) | `make` 命令的额外 `LDFLAGS` 变量(用于编译程序) | -| `SPC_NO_MUSL_PATH` | empty | 是否不插入 musl 工具链的 PATH(值为 `yes` 时不插入) | -| `SPC_MICRO_PATCHES` | `static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream` | 使用的 phpmicro [patches](https://github.com/easysoft/phpmicro/blob/master/patches/Readme.md) | - -> `{ld_lib_path}` 值为 `/usr/local/musl/$GNU_ARCH-linux-musl/lib`。 - -### FreeBSD - -因 FreeBSD 系统的用户较少,我们暂时不提供 FreeBSD 系统的环境变量。 - -### Unix - -对于 macOS、Linux、FreeBSD 等 Unix 系统,以下环境变量是通用的。 - -| var name | default value | comment | -|-------------------|------------------------------|------------------| -| `PATH` | `$BUILD_BIN_PATH:$PATH` | 系统 PATH | -| `PKG_CONFIG_PATH` | `$BUILD_LIB_PATH/pkgconfig` | pkg-config 的搜索路径 | -| `PKG_CONFIG` | `$BUILD_BIN_PATH/pkg-config` | pkg-config 命令路径 | +例如,你需要修改编译 PHP 的 `./configure` 命令,你可以在 `config/env.ini` 文件中找到 `SPC_CMD_PREFIX_PHP_CONFIGURE` 环境变量,然后修改其值即可。 ## 编译依赖库的环境变量(仅限 Unix 系统) @@ -142,6 +70,7 @@ openssl_CFLAGS="-O0" | `ldap_LDFLAGS` | `-L$BUILD_LIB_PATH` | | `openssl_CFLAGS` | Linux: `$SPC_DEFAULT_C_FLAGS`, Other: empty | | others... | empty | + ::: 下表是支持自定义以上三种变量的依赖库名称列表: @@ -165,5 +94,6 @@ openssl_CFLAGS="-O0" ::: tip 因为给每个库适配自定义环境变量是一项特别繁琐的工作,且大部分情况下你都不需要这些库的自定义环境变量,所以我们目前只支持了部分库的自定义环境变量。 -如果你需要自定义环境变量的库不在上方列表,可以通过 [GitHub Issue](https://github.com/crazywhalecc/static-php-cli/issues) 来提出需求。 +如果你需要自定义环境变量的库不在上方列表,可以通过 [GitHub Issue](https://github.com/crazywhalecc/static-php-cli/issues) +来提出需求。 ::: diff --git a/docs/zh/guide/extension-notes.md b/docs/zh/guide/extension-notes.md index 4fc475e3..9c5d9296 100644 --- a/docs/zh/guide/extension-notes.md +++ b/docs/zh/guide/extension-notes.md @@ -43,7 +43,7 @@ swoole-hook-sqlite 与 `pdo_sqlite` 扩展冲突。如需使用 Swoole 和 `pdo_ ## swow -1. swow 仅支持 PHP >= 8.0 版本。 +1. swow 仅支持 PHP 8.0 ~ 8.4 版本。 ## imap diff --git a/docs/zh/guide/extensions.md b/docs/zh/guide/extensions.md index 46a561dd..43095a07 100644 --- a/docs/zh/guide/extensions.md +++ b/docs/zh/guide/extensions.md @@ -1,3 +1,7 @@ + + # 扩展列表 > - `yes`: 已支持 @@ -5,7 +9,8 @@ > - `no` with issue link: 确定不支持或无法支持 > - `partial` with issue link: 已支持,但是无法完美工作 - + + ::: tip 如果缺少您需要的扩展,您可以创建 [功能请求](https://github.com/crazywhalecc/static-php-cli/issues)。 diff --git a/docs/zh/guide/index.md b/docs/zh/guide/index.md index 7fcfafaf..eb0674c3 100644 --- a/docs/zh/guide/index.md +++ b/docs/zh/guide/index.md @@ -29,6 +29,6 @@ Windows 目前只支持 x86_64 架构,不支持 32 位 x86、不支持 arm64 ## PHP 支持版本 -目前,static-php-cli 对 PHP 7.4 ~ 8.3 版本是支持的,对于 PHP 7.4 及更早版本理论上支持,只需下载时选择早期版本即可。 +目前,static-php-cli 对 PHP 8.1 ~ 8.4 版本是支持的,对于 PHP 8.0 及更早版本理论上支持,只需下载时选择早期版本即可。 但由于部分扩展和特殊组件已对早期版本的 PHP 停止了支持,所以 static-php-cli 不会明确支持早期版本。 我们推荐你编译尽可能新的 PHP 版本,以获得更好的体验。 diff --git a/docs/zh/guide/manual-build.md b/docs/zh/guide/manual-build.md index 98f939a7..3d523fe6 100644 --- a/docs/zh/guide/manual-build.md +++ b/docs/zh/guide/manual-build.md @@ -141,8 +141,8 @@ bin/spc download --for-extensions="curl,pcntl,xml,mbstring" --prefer-pre-built # 下载所有依赖包 bin/spc download --all -# 下载所有依赖包,并指定下载的 PHP 主版本,可选:7.3,7.4,8.0,8.1,8.2,8.3,也可以使用特定的版本,如 8.3.10。 -bin/spc download --all --with-php=8.2 +# 下载所有依赖包,并指定下载的 PHP 主版本,可选:8.1,8.2,8.3,8.4,也可以使用特定的版本,如 8.3.10。 +bin/spc download --all --with-php=8.3 # 下载时显示下载进度条(curl) bin/spc download --all --debug @@ -236,12 +236,12 @@ bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli 如果你想构建多个版本的 PHP,且不想每次都重复构建其他依赖库,可以使用 `switch-php-version` 在编译好一个版本后快速切换至另一个版本并编译: ```shell -# switch to 8.3 -bin/spc switch-php-version 8.3 +# switch to 8.4 +bin/spc switch-php-version 8.4 # build bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli -# switch to 8.0 -bin/spc switch-php-version 8.0 +# switch to 8.1 +bin/spc switch-php-version 8.1 # build bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli ``` @@ -265,6 +265,8 @@ bin/spc build mysqlnd,pdo_mysql --build-all --debug - `--enable-zts`: 让编译的 PHP 为线程安全版本(默认为 NTS 版本) - `--no-strip`: 编译 PHP 库后不运行 `strip` 裁剪二进制文件缩小体积(不裁剪的 macOS 二进制文件可使用动态链接的第三方扩展) - `--with-libs=XXX,YYY`: 编译 PHP 前先编译指定的依赖库,激活部分扩展的可选功能(例如 gd 库的 libavif 等) +- `--with-config-file-path=XXX`: 查找 `php.ini` 的路径(在 [这里](../faq/index.html#php-ini-的路径是什么) 查看默认路径) +- `--with-config-file-scan-dir=XXX`: 读取 `php.ini` 后扫描 `.ini` 文件的目录(在 [这里](../faq/index.html#php-ini-的路径是什么) 查看默认路径) - `-I xxx=yyy`: 编译前将 INI 选项硬编译到 PHP 内(支持多个选项,别名是 `--with-hardcoded-ini`) - `--with-micro-fake-cli`: 在编译 micro 时,让 micro 的 SAPI 伪装为 `cli`(用于兼容一些检查 `PHP_SAPI` 的程序) - `--disable-opcache-jit`: 禁用 opcache jit(默认启用) @@ -491,3 +493,75 @@ static-php-cli 开放的方法非常多,文档中无法一一列举,但只 - 如果你想重新构建一次,但不重新下载源码,可以先 `rm -rf buildroot source` 删除编译目录和源码目录,然后重新构建。 - 如果你想更新某个依赖的版本,可以使用 `bin/spc del-download ` 删除指定的源码,然后使用 `download ` 重新下载。 - 如果你想更新所有依赖的版本,可以使用 `bin/spc download --clean` 删除所有下载的源码,然后重新下载。 + +## embed 使用 + +如果你想将 static-php 嵌入到其他 C 语言程序中,可以使用 `--build-embed` 构建一个 embed 版本的 PHP。 + +```bash +bin/spc build {your extensions} --build-embed --debug +``` + +在通常的情况下,PHP embed 编译后会生成 `php-config`。对于 static-php,我们提供了 `spc-config`,用于获取编译时的参数。 +另外,在使用 embed SAPI(libphp.a)时,你需要使用和编译 libphp 相同的编译器,否则会出现链接错误。 + +下面是 spc-config 的基本用法: + +```bash +# output all flags and options +bin/spc spc-config curl,zlib,phar,openssl + +# output libs +bin/spc spc-config curl,zlib,phar,openssl --libs + +# output includes +bin/spc spc-config curl,zlib,phar,openssl --includes +``` + +默认情况下,static-php 在不同系统使用的编译器分别是: + +- macOS: `clang` +- Linux (Alpine Linux): `gcc` +- Linux (glibc based distros, x86_64): `/usr/local/musl/bin/x86_64-linux-musl-gcc` +- Linux (glibc based distros, aarch64): `/usr/local/musl/bin/aarch64-linux-musl-gcc` +- FreeBSD: `clang` + +下面是一个使用 embed SAPI 的例子: + +```c +// embed.c +#include + +int main(int argc,char **argv){ + + PHP_EMBED_START_BLOCK(argc,argv) + + zend_file_handle file_handle; + + zend_stream_init_filename(&file_handle,"embed.php"); + + if(php_execute_script(&file_handle) == FAILURE){ + php_printf("Failed to execute PHP script.\n"); + } + + PHP_EMBED_END_BLOCK() + return 0; +} +``` + + +```php + + + \ No newline at end of file diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 534cbe03..1849a654 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -22,6 +22,7 @@ use SPC\command\DumpLicenseCommand; use SPC\command\ExtractCommand; use SPC\command\InstallPkgCommand; use SPC\command\MicroCombineCommand; +use SPC\command\SPCConfigCommand; use SPC\command\SwitchPhpVersionCommand; use Symfony\Component\Console\Application; @@ -30,12 +31,15 @@ use Symfony\Component\Console\Application; */ final class ConsoleApplication extends Application { - public const VERSION = '2.3.4'; + public const VERSION = '2.4.2'; public function __construct() { parent::__construct('static-php-cli', self::VERSION); + // Define internal env vars and constants + require_once ROOT_DIR . '/src/globals/internal-env.php'; + $this->addCommands( [ // Common commands @@ -49,6 +53,7 @@ final class ConsoleApplication extends Application new ExtractCommand(), new MicroCombineCommand(), new SwitchPhpVersionCommand(), + new SPCConfigCommand(), // Dev commands new AllExtCommand(), diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index ce92d1dd..0456af8b 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -6,6 +6,7 @@ namespace SPC\builder; use SPC\exception\ExceptionHandler; use SPC\exception\FileSystemException; +use SPC\exception\InterruptException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; @@ -24,6 +25,12 @@ abstract class BuilderBase /** @var array extensions */ protected array $exts = []; + /** @var array extension names */ + protected array $ext_list = []; + + /** @var array library names */ + protected array $lib_list = []; + /** @var bool compile libs only (just mark it) */ protected bool $libs_only = false; @@ -160,7 +167,7 @@ abstract class BuilderBase * @throws FileSystemException * @throws RuntimeException * @throws \ReflectionException - * @throws WrongUsageException + * @throws \Throwable|WrongUsageException * @internal */ public function proveExts(array $extensions, bool $skip_check_deps = false): void @@ -190,6 +197,7 @@ abstract class BuilderBase foreach ($this->exts as $ext) { $ext->checkDependency(); } + $this->ext_list = $extensions; } /** @@ -276,7 +284,7 @@ abstract class BuilderBase return false; } } - if (preg_match('/php-(\d+\.\d+\.\d+)/', $file, $match)) { + if (preg_match('/php-(\d+\.\d+\.\d+(?:RC\d+)?)\.tar\.(?:gz|bz2|xz)/', $file, $match)) { return $match[1]; } return false; @@ -407,6 +415,13 @@ abstract class BuilderBase } logger()->debug('Running additional patch script: ' . $patch); require $patch; + } catch (InterruptException $e) { + if ($e->getCode() === 0) { + logger()->notice('Patch script ' . $patch . ' interrupted' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.')); + } else { + logger()->error('Patch script ' . $patch . ' interrupted with error code [' . $e->getCode() . ']' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.')); + } + exit($e->getCode()); } catch (\Throwable $e) { logger()->critical('Patch script ' . $patch . ' failed to run.'); if ($this->getOption('debug')) { @@ -414,34 +429,11 @@ abstract class BuilderBase } else { logger()->critical('Please check with --debug option to see more details.'); } + throw $e; } } } - /** - * Check if all libs are downloaded. - * If not, throw exception. - * - * @throws RuntimeException - */ - protected function checkLibsSource(): void - { - $not_downloaded = []; - foreach ($this->libs as $lib) { - if (!file_exists($lib->getSourceDir())) { - $not_downloaded[] = $lib::NAME; - } - } - if ($not_downloaded !== []) { - throw new RuntimeException( - '"' . implode(', ', $not_downloaded) . - '" totally ' . count($not_downloaded) . - ' source' . (count($not_downloaded) === 1 ? '' : 's') . - ' not downloaded, maybe you need to "fetch" ' . (count($not_downloaded) === 1 ? 'it' : 'them') . ' first?' - ); - } - } - /** * Generate micro extension test php code. */ diff --git a/src/SPC/builder/extension/grpc.php b/src/SPC/builder/extension/grpc.php new file mode 100644 index 00000000..7b410074 --- /dev/null +++ b/src/SPC/builder/extension/grpc.php @@ -0,0 +1,45 @@ +builder instanceof WindowsBuilder) { + // not support windows yet + throw new \RuntimeException('grpc extension does not support windows yet'); + } + if (!is_link(SOURCE_PATH . '/php-src/ext/grpc')) { + shell()->exec('ln -s ' . $this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc'); + $macos = $this->builder instanceof MacOSBuilder ? "\n" . ' LDFLAGS="$LDFLAGS -framework CoreFoundation"' : ''; + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/grpc/config.m4', '/GRPC_LIBDIR=.*$/m', 'GRPC_LIBDIR=' . BUILD_LIB_PATH . $macos); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/grpc/config.m4', '/SEARCH_PATH=.*$/m', 'SEARCH_PATH="' . BUILD_ROOT_PATH . '"'); + return true; + } + return false; + } + + public function patchBeforeMake(): bool + { + // add -Wno-strict-prototypes + GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes'); + return true; + } + + public function getUnixConfigureArg(): string + { + return '--enable-grpc=' . BUILD_ROOT_PATH . '/grpc GRPC_LIB_SUBDIR=' . BUILD_LIB_PATH; + } +} diff --git a/src/SPC/builder/extension/parallel.php b/src/SPC/builder/extension/parallel.php index f50dffb2..de4e5d88 100644 --- a/src/SPC/builder/extension/parallel.php +++ b/src/SPC/builder/extension/parallel.php @@ -6,6 +6,7 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('parallel')] @@ -17,4 +18,10 @@ class parallel extends Extension throw new WrongUsageException('ext-parallel must be built with ZTS builds. Use "--enable-zts" option!'); } } + + public function patchBeforeBuildconf(): bool + { + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/parallel/config.m4', '/PHP_VERSION=.*/m', ''); + return true; + } } diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index 8b447a16..d385554c 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -6,6 +6,8 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\util\CustomExt; @@ -14,6 +16,8 @@ class pgsql extends Extension { /** * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ public function patchBeforeConfigure(): bool { @@ -24,4 +28,16 @@ class pgsql extends Extension ); return true; } + + /** + * @throws WrongUsageException + * @throws RuntimeException + */ + public function getUnixConfigureArg(): string + { + if ($this->builder->getPHPVersionID() >= 80400) { + return '--with-pgsql PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon"'; + } + return '--with-pgsql=' . BUILD_ROOT_PATH; + } } diff --git a/src/SPC/builder/extension/sodium.php b/src/SPC/builder/extension/sodium.php deleted file mode 100644 index 18059774..00000000 --- a/src/SPC/builder/extension/sodium.php +++ /dev/null @@ -1,35 +0,0 @@ -removeLineContainingString(); - } - - private function removeLineContainingString(): bool - { - $path = SOURCE_PATH . '/php-src/ext/sodium/config.m4'; - $search = '-Wno-logical-op'; - if (!file_exists($path)) { - return false; - } - $content = file_get_contents($path); - $lines = preg_split('/\r\n|\n/', $content); - $filteredLines = array_filter($lines, function ($line) use ($search) { - return strpos($line, $search) === false; - }); - $newContent = implode("\n", $filteredLines); - file_put_contents($path, $newContent); - return true; - } -} diff --git a/src/SPC/builder/extension/zlib.php b/src/SPC/builder/extension/zlib.php index 916ee3a2..a4b8d44b 100644 --- a/src/SPC/builder/extension/zlib.php +++ b/src/SPC/builder/extension/zlib.php @@ -12,6 +12,9 @@ class zlib extends Extension { public function getUnixConfigureArg(): string { + if ($this->builder->getPHPVersionID() >= 80400) { + return '--with-zlib'; + } return '--with-zlib --with-zlib-dir="' . BUILD_ROOT_PATH . '"'; } } diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index fad4a830..c1d41118 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -89,6 +89,11 @@ class BSDBuilder extends UnixBuilderBase $zts_enable = $this->getPHPVersionID() < 80000 ? '--enable-maintainer-zts --disable-zend-signals' : '--enable-zts --disable-zend-signals'; $zts = $this->getOption('enable-zts', false) ? $zts_enable : ''; + $config_file_path = $this->getOption('with-config-file-path', false) ? + ('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : ''; + $config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ? + ('--with-config-file-scan-dir=' . $this->getOption('with-config-file-scan-dir') . ' ') : ''; + $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; @@ -109,6 +114,8 @@ class BSDBuilder extends UnixBuilderBase ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . ($enableMicro ? '--enable-micro ' : '--disable-micro ') . + $config_file_path . + $config_file_scan_dir . $json_74 . $zts . $this->makeExtensionArgs() diff --git a/src/SPC/builder/freebsd/library/openssl.php b/src/SPC/builder/freebsd/library/openssl.php index e525745a..fb029a77 100644 --- a/src/SPC/builder/freebsd/library/openssl.php +++ b/src/SPC/builder/freebsd/library/openssl.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 14a1b987..6589f32b 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -35,7 +35,7 @@ class LinuxBuilder extends UnixBuilderBase GlobalEnvManager::init($this); - if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) { + if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc") && (getenv('SPC_NO_MUSL_PATH') !== 'yes')) { throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)'); } @@ -134,6 +134,11 @@ class LinuxBuilder extends UnixBuilderBase } $disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : ''; + $config_file_path = $this->getOption('with-config-file-path', false) ? + ('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : ''; + $config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ? + ('--with-config-file-scan-dir=' . $this->getOption('with-config-file-scan-dir') . ' ') : ''; + $enable_cli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; $enable_fpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enable_micro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; @@ -163,6 +168,8 @@ class LinuxBuilder extends UnixBuilderBase ($enable_fpm ? '--enable-fpm ' : '--disable-fpm ') . ($enable_embed ? '--enable-embed=static ' : '--disable-embed ') . ($enable_micro ? '--enable-micro=all-static ' : '--disable-micro ') . + $config_file_path . + $config_file_scan_dir . $disable_jit . $json_74 . $zts . diff --git a/src/SPC/builder/linux/SystemUtil.php b/src/SPC/builder/linux/SystemUtil.php index 7cd3f098..730fb3d2 100644 --- a/src/SPC/builder/linux/SystemUtil.php +++ b/src/SPC/builder/linux/SystemUtil.php @@ -6,7 +6,6 @@ namespace SPC\builder\linux; use SPC\builder\traits\UnixSystemUtilTrait; use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; class SystemUtil { @@ -83,52 +82,6 @@ class SystemUtil }; } - /** - * @throws RuntimeException - * @throws WrongUsageException - * @throws WrongUsageException - */ - public static function getArchCFlags(string $cc, string $arch): string - { - if (php_uname('m') === $arch) { - return ''; - } - return match (static::getCCType($cc)) { - 'clang' => match ($arch) { - 'x86_64' => '--target=x86_64-unknown-linux', - 'arm64', 'aarch64' => '--target=arm64-unknown-linux', - default => throw new WrongUsageException('unsupported arch: ' . $arch), - }, - 'gcc' => '', - default => throw new WrongUsageException('cc compiler ' . $cc . ' is not supported'), - }; - } - - /** - * @throws RuntimeException - */ - public static function getTuneCFlags(string $arch): array - { - return match ($arch) { - 'x86_64', 'arm64', 'aarch64' => [], - default => throw new RuntimeException('unsupported arch: ' . $arch), - }; - } - - public static function checkCCFlags(array $flags, string $cc): array - { - return array_filter($flags, fn ($flag) => static::checkCCFlag($flag, $cc)); - } - - public static function checkCCFlag(string $flag, string $cc): string - { - [$ret] = shell()->execWithResult("echo | {$cc} -E -x c - {$flag} 2>/dev/null"); - if ($ret != 0) { - return ''; - } - return $flag; - } - /** * @throws RuntimeException * @noinspection PhpUnused diff --git a/src/SPC/builder/linux/library/grpc.php b/src/SPC/builder/linux/library/grpc.php new file mode 100644 index 00000000..ccafc94c --- /dev/null +++ b/src/SPC/builder/linux/library/grpc.php @@ -0,0 +1,12 @@ + * diff --git a/src/SPC/builder/linux/library/libwebp.php b/src/SPC/builder/linux/library/libwebp.php index d376e341..8cd3c670 100644 --- a/src/SPC/builder/linux/library/libwebp.php +++ b/src/SPC/builder/linux/library/libwebp.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 46fcd75e..e427bbf9 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index a29e9954..95aa2c5e 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -137,6 +137,11 @@ class MacOSBuilder extends UnixBuilderBase $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; + $config_file_path = $this->getOption('with-config-file-path', false) ? + ('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : ''; + $config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ? + ('--with-config-file-scan-dir=' . $this->getOption('with-config-file-scan-dir') . ' ') : ''; + $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; @@ -164,6 +169,8 @@ class MacOSBuilder extends UnixBuilderBase ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . ($enableMicro ? '--enable-micro ' : '--disable-micro ') . + $config_file_path . + $config_file_scan_dir . $json_74 . $zts . $this->makeExtensionArgs() . ' ' . diff --git a/src/SPC/builder/macos/library/brotli.php b/src/SPC/builder/macos/library/brotli.php index 75b68fbc..1061d913 100644 --- a/src/SPC/builder/macos/library/brotli.php +++ b/src/SPC/builder/macos/library/brotli.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/macos/library/bzip2.php b/src/SPC/builder/macos/library/bzip2.php index bd44e0bc..7719770c 100644 --- a/src/SPC/builder/macos/library/bzip2.php +++ b/src/SPC/builder/macos/library/bzip2.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/macos/library/curl.php b/src/SPC/builder/macos/library/curl.php index 3a24f31a..0555f66e 100644 --- a/src/SPC/builder/macos/library/curl.php +++ b/src/SPC/builder/macos/library/curl.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/macos/library/grpc.php b/src/SPC/builder/macos/library/grpc.php new file mode 100644 index 00000000..03e7a555 --- /dev/null +++ b/src/SPC/builder/macos/library/grpc.php @@ -0,0 +1,12 @@ +exec('chmod +x src/osdep/unix/drivers') ->exec('chmod +x src/osdep/unix/mkauths') ->exec( - "yes | make osx {$ssl_options} EXTRACFLAGS='-Wimplicit-function-declaration -Wno-incompatible-function-pointer-types {$out}'" + "echo y | make osx {$ssl_options} EXTRACFLAGS='-Wno-implicit-function-declaration -Wno-incompatible-function-pointer-types {$out}'" ); try { shell() diff --git a/src/SPC/builder/macos/library/libavif.php b/src/SPC/builder/macos/library/libavif.php index 74b84b6a..8201c64d 100644 --- a/src/SPC/builder/macos/library/libavif.php +++ b/src/SPC/builder/macos/library/libavif.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/macos/library/libiconv.php b/src/SPC/builder/macos/library/libiconv.php index d5c2b693..945c82e0 100644 --- a/src/SPC/builder/macos/library/libiconv.php +++ b/src/SPC/builder/macos/library/libiconv.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/macos/library/libpng.php b/src/SPC/builder/macos/library/libpng.php index 39522a8c..b61cc898 100644 --- a/src/SPC/builder/macos/library/libpng.php +++ b/src/SPC/builder/macos/library/libpng.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/macos/library/libwebp.php b/src/SPC/builder/macos/library/libwebp.php index 1b2a2ee8..324b5543 100644 --- a/src/SPC/builder/macos/library/libwebp.php +++ b/src/SPC/builder/macos/library/libwebp.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/macos/library/nghttp2.php b/src/SPC/builder/macos/library/nghttp2.php index 09277912..61aceb24 100644 --- a/src/SPC/builder/macos/library/nghttp2.php +++ b/src/SPC/builder/macos/library/nghttp2.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index 1e171ef2..54ebe975 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/macos/library/zlib.php b/src/SPC/builder/macos/library/zlib.php index 2f451c10..a5c0b2b0 100644 --- a/src/SPC/builder/macos/library/zlib.php +++ b/src/SPC/builder/macos/library/zlib.php @@ -1,4 +1,5 @@ * diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 3ec21f06..347e1f16 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -12,6 +12,7 @@ use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; use SPC\util\DependencyUtil; +use SPC\util\SPCConfigUtil; abstract class UnixBuilderBase extends BuilderBase { @@ -128,6 +129,7 @@ abstract class UnixBuilderBase extends BuilderBase foreach ($this->libs as $lib) { $lib->calcDependency(); } + $this->lib_list = $sorted_libraries; } /** @@ -170,6 +172,32 @@ abstract class UnixBuilderBase extends BuilderBase } } } + + // sanity check for embed + if (($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) { + logger()->info('running embed sanity check'); + $sample_file_path = SOURCE_PATH . '/embed-test'; + if (!is_dir($sample_file_path)) { + @mkdir($sample_file_path); + } + // copy embed test files + copy(ROOT_DIR . '/src/globals/common-tests/embed.c', $sample_file_path . '/embed.c'); + copy(ROOT_DIR . '/src/globals/common-tests/embed.php', $sample_file_path . '/embed.php'); + $util = new SPCConfigUtil($this); + $config = $util->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs')); + $lens = "{$config['cflags']} {$config['ldflags']} {$config['libs']}"; + if (PHP_OS_FAMILY === 'Linux') { + $lens .= ' -static'; + } + [$ret, $out] = shell()->cd($sample_file_path)->execWithResult(getenv('CC') . ' -o embed embed.c ' . $lens); + if ($ret !== 0) { + throw new RuntimeException('embed failed sanity check: build failed. Error message: ' . implode("\n", $out)); + } + [$ret, $output] = shell()->cd($sample_file_path)->execWithResult('./embed'); + if ($ret !== 0 || trim(implode('', $output)) !== 'hello') { + throw new RuntimeException('embed failed sanity check: run failed. Error message: ' . implode("\n", $output)); + } + } } /** diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 6a1995c4..e20dd4f6 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -19,6 +19,7 @@ trait gettext '--disable-java ' . '--disable-c+ ' . $extra . + '--with-included-gettext ' . '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . '--prefix=' . BUILD_ROOT_PATH ) diff --git a/src/SPC/builder/unix/library/grpc.php b/src/SPC/builder/unix/library/grpc.php new file mode 100644 index 00000000..ea93139d --- /dev/null +++ b/src/SPC/builder/unix/library/grpc.php @@ -0,0 +1,24 @@ +cd($this->source_dir) + ->exec('EXTRA_DEFINES=GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK EMBED_OPENSSL=false CXXFLAGS="-L' . BUILD_LIB_PATH . ' -I' . BUILD_INCLUDE_PATH . '" make static -j' . $this->builder->concurrency); + copy($this->source_dir . '/libs/opt/libgrpc.a', BUILD_LIB_PATH . '/libgrpc.a'); + copy($this->source_dir . '/libs/opt/libboringssl.a', BUILD_LIB_PATH . '/libboringssl.a'); + if (!file_exists(BUILD_LIB_PATH . '/libcares.a')) { + copy($this->source_dir . '/libs/opt/libcares.a', BUILD_LIB_PATH . '/libcares.a'); + } + FileSystem::copyDir($this->source_dir . '/include/grpc', BUILD_INCLUDE_PATH . '/grpc'); + FileSystem::copyDir($this->source_dir . '/include/grpc++', BUILD_INCLUDE_PATH . '/grpc++'); + FileSystem::copyDir($this->source_dir . '/include/grpcpp', BUILD_INCLUDE_PATH . '/grpcpp'); + } +} diff --git a/src/SPC/builder/windows/SystemUtil.php b/src/SPC/builder/windows/SystemUtil.php index e1794f94..4d3d38ff 100644 --- a/src/SPC/builder/windows/SystemUtil.php +++ b/src/SPC/builder/windows/SystemUtil.php @@ -21,7 +21,7 @@ class SystemUtil if (!$paths) { $paths = explode(PATH_SEPARATOR, getenv('Path')); if ($include_sdk_bin) { - $paths[] = PHP_SDK_PATH . '\bin'; + $paths[] = getenv('PHP_SDK_PATH') . '\bin'; } } foreach ($paths as $path) { diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 1c1646d7..46b8ac48 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -38,7 +38,7 @@ class WindowsBuilder extends BuilderBase // ---------- set necessary options ---------- // set sdk (require visual studio 16 or 17) $vs = SystemUtil::findVisualStudio()['version']; - $this->sdk_prefix = PHP_SDK_PATH . "\\phpsdk-{$vs}-x64.bat -t"; + $this->sdk_prefix = getenv('PHP_SDK_PATH') . "\\phpsdk-{$vs}-x64.bat -t"; // set zts $this->zts = $this->getOption('enable-zts', false); @@ -103,6 +103,9 @@ class WindowsBuilder extends BuilderBase $micro_w32 = $this->getOption('enable-micro-win32') ? ' --enable-micro-win32=yes' : ''; + $config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ? + ('--with-config-file-scan-dir=' . $this->getOption('with-config-file-scan-dir') . ' ') : ''; + cmd()->cd(SOURCE_PATH . '\php-src') ->exec( "{$this->sdk_prefix} configure.bat --task-args \"" . @@ -114,6 +117,7 @@ class WindowsBuilder extends BuilderBase ($enableCli ? '--enable-cli=yes ' : '--enable-cli=no ') . ($enableMicro ? ('--enable-micro=yes ' . $micro_logo . $micro_w32) : '--enable-micro=no ') . ($enableEmbed ? '--enable-embed=yes ' : '--enable-embed=no ') . + $config_file_scan_dir . "{$this->makeExtensionArgs()} " . $zts . '"' @@ -244,6 +248,7 @@ class WindowsBuilder extends BuilderBase foreach ($this->libs as $lib) { $lib->calcDependency(); } + $this->lib_list = $sorted_libraries; } /** diff --git a/src/SPC/builder/windows/library/xz.php b/src/SPC/builder/windows/library/xz.php index cf5b7234..a48df52d 100644 --- a/src/SPC/builder/windows/library/xz.php +++ b/src/SPC/builder/windows/library/xz.php @@ -32,7 +32,7 @@ class xz extends WindowsLibraryBase ); // copy liblzma.lib to liblzma_a.lib - copy(BUILD_LIB_PATH . '/liblzma.lib', BUILD_LIB_PATH . '/liblzma_a.lib'); + copy(BUILD_LIB_PATH . '/lzma.lib', BUILD_LIB_PATH . '/liblzma_a.lib'); // patch lzma.h FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '/lzma.h', 'defined(LZMA_API_STATIC)', 'defined(_WIN32)'); } diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php index d67b133a..7b79a4c8 100644 --- a/src/SPC/command/BaseCommand.php +++ b/src/SPC/command/BaseCommand.php @@ -10,6 +10,7 @@ use Psr\Log\LogLevel; use SPC\ConsoleApplication; use SPC\exception\ExceptionHandler; use SPC\exception\WrongUsageException; +use SPC\util\GlobalEnvManager; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; @@ -94,6 +95,11 @@ abstract class BaseCommand extends Command $question = new ConfirmationQuestion($prompt->label . $case, $prompt->default); return $helper->ask($input, $output, $question); }); + + // init GlobalEnv + if (!$this instanceof BuildCommand) { + GlobalEnvManager::init(); + } if ($this->shouldExecute()) { try { // show raw argv list for logger()->debug diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 2356e96f..bc214760 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -22,6 +22,8 @@ class BuildCliCommand extends BuildCommand { public function configure(): void { + $isWindows = PHP_OS_FAMILY === 'Windows'; + $this->addArgument('extensions', InputArgument::REQUIRED, 'The extensions will be compiled, comma separated'); $this->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', ''); $this->addOption('build-micro', null, null, 'Build micro SAPI'); @@ -32,6 +34,8 @@ class BuildCliCommand extends BuildCommand $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); $this->addOption('enable-zts', null, null, 'enable ZTS support'); $this->addOption('disable-opcache-jit', null, null, 'disable opcache jit'); + $this->addOption('with-config-file-path', null, InputOption::VALUE_REQUIRED, 'Set the path in which to look for php.ini', $isWindows ? null : '/usr/local/etc/php'); + $this->addOption('with-config-file-scan-dir', null, InputOption::VALUE_REQUIRED, 'Set the directory to scan for .ini files after reading php.ini', $isWindows ? null : '/usr/local/etc/php/conf.d'); $this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI'); $this->addOption('with-micro-fake-cli', null, null, 'Let phpmicro\'s PHP_SAPI use "cli" instead of "micro"'); $this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs'); @@ -114,6 +118,9 @@ class BuildCliCommand extends BuildCommand 'Strip Binaries' => $builder->getOption('no-strip') ? 'no' : 'yes', 'Enable ZTS' => $builder->getOption('enable-zts') ? 'yes' : 'no', ]; + if (!empty($this->input->getOption('with-config-file-path'))) { + $indent_texts['Config File Path'] = $this->input->getOption('with-config-file-path'); + } if (!empty($this->input->getOption('with-hardcoded-ini'))) { $indent_texts['Hardcoded INI'] = $this->input->getOption('with-hardcoded-ini'); } @@ -174,7 +181,9 @@ class BuildCliCommand extends BuildCommand // compile stopwatch :P $time = round(microtime(true) - START_TIME, 3); - logger()->info('Build complete, used ' . $time . ' s !'); + logger()->info(''); + logger()->info(' Build complete, used ' . $time . ' s !'); + logger()->info(''); // ---------- When using bin/spc-alpine-docker, the build root path is different from the host system ---------- $build_root_path = BUILD_ROOT_PATH; diff --git a/src/SPC/command/DoctorCommand.php b/src/SPC/command/DoctorCommand.php index bc77511a..1b5b8d14 100644 --- a/src/SPC/command/DoctorCommand.php +++ b/src/SPC/command/DoctorCommand.php @@ -23,6 +23,8 @@ class DoctorCommand extends BaseCommand { try { $checker = new CheckListHandler(); + // skipped items + $skip_items = array_filter(explode(',', getenv('SPC_SKIP_DOCTOR_CHECK_ITEMS') ?: '')); $fix_policy = $this->input->getOption('auto-fix') ? FIX_POLICY_AUTOFIX : FIX_POLICY_PROMPT; foreach ($checker->runChecks() as $check) { @@ -32,13 +34,12 @@ class DoctorCommand extends BaseCommand $this->output->write('Checking ' . $check->item_name . ' ... '); - $result = call_user_func($check->callback); - if ($result === null) { + // check if this item is skipped + if (in_array($check->item_name, $skip_items) || ($result = call_user_func($check->callback)) === null) { $this->output->writeln('skipped'); } elseif ($result instanceof CheckResult) { if ($result->isOK()) { $this->output->writeln($result->getMessage() ?? 'ok'); - continue; } diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 7419c60e..80ec6eab 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -30,7 +30,7 @@ class DownloadCommand extends BaseCommand $this->addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated'); $this->addOption('shallow-clone', null, null, 'Clone shallow'); $this->addOption('with-openssl11', null, null, 'Use openssl 1.1'); - $this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'version in major.minor format (default 8.2)', '8.2'); + $this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'version in major.minor format (default 8.3)', '8.3'); $this->addOption('clean', null, null, 'Clean old download cache and source before fetch'); $this->addOption('all', 'A', null, 'Fetch all sources that static-php-cli needed'); $this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"'); diff --git a/src/SPC/command/SPCConfigCommand.php b/src/SPC/command/SPCConfigCommand.php new file mode 100644 index 00000000..0377ace9 --- /dev/null +++ b/src/SPC/command/SPCConfigCommand.php @@ -0,0 +1,53 @@ +addArgument('extensions', InputArgument::OPTIONAL, 'The extensions will be compiled, comma separated'); + $this->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', ''); + $this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs'); + $this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts'); + $this->addOption('includes', null, null, 'Add additional include path'); + $this->addOption('libs', null, null, 'Add additional libs path'); + } + + /** + * @throws RuntimeException + */ + public function handle(): int + { + // transform string to array + $libraries = array_map('trim', array_filter(explode(',', $this->getOption('with-libs')))); + // transform string to array + $extensions = $this->getArgument('extensions') ? $this->parseExtensionList($this->getArgument('extensions')) : []; + $include_suggest_ext = $this->getOption('with-suggested-exts'); + $include_suggest_lib = $this->getOption('with-suggested-libs'); + + $util = new SPCConfigUtil(null, $this->input); + $config = $util->config($extensions, $libraries, $include_suggest_ext, $include_suggest_lib); + + if ($this->getOption('includes')) { + $this->output->writeln($config['cflags']); + } elseif ($this->getOption('libs')) { + $this->output->writeln("{$config['ldflags']} {$config['libs']}"); + } else { + $this->output->writeln("{$config['cflags']} {$config['ldflags']} {$config['libs']}"); + } + + return 0; + } +} diff --git a/src/SPC/command/SwitchPhpVersionCommand.php b/src/SPC/command/SwitchPhpVersionCommand.php index f0f454dd..ab91ed07 100644 --- a/src/SPC/command/SwitchPhpVersionCommand.php +++ b/src/SPC/command/SwitchPhpVersionCommand.php @@ -19,9 +19,9 @@ class SwitchPhpVersionCommand extends BaseCommand $this->addArgument( 'php-major-version', InputArgument::REQUIRED, - 'PHP major version (supported: 7.4, 8.0, 8.1, 8.2, 8.3)', + 'PHP major version (supported: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4)', null, - fn () => ['7.4', '8.0', '8.1', '8.2', '8.3'] + fn () => ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] ); $this->no_motd = true; @@ -31,7 +31,7 @@ class SwitchPhpVersionCommand extends BaseCommand public function handle(): int { $php_ver = $this->input->getArgument('php-major-version'); - if (!in_array($php_ver, ['7.4', '8.0', '8.1', '8.2', '8.3'])) { + if (!in_array($php_ver, ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'])) { // match x.y.z preg_match('/^\d+\.\d+\.\d+$/', $php_ver, $matches); if (!$matches) { diff --git a/src/SPC/command/dev/PackLibCommand.php b/src/SPC/command/dev/PackLibCommand.php index f97eaabd..18e02fda 100644 --- a/src/SPC/command/dev/PackLibCommand.php +++ b/src/SPC/command/dev/PackLibCommand.php @@ -5,8 +5,12 @@ declare(strict_types=1); namespace SPC\command\dev; use SPC\builder\BuilderProvider; +use SPC\builder\LibraryBase; use SPC\command\BuildCommand; use SPC\exception\ExceptionHandler; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; use SPC\util\DependencyUtil; @@ -53,6 +57,8 @@ class PackLibCommand extends BuildCommand $lib->tryBuild(true); // do something like patching pkg-conf files. $lib->beforePack(); + // sanity check for libs (check if the libraries are built correctly) + $this->sanityCheckLib($lib); // After build: load buildroot/ directory, and calculate increase files $after_buildroot = FileSystem::scanDirFiles(BUILD_ROOT_PATH, relative: true); $increase_files = array_diff($after_buildroot, $before_buildroot); @@ -82,4 +88,20 @@ class PackLibCommand extends BuildCommand return static::FAILURE; } } + + /** + * @throws WrongUsageException + * @throws RuntimeException + * @throws FileSystemException + */ + private function sanityCheckLib(LibraryBase $lib): void + { + logger()->info('Sanity check for library ' . $lib->getName()); + // config + foreach ($lib->getStaticLibs() as $static_lib) { + if (!file_exists(FileSystem::convertPath(BUILD_LIB_PATH . '/' . $static_lib))) { + throw new RuntimeException('Static library ' . $static_lib . ' not found in ' . BUILD_LIB_PATH); + } + } + } } diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index e672ca20..6db69f39 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -73,9 +73,9 @@ class LinuxMuslCheck FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); logger()->info('Installing musl wrapper'); shell()->cd(SOURCE_PATH . "/{$musl_version_name}") - ->exec('./configure --disable-gcc-wrapper') - ->exec('make -j') - ->exec("{$prefix}make install"); + ->exec('CC=gcc CXX=g++ AR=ar LD=ld ./configure --disable-gcc-wrapper') + ->exec('CC=gcc CXX=g++ AR=ar LD=ld make -j') + ->exec("CC=gcc CXX=g++ AR=ar LD=ld {$prefix}make install"); // TODO: add path using putenv instead of editing /etc/profile return true; } catch (RuntimeException) { diff --git a/src/SPC/doctor/item/WindowsToolCheckList.php b/src/SPC/doctor/item/WindowsToolCheckList.php index b66737cc..bfeb063e 100644 --- a/src/SPC/doctor/item/WindowsToolCheckList.php +++ b/src/SPC/doctor/item/WindowsToolCheckList.php @@ -37,10 +37,10 @@ class WindowsToolCheckList #[AsCheckItem('if php-sdk-binary-tools are downloaded', limit_os: 'Windows', level: 997)] public function checkSDK(): ?CheckResult { - if (!file_exists(PHP_SDK_PATH . DIRECTORY_SEPARATOR . 'phpsdk-starter.bat')) { + if (!file_exists(getenv('PHP_SDK_PATH') . DIRECTORY_SEPARATOR . 'phpsdk-starter.bat')) { return CheckResult::fail('php-sdk-binary-tools not downloaded', 'install-php-sdk'); } - return CheckResult::ok(PHP_SDK_PATH); + return CheckResult::ok(getenv('PHP_SDK_PATH')); } #[AsCheckItem('if git associated command exists', limit_os: 'Windows', level: 996)] @@ -81,8 +81,8 @@ class WindowsToolCheckList public function installPhpSdk(): bool { try { - FileSystem::removeDir(PHP_SDK_PATH); - cmd(true)->exec('git.exe clone --depth 1 https://github.com/php/php-sdk-binary-tools.git ' . PHP_SDK_PATH); + FileSystem::removeDir(getenv('PHP_SDK_PATH')); + cmd(true)->exec('git.exe clone --depth 1 https://github.com/php/php-sdk-binary-tools.git ' . getenv('PHP_SDK_PATH')); } catch (RuntimeException) { return false; } diff --git a/src/SPC/exception/InterruptException.php b/src/SPC/exception/InterruptException.php new file mode 100644 index 00000000..b004f47f --- /dev/null +++ b/src/SPC/exception/InterruptException.php @@ -0,0 +1,7 @@ +info("using basic github token for {$method} {$url}"); } else { $auth = getenv('GITHUB_TOKEN'); - $headers[] = "Authorization: Bearer {$auth}"; + $he = "Authorization: Bearer {$auth}"; + if (!in_array($he, $headers)) { + $headers[] = $he; + } logger()->info("using bearer github token for {$method} {$url}"); } } diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 363fe344..16edeeae 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -28,7 +28,7 @@ class Downloader logger()->debug("finding {$name} source from bitbucket tag"); $data = json_decode(self::curlExec( url: "https://api.bitbucket.org/2.0/repositories/{$source['repo']}/refs/tags", - retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) + retry: self::getRetryTime() ), true); $ver = $data['values'][0]['name']; if (!$ver) { @@ -38,7 +38,7 @@ class Downloader $headers = self::curlExec( url: $url, method: 'HEAD', - retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) + retry: self::getRetryTime() ); preg_match('/^content-disposition:\s+attachment;\s*filename=("?)(?.+\.tar\.gz)\1/im', $headers, $matches); if ($matches) { @@ -66,7 +66,7 @@ class Downloader $data = json_decode(self::curlExec( url: "https://api.github.com/repos/{$source['repo']}/{$type}", hooks: [[CurlHook::class, 'setupGithubToken']], - retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) + retry: self::getRetryTime() ), true); if (($source['prefer-stable'] ?? false) === false) { @@ -85,7 +85,7 @@ class Downloader url: $url, method: 'HEAD', hooks: [[CurlHook::class, 'setupGithubToken']], - retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) + retry: self::getRetryTime() ); preg_match('/^content-disposition:\s+attachment;\s*filename=("?)(?.+\.tar\.gz)\1/im', $headers, $matches); if ($matches) { @@ -108,11 +108,11 @@ class Downloader */ public static function getLatestGithubRelease(string $name, array $source, bool $match_result = true): array { - logger()->debug("finding {$name} from github releases assests"); + logger()->debug("finding {$name} from github releases assets"); $data = json_decode(self::curlExec( url: "https://api.github.com/repos/{$source['repo']}/releases", hooks: [[CurlHook::class, 'setupGithubToken']], - retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) + retry: self::getRetryTime() ), true); $url = null; foreach ($data as $release) { @@ -149,7 +149,7 @@ class Downloader public static function getFromFileList(string $name, array $source): array { logger()->debug("finding {$name} source from file list"); - $page = self::curlExec($source['url'], retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0)); + $page = self::curlExec($source['url'], retry: self::getRetryTime()); preg_match_all($source['regex'], $page, $matches); if (!$matches) { throw new DownloaderException("Failed to get {$name} version"); @@ -182,6 +182,7 @@ class Downloader * * @throws FileSystemException * @throws RuntimeException + * @throws WrongUsageException */ public static function downloadFile(string $name, string $url, string $filename, ?string $move_path = null, int $lock_as = SPC_LOCK_SOURCE): void { @@ -193,7 +194,7 @@ class Downloader } }; self::registerCancelEvent($cancel_func); - self::curlDown(url: $url, path: FileSystem::convertPath(DOWNLOAD_PATH . "/{$filename}"), retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0)); + self::curlDown(url: $url, path: FileSystem::convertPath(DOWNLOAD_PATH . "/{$filename}"), retry: self::getRetryTime()); self::unregisterCancelEvent(); logger()->debug("Locking {$filename}"); self::lockSource($name, ['source_type' => 'archive', 'filename' => $filename, 'move_path' => $move_path, 'lock_as' => $lock_as]); @@ -220,6 +221,7 @@ class Downloader * * @throws FileSystemException * @throws RuntimeException + * @throws WrongUsageException */ public static function downloadGit(string $name, string $url, string $branch, ?string $move_path = null, int $retry = 0, int $lock_as = SPC_LOCK_SOURCE): void { @@ -345,7 +347,7 @@ class Downloader $pkg['url'], $pkg['rev'], $pkg['extract'] ?? null, - intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0), + self::getRetryTime(), SPC_LOCK_PRE_BUILT ); break; @@ -381,6 +383,7 @@ class Downloader * @param int $lock_as Lock source type (default: SPC_LOCK_SOURCE) * @throws DownloaderException * @throws FileSystemException + * @throws WrongUsageException */ public static function downloadSource(string $name, ?array $source = null, bool $force = false, int $lock_as = SPC_LOCK_SOURCE): void { @@ -448,7 +451,7 @@ class Downloader $source['url'], $source['rev'], $source['path'] ?? null, - intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0), + self::getRetryTime(), $lock_as ); break; @@ -539,6 +542,7 @@ class Downloader * Use curl to download sources from url * * @throws RuntimeException + * @throws WrongUsageException */ public static function curlDown(string $url, string $path, string $method = 'GET', array $headers = [], array $hooks = [], int $retry = 0): void { @@ -563,7 +567,7 @@ class Downloader } if ($retry > 0) { logger()->notice('Retrying curl download ...'); - self::curlDown($url, $path, $method, $used_headers, retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0)); + self::curlDown($url, $path, $method, $used_headers, retry: $retry - 1); return; } throw $e; @@ -597,4 +601,9 @@ class Downloader pcntl_signal(2, SIG_IGN); } } + + private static function getRetryTime(): int + { + return intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0); + } } diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index cbf6107e..5780a216 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -367,6 +367,9 @@ class FileSystem } } } + if (is_link($dir)) { + return unlink($dir); + } return rmdir($dir); } @@ -428,7 +431,7 @@ class FileSystem { $replacement = [ '{pkg_root_path}' => PKG_ROOT_PATH, - '{php_sdk_path}' => defined('PHP_SDK_PATH') ? PHP_SDK_PATH : WORKING_DIR . '/php-sdk-binary-tools', + '{php_sdk_path}' => getenv('PHP_SDK_PATH') ? getenv('PHP_SDK_PATH') : WORKING_DIR . '/php-sdk-binary-tools', '{working_dir}' => WORKING_DIR, '{download_path}' => DOWNLOAD_PATH, '{source_path}' => SOURCE_PATH, @@ -480,7 +483,7 @@ class FileSystem }; } elseif (PHP_OS_FAMILY === 'Windows') { // use php-sdk-binary-tools/bin/7za.exe - $_7z = self::convertPath(PHP_SDK_PATH . '/bin/7za.exe'); + $_7z = self::convertPath(getenv('PHP_SDK_PATH') . '/bin/7za.exe'); // Windows notes: I hate windows tar....... // When extracting .tar.gz like libxml2, it shows a symlink error and returns code[1]. diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 86014e7c..b4c3b933 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -25,6 +25,8 @@ class SourcePatcher FileSystem::addSourceExtractHook('pdo_sqlsrv', [SourcePatcher::class, 'patchSQLSRVWin32']); FileSystem::addSourceExtractHook('yaml', [SourcePatcher::class, 'patchYamlWin32']); FileSystem::addSourceExtractHook('libyaml', [SourcePatcher::class, 'patchLibYaml']); + FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchImapLicense']); + FileSystem::addSourceExtractHook('ext-imagick', [SourcePatcher::class, 'patchImagickWith84']); } /** @@ -370,6 +372,27 @@ class SourcePatcher return true; } + /** + * Patch imap license file for PHP < 8.4 + */ + public static function patchImapLicense(): bool + { + if (!file_exists(SOURCE_PATH . '/php-src/ext/imap/LICENSE') && is_dir(SOURCE_PATH . '/php-src/ext/imap')) { + file_put_contents(SOURCE_PATH . '/php-src/ext/imap/LICENSE', file_get_contents(ROOT_DIR . '/src/globals/extra/Apache_LICENSE')); + return true; + } + return false; + } + + /** + * Patch imagick for PHP 8.4 + */ + public static function patchImagickWith84(): bool + { + SourcePatcher::patchFile('imagick_php84.patch', SOURCE_PATH . '/php-src/ext/imagick'); + return true; + } + /** * Patch cli SAPI Makefile for Windows. * @@ -416,7 +439,7 @@ class SourcePatcher return true; } if ($ver_id < 80200) { - self::patchFile('spc_fix_libxml2_12_php81.patch', SOURCE_PATH . '/php-src'); + // self::patchFile('spc_fix_libxml2_12_php81.patch', SOURCE_PATH . '/php-src'); self::patchFile('spc_fix_alpine_build_php80.patch', SOURCE_PATH . '/php-src'); return true; } diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 79835636..d15fd40f 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -19,7 +19,7 @@ class PhpSource extends CustomSourceBase */ public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_LOCK_SOURCE): void { - $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.1'; + $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.3'; Downloader::downloadSource('php-src', self::getLatestPHPInfo($major), $force); } diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index 083262d4..6c6c9820 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -5,11 +5,9 @@ declare(strict_types=1); namespace SPC\util; use SPC\builder\BuilderBase; -use SPC\builder\freebsd\SystemUtil as BSDSystemUtil; -use SPC\builder\linux\SystemUtil as LinuxSystemUtil; -use SPC\builder\macos\SystemUtil as MacOSSystemUtil; -use SPC\builder\windows\SystemUtil as WindowsSystemUtil; +use SPC\builder\linux\SystemUtil; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; /** * Environment variable manager @@ -26,171 +24,87 @@ class GlobalEnvManager /** * Initialize the environment variables * - * @param BuilderBase $builder Builder + * @param null|BuilderBase $builder Builder * @throws RuntimeException + * @throws WrongUsageException */ - public static function init(BuilderBase $builder): void + public static function init(?BuilderBase $builder = null): void { - // Init global env, build related path - self::putenv('BUILD_ROOT_PATH=' . BUILD_ROOT_PATH); - self::putenv('BUILD_INCLUDE_PATH=' . BUILD_INCLUDE_PATH); - self::putenv('BUILD_LIB_PATH=' . BUILD_LIB_PATH); - self::putenv('BUILD_BIN_PATH=' . BUILD_BIN_PATH); - self::putenv('PKG_ROOT_PATH=' . PKG_ROOT_PATH); - self::putenv('SOURCE_PATH=' . SOURCE_PATH); - self::putenv('DOWNLOAD_PATH=' . DOWNLOAD_PATH); + // Check pre-defined env vars exists + if (getenv('BUILD_ROOT_PATH') === false) { + throw new RuntimeException('You must include src/globals/internal-env.php before using GlobalEnvManager'); + } - // Init SPC env - self::initIfNotExists('SPC_CONCURRENCY', match (PHP_OS_FAMILY) { - 'Windows' => (string) WindowsSystemUtil::getCpuCount(), - 'Darwin' => (string) MacOSSystemUtil::getCpuCount(), - 'Linux' => (string) LinuxSystemUtil::getCpuCount(), - 'BSD' => (string) BSDSystemUtil::getCpuCount(), - default => '1', - }); + // Define env vars for unix + if (is_unix()) { + self::putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); + self::putenv('PKG_CONFIG=' . BUILD_BIN_PATH . '/pkg-config'); + self::putenv('PKG_CONFIG_PATH=' . BUILD_ROOT_PATH . '/lib/pkgconfig'); + if ($builder instanceof BuilderBase) { + self::putenv('SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS=' . ($builder->getOption('no-strip') ? '-g -O0' : '-g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64')); + } + } - // Init system-specific env - match (PHP_OS_FAMILY) { - 'Windows' => self::initWindowsEnv(), - 'Darwin' => self::initDarwinEnv($builder), - 'Linux' => self::initLinuxEnv($builder), - 'BSD' => 'TODO', - default => logger()->warning('Unknown OS: ' . PHP_OS_FAMILY), - }; - } - - private static function initWindowsEnv(): void - { - // Windows need php-sdk binary tools - self::initIfNotExists('PHP_SDK_PATH', WORKING_DIR . DIRECTORY_SEPARATOR . 'php-sdk-binary-tools'); - self::initIfNotExists('UPX_EXEC', PKG_ROOT_PATH . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'upx.exe'); - self::initIfNotExists('SPC_MICRO_PATCHES', 'static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static'); - } - - private static function initLinuxEnv(BuilderBase $builder): void - { - // Init C Compiler and C++ Compiler (alpine) - if (LinuxSystemUtil::isMuslDist()) { - self::initIfNotExists('CC', 'gcc'); - self::initIfNotExists('CXX', 'g++'); - self::initIfNotExists('AR', 'ar'); - self::initIfNotExists('LD', 'ld.gold'); - } else { + // Define env vars for linux + if (PHP_OS_FAMILY === 'Linux') { $arch = arch2gnu(php_uname('m')); - self::initIfNotExists('CC', "{$arch}-linux-musl-gcc"); - self::initIfNotExists('CXX', "{$arch}-linux-musl-g++"); - self::initIfNotExists('AR', "{$arch}-linux-musl-ar"); - self::initIfNotExists('LD', 'ld.gold'); + if (SystemUtil::isMuslDist()) { + self::putenv('SPC_LINUX_DEFAULT_CC=gcc'); + self::putenv('SPC_LINUX_DEFAULT_CXX=g++'); + self::putenv('SPC_LINUX_DEFAULT_AR=ar'); + } else { + self::putenv("SPC_LINUX_DEFAULT_CC={$arch}-linux-musl-gcc"); + self::putenv("SPC_LINUX_DEFAULT_CXX={$arch}-linux-musl-g++"); + self::putenv("SPC_LINUX_DEFAULT_AR={$arch}-linux-musl-ar"); + } + self::putenv("SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD=LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); if (getenv('SPC_NO_MUSL_PATH') !== 'yes') { self::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH')); } } - // Init arch-specific cflags - self::initIfNotExists('SPC_DEFAULT_C_FLAGS', ''); - self::initIfNotExists('SPC_DEFAULT_CXX_FLAGS', ''); - self::initIfNotExists('SPC_EXTRA_LIBS', ''); - - // SPC_MICRO_PATCHES for linux - self::initIfNotExists('SPC_MICRO_PATCHES', 'static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream'); - - // Init linux-only env - self::initIfNotExists('UPX_EXEC', PKG_ROOT_PATH . '/bin/upx'); - self::initIfNotExists('GNU_ARCH', arch2gnu(php_uname('m'))); - - // optimization flags with different strip option - $php_extra_cflags_optimize = $builder->getOption('no-strip') ? '-g -O0' : '-g -Os'; - // optimization flags with different c compiler - $clang_use_lld = str_ends_with(getenv('CC'), 'clang') && LinuxSystemUtil::findCommand('lld') ? '-Xcompiler -fuse-ld=lld ' : ''; - - $init_spc_cmd_maps = [ - // Init default build command prefix - 'SPC_CMD_PREFIX_PHP_BUILDCONF' => './buildconf --force', - 'SPC_CMD_PREFIX_PHP_CONFIGURE' => $builder->getOption('ld_library_path') . ' ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg', - 'SPC_CMD_PREFIX_PHP_MAKE' => 'make -j' . getenv('SPC_CONCURRENCY'), - // Init default build vars for build command - 'SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS' => getenv('SPC_DEFAULT_C_FLAGS'), - 'SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, - 'SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS' => '-L' . BUILD_LIB_PATH, - 'SPC_CMD_VAR_PHP_CONFIGURE_LIBS' => '-ldl -lpthread -lm', - 'SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS' => $php_extra_cflags_optimize . ' -fno-ident -fPIE', - 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS' => '', - 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM' => $clang_use_lld . '-all-static', + // Init env.ini file, read order: + // WORKING_DIR/config/env.ini + // ROOT_DIR/config/env.ini + $ini_files = [ + WORKING_DIR . '/config/env.ini', + ROOT_DIR . '/config/env.ini', ]; - foreach ($init_spc_cmd_maps as $name => $value) { - self::initIfNotExists($name, $value); + $ini = null; + foreach ($ini_files as $ini_file) { + if (file_exists($ini_file)) { + $ini = parse_ini_file($ini_file, true); + break; + } } - - self::initUnixEnv($builder); - } - - private static function initDarwinEnv(BuilderBase $builder): void - { - // Init C Compiler and C++ Compiler - self::initIfNotExists('CC', 'clang'); - self::initIfNotExists('CXX', 'clang++'); - - // Init arch-specific cflags - self::initIfNotExists('SPC_DEFAULT_C_FLAGS', match (php_uname('m')) { - 'arm64', 'aarch64' => '--target=arm64-apple-darwin', - default => '--target=x86_64-apple-darwin', - }); - // Init arch-specific cxxflags - self::initIfNotExists('SPC_DEFAULT_CXX_FLAGS', match (php_uname('m')) { - 'arm64', 'aarch64' => '--target=arm64-apple-darwin', - default => '--target=x86_64-apple-darwin', - }); - - // Init extra libs (will be appended before `before-php-buildconf` event point) - self::initIfNotExists('SPC_EXTRA_LIBS', ''); - - // SPC_MICRO_PATCHES for macOS - self::initIfNotExists('SPC_MICRO_PATCHES', 'static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,macos_iconv'); - - $init_spc_cmd_maps = [ - // Init default build command prefix - 'SPC_CMD_PREFIX_PHP_BUILDCONF' => './buildconf --force', - 'SPC_CMD_PREFIX_PHP_CONFIGURE' => './configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg', - 'SPC_CMD_PREFIX_PHP_MAKE' => 'make -j' . getenv('SPC_CONCURRENCY'), - // Init default build vars for build command - 'SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS' => getenv('SPC_DEFAULT_C_FLAGS') . ' -Werror=unknown-warning-option', - 'SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, - 'SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS' => '-L' . BUILD_LIB_PATH, - 'SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS' => $builder->getOption('no-strip') ? '-g -O0' : '-g -Os', - 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS' => '-lresolv', - ]; - foreach ($init_spc_cmd_maps as $name => $value) { - self::initIfNotExists($name, $value); + if ($ini === null) { + throw new WrongUsageException('env.ini not found'); } - - self::initUnixEnv($builder); - } - - private static function initUnixEnv(BuilderBase $builder): void - { - self::putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); - self::putenv('PKG_CONFIG=' . BUILD_BIN_PATH . '/pkg-config'); - self::putenv('PKG_CONFIG_PATH=' . BUILD_ROOT_PATH . '/lib/pkgconfig'); - } - - /** - * Initialize the environment variable if it does not exist - * - * @param string $name Environment variable name - * @param string $value Environment variable value - */ - private static function initIfNotExists(string $name, string $value): void - { - if (($val = getenv($name)) === false) { - self::putenv($name . '=' . $value); - } else { - logger()->debug("env [{$name}] existing: {$val}"); + if ($ini === false || !isset($ini['global'])) { + throw new WrongUsageException('Failed to parse ' . $ini_file); } + self::applyConfig($ini['global']); + match (PHP_OS_FAMILY) { + 'Windows' => self::applyConfig($ini['windows']), + 'Darwin' => self::applyConfig($ini['macos']), + 'Linux' => self::applyConfig($ini['linux']), + 'BSD' => self::applyConfig($ini['freebsd']), + default => null, + }; } - private static function putenv(string $val): void + public static function putenv(string $val): void { f_putenv($val); self::$env_cache[] = $val; } + + private static function applyConfig(array $ini): void + { + foreach ($ini as $k => $v) { + if (getenv($k) === false) { + self::putenv($k . '=' . $v); + } + } + } } diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php new file mode 100644 index 00000000..1e60aa5a --- /dev/null +++ b/src/SPC/util/SPCConfigUtil.php @@ -0,0 +1,104 @@ +builder = BuilderProvider::makeBuilderByInput($input ?? new ArgvInput()); + } + } + + public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false): array + { + [$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib); + + ob_start(); + $this->builder->proveLibs($libraries); + $this->builder->proveExts($extensions); + ob_get_clean(); + $ldflags = $this->getLdflagsString(); + $libs = $this->getLibsString($libraries); + $cflags = $this->getIncludesString(); + + // embed + $libs = '-lphp -lc ' . $libs; + $extra_env = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'); + if (is_string($extra_env)) { + $libs .= ' ' . $extra_env; + } + // c++ + if ($this->builder->hasCpp()) { + $libs .= $this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++'; + } + return [ + 'cflags' => $cflags, + 'ldflags' => $ldflags, + 'libs' => $libs, + ]; + } + + private function getIncludesString(): string + { + $base = BUILD_INCLUDE_PATH; + $php_embed_includes = [ + "-I{$base}", + "-I{$base}/php", + "-I{$base}/php/main", + "-I{$base}/php/TSRM", + "-I{$base}/php/Zend", + "-I{$base}/php/ext", + ]; + return implode(' ', $php_embed_includes); + } + + private function getLdflagsString(): string + { + return '-L' . BUILD_LIB_PATH; + } + + private function getLibsString(array $libraries): string + { + $short_name = []; + foreach (array_reverse($libraries) as $library) { + $libs = Config::getLib($library, 'static-libs', []); + foreach ($libs as $lib) { + $short_name[] = $this->getShortLibName($lib); + } + if (PHP_OS_FAMILY !== 'Darwin') { + continue; + } + foreach (Config::getLib($library, 'frameworks', []) as $fw) { + $ks = '-framework ' . $fw; + if (!in_array($ks, $short_name)) { + $short_name[] = $ks; + } + } + } + // patch: imagick (imagemagick wrapper) for linux needs -lgomp + if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux') { + $short_name[] = '-lgomp'; + } + return implode(' ', $short_name); + } + + private function getShortLibName(string $lib): string + { + if (!str_starts_with($lib, 'lib') || !str_ends_with($lib, '.a')) { + return BUILD_LIB_PATH . '/' . $lib; + } + // get short name + return '-l' . substr($lib, 3, -2); + } +} diff --git a/src/SPC/util/UnixShell.php b/src/SPC/util/UnixShell.php index 16ae3f8c..44e97bfe 100644 --- a/src/SPC/util/UnixShell.php +++ b/src/SPC/util/UnixShell.php @@ -62,6 +62,9 @@ class UnixShell logger()->debug(ConsoleColor::blue('[EXEC] ') . ConsoleColor::gray($cmd)); } logger()->debug('Executed at: ' . debug_backtrace()[0]['file'] . ':' . debug_backtrace()[0]['line']); + if ($this->cd !== null) { + $cmd = 'cd ' . escapeshellarg($this->cd) . ' && ' . $cmd; + } exec($cmd, $out, $code); return [$code, $out]; } diff --git a/src/globals/common-tests/embed.c b/src/globals/common-tests/embed.c new file mode 100644 index 00000000..85c29921 --- /dev/null +++ b/src/globals/common-tests/embed.c @@ -0,0 +1,17 @@ +#include + +int main(int argc,char **argv){ + + PHP_EMBED_START_BLOCK(argc,argv) + + zend_file_handle file_handle; + + zend_stream_init_filename(&file_handle,"embed.php"); + + if(php_execute_script(&file_handle) == FAILURE){ + php_printf("Failed to execute PHP script.\n"); + } + + PHP_EMBED_END_BLOCK() + return 0; +} \ No newline at end of file diff --git a/src/globals/common-tests/embed.php b/src/globals/common-tests/embed.php new file mode 100644 index 00000000..aa1d7e41 --- /dev/null +++ b/src/globals/common-tests/embed.php @@ -0,0 +1,4 @@ +getPatchPoint(); } +function patch_point_interrupt(int $retcode, string $msg = ''): InterruptException +{ + return new InterruptException(message: $msg, code: $retcode); +} + // ------- function f_* part ------- // f_ means standard function wrapper diff --git a/src/globals/internal-env.php b/src/globals/internal-env.php new file mode 100644 index 00000000..60ea8370 --- /dev/null +++ b/src/globals/internal-env.php @@ -0,0 +1,49 @@ + (string) WindowsSystemUtil::getCpuCount(), + 'Darwin' => (string) MacOSSystemUtil::getCpuCount(), + 'Linux' => (string) LinuxSystemUtil::getCpuCount(), + 'BSD' => (string) BSDSystemUtil::getCpuCount(), + default => 1, +}); +define('GNU_ARCH', arch2gnu(php_uname('m'))); +define('MAC_ARCH', match ($_im8a = arch2gnu(php_uname('m'))) { + 'aarch64' => 'arm64', + default => $_im8a +}); + +// deprecated variables +define('SEPARATED_PATH', [ + '/' . pathinfo(BUILD_LIB_PATH)['basename'], // lib + '/' . pathinfo(BUILD_INCLUDE_PATH)['basename'], // include + BUILD_ROOT_PATH, +]); + +// add these to env vars with same name +GlobalEnvManager::putenv('BUILD_ROOT_PATH=' . BUILD_ROOT_PATH); +GlobalEnvManager::putenv('BUILD_INCLUDE_PATH=' . BUILD_INCLUDE_PATH); +GlobalEnvManager::putenv('BUILD_LIB_PATH=' . BUILD_LIB_PATH); +GlobalEnvManager::putenv('BUILD_BIN_PATH=' . BUILD_BIN_PATH); +GlobalEnvManager::putenv('PKG_ROOT_PATH=' . PKG_ROOT_PATH); +GlobalEnvManager::putenv('SOURCE_PATH=' . SOURCE_PATH); +GlobalEnvManager::putenv('DOWNLOAD_PATH=' . DOWNLOAD_PATH); +GlobalEnvManager::putenv('CPU_COUNT=' . CPU_COUNT); +GlobalEnvManager::putenv('GNU_ARCH=' . GNU_ARCH); +GlobalEnvManager::putenv('MAC_ARCH=' . MAC_ARCH); diff --git a/src/globals/patch/imagick_php84.patch b/src/globals/patch/imagick_php84.patch new file mode 100644 index 00000000..8eb98bb1 --- /dev/null +++ b/src/globals/patch/imagick_php84.patch @@ -0,0 +1,40 @@ +From 65e27f2bc02e7e8f1bf64e26e359e42a1331fca1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= +Date: Wed, 25 Sep 2024 10:56:28 +0200 +Subject: [PATCH] Fix removed "php_strtolower" for PHP 8.4 + +--- + imagick.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/imagick.c b/imagick.c +index 1b765389..ebab7ae7 100644 +--- a/imagick.c ++++ b/imagick.c +@@ -610,7 +610,7 @@ static zval *php_imagick_read_property(zend_object *object, zend_string *member, + if (format) { + retval = rv; + ZVAL_STRING(retval, format); +- php_strtolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); ++ zend_str_tolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); + IMAGICK_FREE_MAGICK_MEMORY(format); + } else { + retval = rv; +@@ -683,7 +683,7 @@ static zval *php_imagick_read_property(zval *object, zval *member, int type, voi + if (format) { + retval = rv; + ZVAL_STRING(retval, format); +- php_strtolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); ++ zend_str_tolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); + IMAGICK_FREE_MAGICK_MEMORY(format); + } else { + retval = rv; +@@ -766,7 +766,7 @@ static zval *php_imagick_read_property(zval *object, zval *member, int type, con + + if (format) { + ZVAL_STRING(retval, format, 1); +- php_strtolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); ++ zend_str_tolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); + IMAGICK_FREE_MAGICK_MEMORY(format); + } else { + ZVAL_STRING(retval, "", 1); \ No newline at end of file diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 22c67d3e..8f0c32cc 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -11,16 +11,35 @@ declare(strict_types=1); // --------------------------------- edit area --------------------------------- -$zts = false; +// test php version +$test_php_version = [ + '8.1', + '8.2', + '8.3', + '8.4', +]; + +// test os (macos-13, macos-14, ubuntu-latest, windows-latest are available) +$test_os = [ + 'macos-14', + 'ubuntu-latest', +]; + +// whether enable thread safe +$zts = true; $no_strip = false; -$upx = true; +// compress with upx +$upx = false; + +// prefer downloading pre-built packages to speed up the build process +$prefer_pre_built = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'rdkafka', - 'Windows' => 'rdkafka', + 'Linux', 'Darwin' => 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,gmp,gettext,iconv,igbinary,imagick,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,parallel,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,ssh2,sysvmsg,sysvsem,sysvshm,tidy,tokenizer,xlswriter,xml,xmlreader,xmlwriter,zip,zlib,yaml,zstd', + 'Windows' => 'amqp,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,ds,exif,ffi,fileinfo,filter,ftp,gd,iconv,igbinary,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pdo,pdo_mysql,pdo_sqlite,pdo_sqlsrv,phar,rar,redis,session,shmop,simdjson,simplexml,soap,sockets,sqlite3,sqlsrv,ssh2,swow,sysvshm,tokenizer,xml,xmlreader,xmlwriter,yac,yaml,zip,zlib', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). @@ -58,7 +77,7 @@ function _getCombination(string $type = 'common'): string } if (!isset($argv[1])) { - exit("Please use 'extensions', 'cmd' or 'libs' as output type"); + exit("Please use 'extensions', 'cmd', 'os', 'php' or 'libs' as output type"); } $trim_value = "\r\n \t,"; @@ -72,7 +91,43 @@ if (PHP_OS_FAMILY === 'Windows') { $final_extensions_cmd = $final_extensions; } +function quote2(string $param): string +{ + global $argv; + if (str_starts_with($argv[2], 'windows-')) { + return '"' . $param . '"'; + } + return $param; +} + +// generate download command +if ($argv[1] === 'download_cmd') { + $down_cmd = 'download '; + $down_cmd .= '--for-extensions=' . quote2($final_extensions) . ' '; + $down_cmd .= '--for-libs=' . quote2($final_libs) . ' '; + $down_cmd .= '--with-php=' . quote2($argv[3]) . ' '; + $down_cmd .= '--ignore-cache-sources=php-src '; + $down_cmd .= '--debug '; + $down_cmd .= '--retry=5 '; + $down_cmd .= '--shallow-clone '; + $down_cmd .= $prefer_pre_built ? '--prefer-pre-built ' : ''; +} + +// generate build command +if ($argv[1] === 'build_cmd' || $argv[1] === 'build_embed_cmd') { + $build_cmd = 'build '; + $build_cmd .= quote2($final_extensions) . ' '; + $build_cmd .= $zts ? '--enable-zts ' : ''; + $build_cmd .= $no_strip ? '--no-strip ' : ''; + $build_cmd .= $upx ? '--with-upx-pack ' : ''; + $build_cmd .= $final_libs === '' ? '' : ('--with-libs=' . quote2($final_libs) . ' '); + $build_cmd .= str_starts_with($argv[2], 'windows-') ? '' : '--build-fpm '; + $build_cmd .= '--debug '; +} + echo match ($argv[1]) { + 'os' => json_encode($test_os), + 'php' => json_encode($test_php_version), 'extensions' => $final_extensions, 'libs' => $final_libs, 'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)), @@ -80,5 +135,32 @@ echo match ($argv[1]) { 'zts' => $zts ? '--enable-zts' : '', 'no_strip' => $no_strip ? '--no-strip' : '', 'upx' => $upx ? '--with-upx-pack' : '', + 'prefer_pre_built' => $prefer_pre_built ? '--prefer-pre-built' : '', + 'download_cmd' => $down_cmd, + 'build_cmd' => $build_cmd, + 'build_embed_cmd' => $build_cmd, default => '', }; + +if ($argv[1] === 'download_cmd') { + if (str_starts_with($argv[2], 'windows-')) { + passthru('powershell.exe -file .\bin\spc.ps1 ' . $down_cmd, $retcode); + } else { + passthru('./bin/spc ' . $down_cmd, $retcode); + } +} elseif ($argv[1] === 'build_cmd') { + if (str_starts_with($argv[2], 'windows-')) { + passthru('powershell.exe -file .\bin\spc.ps1 ' . $build_cmd . ' --build-cli --build-micro', $retcode); + } else { + passthru('./bin/spc ' . $build_cmd . ' --build-cli --build-micro', $retcode); + } +} elseif ($argv[1] === 'build_embed_cmd') { + if (str_starts_with($argv[2], 'windows-')) { + // windows does not accept embed SAPI + passthru('powershell.exe -file .\bin\spc.ps1 ' . $build_cmd . ' --build-cli', $retcode); + } else { + passthru('./bin/spc ' . $build_cmd . ' --build-embed', $retcode); + } +} + +exit($retcode); diff --git a/tests/SPC/builder/BuilderTest.php b/tests/SPC/builder/BuilderTest.php new file mode 100644 index 00000000..5796f5df --- /dev/null +++ b/tests/SPC/builder/BuilderTest.php @@ -0,0 +1,253 @@ +builder = BuilderProvider::makeBuilderByInput(new ArgvInput()); + [$extensions, $libs] = DependencyUtil::getExtsAndLibs(['mbregex']); + $this->builder->proveLibs($libs); + CustomExt::loadCustomExt(); + foreach ($extensions as $extension) { + $class = CustomExt::getExtClass($extension); + $ext = new $class($extension, $this->builder); + $this->builder->addExt($ext); + } + foreach ($this->builder->getExts() as $ext) { + $ext->checkDependency(); + } + } + + public function testMakeBuilderByInput(): void + { + $this->assertInstanceOf(BuilderBase::class, BuilderProvider::makeBuilderByInput(new ArgvInput())); + $this->assertInstanceOf(BuilderBase::class, BuilderProvider::getBuilder()); + } + + public function testGetLibAndGetLibs() + { + $this->assertIsArray($this->builder->getLibs()); + $this->assertInstanceOf(LibraryBase::class, $this->builder->getLib('onig')); + } + + public function testGetExtAndGetExts() + { + $this->assertIsArray($this->builder->getExts()); + $this->assertInstanceOf(Extension::class, $this->builder->getExt('mbregex')); + } + + public function testHasCpp() + { + // mbregex doesn't have cpp + $this->assertFalse($this->builder->hasCpp()); + } + + public function testMakeExtensionArgs() + { + $this->assertStringContainsString('--enable-mbstring', $this->builder->makeExtensionArgs()); + } + + public function testIsLibsOnly() + { + // mbregex is not libs only + $this->assertFalse($this->builder->isLibsOnly()); + } + + public function testGetPHPVersionID() + { + if (file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { + $file = SOURCE_PATH . '/php-src/main/php_version.h'; + $cnt = preg_match('/PHP_VERSION_ID (\d+)/m', file_get_contents($file), $match); + if ($cnt !== 0) { + $this->assertEquals(intval($match[1]), $this->builder->getPHPVersionID()); + } else { + $this->expectException(RuntimeException::class); + $this->builder->getPHPVersionID(); + } + } else { + $this->expectException(WrongUsageException::class); + $this->builder->getPHPVersionID(); + } + } + + public function testGetPHPVersion() + { + if (file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { + $file = SOURCE_PATH . '/php-src/main/php_version.h'; + $cnt = preg_match('/PHP_VERSION "(\d+\.\d+\.\d+)"/', file_get_contents($file), $match); + if ($cnt !== 0) { + $this->assertEquals($match[1], $this->builder->getPHPVersion()); + } else { + $this->expectException(RuntimeException::class); + $this->builder->getPHPVersion(); + } + } else { + $this->expectException(WrongUsageException::class); + $this->builder->getPHPVersion(); + } + } + + public function testGetPHPVersionFromArchive() + { + $lock = file_exists(DOWNLOAD_PATH . '/.lock.json') ? file_get_contents(DOWNLOAD_PATH . '/.lock.json') : false; + if ($lock === false) { + $this->assertFalse($this->builder->getPHPVersionFromArchive()); + } else { + $lock = json_decode($lock, true); + $file = $lock['php-src']['filename'] ?? null; + if ($file === null) { + $this->assertFalse($this->builder->getPHPVersionFromArchive()); + } else { + $cnt = preg_match('/php-(\d+\.\d+\.\d+)/', $file, $match); + if ($cnt !== 0) { + $this->assertEquals($match[1], $this->builder->getPHPVersionFromArchive()); + } else { + $this->assertFalse($this->builder->getPHPVersionFromArchive()); + } + } + } + } + + public function testGetMicroVersion() + { + $file = FileSystem::convertPath(SOURCE_PATH . '/php-src/sapi/micro/php_micro.h'); + if (!file_exists($file)) { + $this->assertFalse($this->builder->getMicroVersion()); + } else { + $content = file_get_contents($file); + $ver = ''; + preg_match('/#define PHP_MICRO_VER_MAJ (\d)/m', $content, $match); + $ver .= $match[1] . '.'; + preg_match('/#define PHP_MICRO_VER_MIN (\d)/m', $content, $match); + $ver .= $match[1] . '.'; + preg_match('/#define PHP_MICRO_VER_PAT (\d)/m', $content, $match); + $ver .= $match[1]; + $this->assertEquals($ver, $this->builder->getMicroVersion()); + } + } + + public static function providerGetBuildTypeName(): array + { + return [ + [BUILD_TARGET_CLI, 'cli'], + [BUILD_TARGET_FPM, 'fpm'], + [BUILD_TARGET_MICRO, 'micro'], + [BUILD_TARGET_EMBED, 'embed'], + [BUILD_TARGET_ALL, 'cli, micro, fpm, embed'], + [BUILD_TARGET_CLI | BUILD_TARGET_EMBED, 'cli, embed'], + ]; + } + + /** + * @dataProvider providerGetBuildTypeName + */ + public function testGetBuildTypeName(int $target, string $name): void + { + $this->assertEquals($name, $this->builder->getBuildTypeName($target)); + } + + public function testGetOption() + { + // we cannot assure the option exists, so just tests default value + $this->assertEquals('foo', $this->builder->getOption('bar', 'foo')); + } + + public function testGetOptions() + { + $this->assertIsArray($this->builder->getOptions()); + } + + public function testSetOptionIfNotExist() + { + $this->assertEquals(null, $this->builder->getOption('bar')); + $this->builder->setOptionIfNotExist('bar', 'foo'); + $this->assertEquals('foo', $this->builder->getOption('bar')); + } + + public function testSetOption() + { + $this->assertEquals(null, $this->builder->getOption('bar')); + $this->builder->setOption('bar', 'foo'); + $this->assertEquals('foo', $this->builder->getOption('bar')); + } + + public function testGetEnvString() + { + $this->assertIsString($this->builder->getEnvString()); + putenv('TEST_SPC_BUILDER=foo'); + $this->assertStringContainsString('TEST_SPC_BUILDER=foo', $this->builder->getEnvString(['TEST_SPC_BUILDER'])); + } + + public function testValidateLibsAndExts() + { + $this->builder->validateLibsAndExts(); + $this->assertTrue(true); + } + + public static function providerEmitPatchPoint(): array + { + return [ + ['before-libs-extract'], + ['after-libs-extract'], + ['before-php-extract'], + ['after-php-extract'], + ['before-micro-extract'], + ['after-micro-extract'], + ['before-exts-extract'], + ['after-exts-extract'], + ['before-php-buildconf'], + ['before-php-configure'], + ['before-php-make'], + ['before-sanity-check'], + ]; + } + + /** + * @dataProvider providerEmitPatchPoint + */ + public function testEmitPatchPoint(string $point) + { + $code = 'builder->setOption('with-added-patch', ['/tmp/patch-point.' . $point . '.php']); + FileSystem::writeFile('/tmp/patch-point.' . $point . '.php', $code); + $this->expectOutputString('GOOD:' . $point); + $this->builder->emitPatchPoint($point); + } + + public function testEmitPatchPointNotExists() + { + $this->expectOutputRegex('/failed to run/'); + $this->expectException(RuntimeException::class); + $this->builder->setOption('with-added-patch', ['/tmp/patch-point.not_exsssists.php']); + $this->builder->emitPatchPoint('not-exists'); + } +} diff --git a/tests/SPC/builder/ExtensionTest.php b/tests/SPC/builder/ExtensionTest.php new file mode 100644 index 00000000..5e8ae92d --- /dev/null +++ b/tests/SPC/builder/ExtensionTest.php @@ -0,0 +1,100 @@ +proveLibs($libs); + CustomExt::loadCustomExt(); + foreach ($extensions as $extension) { + $class = CustomExt::getExtClass($extension); + $ext = new $class($extension, $builder); + $builder->addExt($ext); + } + foreach ($builder->getExts() as $ext) { + $ext->checkDependency(); + } + $this->extension = $builder->getExt('mbregex'); + } + + public function testPatches() + { + $this->assertFalse($this->extension->patchBeforeBuildconf()); + $this->assertFalse($this->extension->patchBeforeConfigure()); + $this->assertFalse($this->extension->patchBeforeMake()); + } + + public function testGetExtensionDependency() + { + $this->assertEquals('mbstring', current($this->extension->getExtensionDependency())->getName()); + } + + public function testGetWindowsConfigureArg() + { + $this->assertEquals('', $this->extension->getWindowsConfigureArg()); + } + + public function testGetConfigureArg() + { + $this->assertEquals('', $this->extension->getUnixConfigureArg()); + } + + public function testGetExtVersion() + { + // only swoole has version, we cannot test it + $this->assertEquals(null, $this->extension->getExtVersion()); + } + + public function testGetDistName() + { + $this->assertEquals('mbregex', $this->extension->getName()); + } + + public function testRunCliCheckWindows() + { + if (is_unix()) { + $this->markTestIncomplete('This test is for Windows only'); + } else { + $this->extension->runCliCheckWindows(); + $this->assertTrue(true); + } + } + + public function testGetLibFilesString() + { + $this->assertStringEndsWith('libonig.a', $this->extension->getLibFilesString()); + } + + public function testGetName() + { + $this->assertEquals('mbregex', $this->extension->getName()); + } + + public function testGetUnixConfigureArg() + { + $this->assertEquals('', $this->extension->getUnixConfigureArg()); + } + + public function testGetEnableArg() + { + $this->assertEquals('', $this->extension->getEnableArg()); + } +} diff --git a/tests/SPC/builder/linux/SystemUtilTest.php b/tests/SPC/builder/linux/SystemUtilTest.php new file mode 100644 index 00000000..341f2383 --- /dev/null +++ b/tests/SPC/builder/linux/SystemUtilTest.php @@ -0,0 +1,70 @@ +assertArrayHasKey('dist', $release); + $this->assertArrayHasKey('ver', $release); + $this->assertTrue($release['dist'] === 'alpine' && SystemUtil::isMuslDist() || $release['dist'] !== 'alpine' && !SystemUtil::isMuslDist()); + } + + public function testFindStaticLib() + { + $this->assertIsArray(SystemUtil::findStaticLib('ld-linux-x86-64.so.2')); + } + + public function testGetCpuCount() + { + $this->assertIsInt(SystemUtil::getCpuCount()); + } + + public function testFindHeader() + { + $this->assertIsArray(SystemUtil::findHeader('elf.h')); + } + + public function testGetCrossCompilePrefix() + { + $this->assertIsString(SystemUtil::getCrossCompilePrefix('gcc', 'x86_64')); + } + + public function testGetCCType() + { + $this->assertEquals('gcc', SystemUtil::getCCType('xjfoiewjfoewof-gcc')); + } + + public function testGetSupportedDistros() + { + $this->assertIsArray(SystemUtil::getSupportedDistros()); + } + + public function testFindHeaders() + { + $this->assertIsArray(SystemUtil::findHeaders(['elf.h'])); + } + + public function testFindStaticLibs() + { + $this->assertIsArray(SystemUtil::findStaticLibs(['ld-linux-x86-64.so.2'])); + } +} diff --git a/tests/SPC/builder/macos/SystemUtilTest.php b/tests/SPC/builder/macos/SystemUtilTest.php new file mode 100644 index 00000000..75964508 --- /dev/null +++ b/tests/SPC/builder/macos/SystemUtilTest.php @@ -0,0 +1,31 @@ +assertIsInt(SystemUtil::getCpuCount()); + } + + public function testGetArchCFlags() + { + $this->assertEquals('--target=x86_64-apple-darwin', SystemUtil::getArchCFlags('x86_64')); + } +} diff --git a/tests/SPC/builder/unix/UnixSystemUtilTest.php b/tests/SPC/builder/unix/UnixSystemUtilTest.php new file mode 100644 index 00000000..fec21e36 --- /dev/null +++ b/tests/SPC/builder/unix/UnixSystemUtilTest.php @@ -0,0 +1,52 @@ + 'SPC\builder\linux\SystemUtil', + 'Darwin' => 'SPC\builder\macos\SystemUtil', + 'FreeBSD' => 'SPC\builder\freebsd\SystemUtil', + default => null, + }; + if ($util_class === null) { + self::markTestIncomplete('This test is only for Unix'); + } + $this->util = new $util_class(); + } + + /** + * @throws FileSystemException + */ + public function testMakeCmakeToolchainFile() + { + $str = $this->util->makeCmakeToolchainFile(PHP_OS_FAMILY, 'x86_64', ''); + $this->assertIsString($str); + } + + public function testFindCommand() + { + $this->assertIsString($this->util->findCommand('bash')); + } + + public function testMakeEnvVarString() + { + $this->assertEquals("PATH='/usr/bin' PKG_CONFIG='/usr/bin/pkg-config'", $this->util->makeEnvVarString(['PATH' => '/usr/bin', 'PKG_CONFIG' => '/usr/bin/pkg-config'])); + } +} diff --git a/tests/SPC/store/CurlHookTest.php b/tests/SPC/store/CurlHookTest.php new file mode 100644 index 00000000..8b950da6 --- /dev/null +++ b/tests/SPC/store/CurlHookTest.php @@ -0,0 +1,29 @@ +assertEmpty($header); + } else { + $this->assertEquals(['Authorization: Bearer ' . getenv('GITHUB_TOKEN')], $header); + } + $header = []; + putenv('GITHUB_TOKEN=token'); + CurlHook::setupGithubToken('GET', 'https://example.com', $header); + $this->assertEquals(['Authorization: Bearer token'], $header); + } +} diff --git a/tests/SPC/store/DownloaderTest.php b/tests/SPC/store/DownloaderTest.php new file mode 100644 index 00000000..a9507e08 --- /dev/null +++ b/tests/SPC/store/DownloaderTest.php @@ -0,0 +1,112 @@ +assertEquals( + 'https://api.github.com/repos/AOMediaCodec/libavif/tarball/v1.1.1', + Downloader::getLatestGithubTarball('libavif', [ + 'type' => 'ghtar', + 'repo' => 'AOMediaCodec/libavif', + ])[0] + ); + } + + public function testDownloadGit() + { + Downloader::downloadGit('setup-static-php', 'https://github.com/static-php/setup-static-php.git', 'main'); + $this->assertTrue(true); + + // test keyboard interrupt + try { + Downloader::downloadGit('setup-static-php', 'https://github.com/static-php/setup-static-php.git', 'SIGINT'); + } catch (WrongUsageException $e) { + $this->assertStringContainsString('interrupted', $e->getMessage()); + return; + } + $this->fail('Expected exception not thrown'); + } + + public function testDownloadFile() + { + Downloader::downloadFile('fake-file', 'https://fakecmd.com/curlDown', 'curlDown.exe'); + $this->assertTrue(true); + + // test keyboard interrupt + try { + Downloader::downloadFile('fake-file', 'https://fakecmd.com/curlDown', 'SIGINT'); + } catch (WrongUsageException $e) { + $this->assertStringContainsString('interrupted', $e->getMessage()); + return; + } + $this->fail('Expected exception not thrown'); + } + + public function testLockSource() + { + Downloader::lockSource('fake-file', ['source_type' => 'archive', 'filename' => 'fake-file-name', 'move_path' => 'fake-path', 'lock_as' => 'fake-lock-as']); + $this->assertFileExists(DOWNLOAD_PATH . '/.lock.json'); + $json = json_decode(file_get_contents(DOWNLOAD_PATH . '/.lock.json'), true); + $this->assertIsArray($json); + $this->assertArrayHasKey('fake-file', $json); + $this->assertArrayHasKey('source_type', $json['fake-file']); + $this->assertArrayHasKey('filename', $json['fake-file']); + $this->assertArrayHasKey('move_path', $json['fake-file']); + $this->assertArrayHasKey('lock_as', $json['fake-file']); + $this->assertEquals('archive', $json['fake-file']['source_type']); + $this->assertEquals('fake-file-name', $json['fake-file']['filename']); + $this->assertEquals('fake-path', $json['fake-file']['move_path']); + $this->assertEquals('fake-lock-as', $json['fake-file']['lock_as']); + } + + public function testGetLatestBitbucketTag() + { + $this->assertEquals( + 'abc.tar.gz', + Downloader::getLatestBitbucketTag('abc', [ + 'repo' => 'MATCHED/def', + ])[1] + ); + $this->assertEquals( + 'abc-1.0.0.tar.gz', + Downloader::getLatestBitbucketTag('abc', [ + 'repo' => 'abc/def', + ])[1] + ); + } + + public function testGetLatestGithubRelease() + { + $this->assertEquals( + 'ghreltest.tar.gz', + Downloader::getLatestGithubRelease('ghrel', [ + 'type' => 'ghrel', + 'repo' => 'ghreltest/ghrel', + 'match' => 'ghreltest.tar.gz', + ])[1] + ); + } + + public function testGetFromFileList() + { + $filelist = Downloader::getFromFileList('fake-filelist', [ + 'url' => 'https://fakecmd.com/filelist', + 'regex' => '/href="(?filelist-(?[^"]+)\.tar\.xz)"/', + ]); + $this->assertIsArray($filelist); + $this->assertEquals('filelist-4.7.0.tar.xz', $filelist[1]); + } +} diff --git a/tests/assets/filelist.gz b/tests/assets/filelist.gz new file mode 100644 index 00000000..fb566ebf Binary files /dev/null and b/tests/assets/filelist.gz differ diff --git a/tests/assets/github_api_AOMediaCodec_libavif_releases.json.gz b/tests/assets/github_api_AOMediaCodec_libavif_releases.json.gz new file mode 100644 index 00000000..31e0b126 Binary files /dev/null and b/tests/assets/github_api_AOMediaCodec_libavif_releases.json.gz differ diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 00000000..d573204b --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,6 @@ + [['name' => '1.0.0']], 'tag_name' => '1.0.0'])); + return true; + } + if (str_contains($command, 'https://bitbucket.org/')) { + $output = explode("\n", str_contains($command, 'MATCHED') ? "HTTP/2 200 OK\r\ncontent-disposition: attachment; filename=abc.tar.gz\r\n\r\n" : "HTTP/2 200 OK\r\n\r\n"); + return true; + } + if (str_contains($command, 'ghreltest/ghrel')) { + $output = explode("\n", json_encode([[ + 'prerelease' => false, + 'assets' => [ + [ + 'name' => 'ghreltest.tar.gz', + 'browser_download_url' => 'https://fakecmd.com/ghreltest.tar.gz', + ], + ], + ]])); + return true; + } + if (str_contains($command, 'filelist')) { + $output = explode("\n", gzdecode(file_get_contents(__DIR__ . '/../assets/filelist.gz'))); + return true; + } + $result_code = -2; + $output = null; + return false; +} + +function f_passthru(string $cmd): bool +{ + if (str_starts_with($cmd, 'git')) { + if (str_contains($cmd, '--branch "SIGINT"')) { + throw new RuntimeException('Interrupt', 2); + } + return true; + } + if (str_contains($cmd, 'https://fakecmd.com/curlDown')) { + if (str_contains($cmd, 'SIGINT')) { + throw new RuntimeException('Interrupt', 2); + } + return true; + } + + // allowed commands + $allowed = ['cp', 'copy', 'xcopy']; + foreach ($allowed as $a) { + if (str_starts_with($cmd, $a)) { + \f_passthru($cmd); + return true; + } + } + throw new RuntimeException('Invalid tests'); +}