TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
6.0 KiB
179 lines
6.0 KiB
name: ARM64 and macOS tpc build
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: platform-tpc-${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
COMPOSER_NO_INTERACTION: 1
|
|
COMPOSER_PROCESS_TIMEOUT: 0
|
|
|
|
jobs:
|
|
build-tpc:
|
|
name: ${{ matrix.target.label }} (PHP ${{ matrix.php }} ZTS)
|
|
runs-on: ${{ matrix.target.runner }}
|
|
timeout-minutes: 90
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
php: ["8.4", "8.5"]
|
|
target:
|
|
- label: Linux ARM64
|
|
runner: ubuntu-22.04-arm
|
|
os: linux
|
|
arch: arm64
|
|
library_ext: so
|
|
smoke_dir: linux-arm64
|
|
smoke_binary: linux_arm64_smoke
|
|
smoke_output: linux-arm64-smoke-ok:zts
|
|
- label: macOS ARM64
|
|
runner: macos-15
|
|
os: macos
|
|
arch: arm64
|
|
library_ext: dylib
|
|
smoke_dir: macos
|
|
smoke_binary: macos_smoke
|
|
smoke_output: macos-arm64-smoke-ok:zts
|
|
env:
|
|
PHPX_HOME: ${{ github.workspace }}/vendor/swoole/phpx
|
|
|
|
steps:
|
|
- name: Checkout TypePHP
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ matrix.php }}
|
|
coverage: none
|
|
extensions: mbstring
|
|
ini-values: precision=17, memory_limit=4G, error_reporting=E_ERROR|E_WARNING, display_errors=1, display_startup_errors=1, log_errors=0
|
|
tools: composer:v2
|
|
env:
|
|
fail-fast: true
|
|
phpts: ts
|
|
update: true
|
|
|
|
- name: Install Linux build dependencies
|
|
if: matrix.target.os == 'linux'
|
|
shell: bash
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install --yes build-essential cmake libgmp-dev libmpfr-dev pkg-config
|
|
|
|
- name: Install macOS build dependencies
|
|
if: matrix.target.os == 'macos'
|
|
shell: bash
|
|
run: brew install cmake gmp mpfr pkg-config
|
|
|
|
- name: Verify ZTS PHP and architecture
|
|
shell: bash
|
|
run: |
|
|
php -r 'if (!PHP_ZTS) { fwrite(STDERR, "Expected a ZTS PHP build\n"); exit(1); }'
|
|
case "$(php -r 'echo PHP_VERSION;')" in
|
|
"${{ matrix.php }}"*) ;;
|
|
*) echo "setup-php installed an unexpected PHP version" >&2; exit 1 ;;
|
|
esac
|
|
case "$(uname -m)" in
|
|
arm64|aarch64) ;;
|
|
*) echo "Expected an ARM64 runner, got $(uname -m)" >&2; exit 1 ;;
|
|
esac
|
|
|
|
php_home="$(php-config --prefix)"
|
|
embed_library="${php_home}/lib/libphp.${{ matrix.target.library_ext }}"
|
|
test -x "${php_home}/bin/php-config"
|
|
test -f "${embed_library}"
|
|
echo "PHP_HOME=${php_home}" >> "${GITHUB_ENV}"
|
|
if [[ '${{ matrix.target.os }}' == 'linux' ]]; then
|
|
echo "LD_LIBRARY_PATH=${PHPX_HOME}/lib:${php_home}/lib" >> "${GITHUB_ENV}"
|
|
else
|
|
echo "DYLD_LIBRARY_PATH=${PHPX_HOME}/lib:${php_home}/lib" >> "${GITHUB_ENV}"
|
|
fi
|
|
php -v
|
|
php-config --configure-options
|
|
|
|
- name: Patch php_hash.h C++ compatibility
|
|
uses: ./.github/actions/patch-php-headers
|
|
|
|
- name: Install Composer dependencies
|
|
run: composer install --prefer-dist --no-progress
|
|
|
|
- name: Build PHPX
|
|
shell: bash
|
|
run: |
|
|
cmake -S "${PHPX_HOME}" -B "${PHPX_HOME}/build" \
|
|
-D CMAKE_BUILD_TYPE=Release \
|
|
-D BUILD_TESTS=OFF \
|
|
-D BUILD_EXT=OFF \
|
|
-D GITHUB_ACTION=ON \
|
|
-D php_dir="${PHP_HOME}"
|
|
cmake --build "${PHPX_HOME}/build" --target phpx --parallel 2
|
|
test -f "${PHPX_HOME}/lib/libphpx.${{ matrix.target.library_ext }}"
|
|
|
|
- name: Build tpc
|
|
shell: bash
|
|
run: |
|
|
php bin/tpc.php project.yml --job 2 --no-progress
|
|
test -x ./tpc
|
|
file ./tpc
|
|
file ./tpc | grep -Eiq 'arm64|aarch64|ARM aarch64'
|
|
./tpc --version
|
|
|
|
- name: Run platform smoke test
|
|
shell: bash
|
|
run: |
|
|
smoke_root=".github/smoke/${{ matrix.target.smoke_dir }}"
|
|
./tpc "${smoke_root}/project.yml" --job 1 --no-progress
|
|
smoke_binary="${smoke_root}/${{ matrix.target.smoke_binary }}"
|
|
test -x "${smoke_binary}"
|
|
output="$("${smoke_binary}")"
|
|
test "${output}" = '${{ matrix.target.smoke_output }}'
|
|
|
|
- name: Show native dependencies
|
|
shell: bash
|
|
run: |
|
|
if [[ '${{ matrix.target.os }}' == 'linux' ]]; then
|
|
ldd ./tpc
|
|
else
|
|
otool -L ./tpc
|
|
fi
|
|
|
|
- name: Package tested compiler
|
|
if: startsWith(github.ref, 'refs/tags/') && matrix.php == '8.5'
|
|
shell: bash
|
|
run: |
|
|
composer install --no-dev --prefer-dist --no-progress --classmap-authoritative
|
|
export TYPEPHP_PACKAGE_VERSION="${GITHUB_REF_NAME}"
|
|
php package.php
|
|
test "$(find . -maxdepth 1 -name 'tpc_v*_${{ matrix.target.os }}_${{ matrix.target.arch }}.tar.gz' -type f | wc -l)" -eq 1
|
|
|
|
- name: Upload release package
|
|
if: startsWith(github.ref, 'refs/tags/') && matrix.php == '8.5'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: release-${{ matrix.target.os }}-${{ matrix.target.arch }}-php-${{ matrix.php }}-zts
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
path: tpc_v*_${{ matrix.target.os }}_${{ matrix.target.arch }}.tar.gz
|
|
|
|
- name: Upload platform build outputs
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tpc-${{ matrix.target.os }}-${{ matrix.target.arch }}-php-${{ matrix.php }}-zts
|
|
include-hidden-files: true
|
|
if-no-files-found: warn
|
|
retention-days: 7
|
|
path: |
|
|
tpc
|
|
.github/smoke/${{ matrix.target.smoke_dir }}/${{ matrix.target.smoke_binary }}
|
|
.github/smoke/${{ matrix.target.smoke_dir }}/build/**/*.cc
|
|
.github/smoke/${{ matrix.target.smoke_dir }}/build/**/*.h
|
|
|