From e0dcbc31667acd071419c477893819cb60b56bdc Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Mon, 28 Sep 2026 10:14:12 +0800 Subject: [PATCH] test(nano): verify Apple native targets --- .github/actions/unix-arm64-build/action.yml | 48 +++++++++++++++++++++ .github/smoke/macos/main.php | 9 ++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/.github/actions/unix-arm64-build/action.yml b/.github/actions/unix-arm64-build/action.yml index d6cebaf9..8e61d2aa 100644 --- a/.github/actions/unix-arm64-build/action.yml +++ b/.github/actions/unix-arm64-build/action.yml @@ -171,6 +171,48 @@ runs: output="$("${smoke_binary}")" test "${output}" = '${{ inputs.smoke-output }}' + - name: Build and verify Apple Nano native applications + if: inputs.os == 'macos' + shell: bash + run: | + set -euo pipefail + + smoke_root='.github/smoke/macos' + nano_smoke="${smoke_root}/macos_nano_smoke" + ./tpc "${smoke_root}/project.yml" \ + --nano \ + --build-dir "${smoke_root}/nano-build" \ + --output "${nano_smoke}" \ + --job 2 \ + --no-progress + test -x "${nano_smoke}" + test "$("${nano_smoke}")" = 'macos-arm64-smoke-ok:nts' + file "${nano_smoke}" + otool -L "${nano_smoke}" + if otool -L "${nano_smoke}" | grep -Eiq 'libphp|libphpx'; then + echo 'macOS Nano executable unexpectedly links a host PHP/PHPX library' >&2 + exit 1 + fi + + ./tpc examples/apple-native/project.yml --nano --job 2 --no-progress + test -x examples/apple-native/typephp_macos_hello + file examples/apple-native/typephp_macos_hello + otool -L examples/apple-native/typephp_macos_hello + + ./tpc examples/apple-native/ios-simulator.yml --nano --job 2 --no-progress + ios_simulator='examples/apple-native/typephp_ios_simulator_hello' + test -x "${ios_simulator}" + file "${ios_simulator}" + xcrun vtool -show-build "${ios_simulator}" + xcrun vtool -show-build "${ios_simulator}" | grep -Eq 'platform[[:space:]]+IOSSIMULATOR' + + ./tpc examples/apple-native/ios.yml --nano --job 2 --no-progress + ios_device='examples/apple-native/typephp_ios_hello' + test -x "${ios_device}" + file "${ios_device}" + xcrun vtool -show-build "${ios_device}" + xcrun vtool -show-build "${ios_device}" | grep -Eq 'platform[[:space:]]+IOS$' + - name: Show native dependencies shell: bash run: | @@ -219,3 +261,9 @@ runs: .github/smoke/${{ inputs.smoke-directory }}/${{ inputs.smoke-binary }} .github/smoke/${{ inputs.smoke-directory }}/build/**/*.cc .github/smoke/${{ inputs.smoke-directory }}/build/**/*.h + .github/smoke/macos/macos_nano_smoke + .github/smoke/macos/nano-build/**/*.cc + .github/smoke/macos/nano-build/**/*.h + examples/apple-native/typephp_macos_hello + examples/apple-native/typephp_ios_simulator_hello + examples/apple-native/typephp_ios_hello diff --git a/.github/smoke/macos/main.php b/.github/smoke/macos/main.php index 11949d2a..987fd0a1 100644 --- a/.github/smoke/macos/main.php +++ b/.github/smoke/macos/main.php @@ -9,14 +9,17 @@ function requireMacosCondition(bool $condition, string $message): void function main(): void { + $zts = PHP_ZTS !== 0 && PHP_ZTS !== false; requireMacosCondition(PHP_OS_FAMILY === 'Darwin', 'Expected PHP_OS_FAMILY=Darwin'); requireMacosCondition(DIRECTORY_SEPARATOR === '/', 'Expected the Unix directory separator'); - requireMacosCondition(PHP_ZTS !== 0 && PHP_ZTS !== false, 'Expected a ZTS PHP runtime'); - requireMacosCondition(macos_native_php_is_zts(), 'The native ZTS macro is not enabled'); + requireMacosCondition( + macos_native_php_is_zts() === $zts, + 'PHP_ZTS does not match the native ZTS macro', + ); requireMacosCondition(macos_native_is_arm64(), 'The native compiler target is not ARM64'); requireMacosCondition(macos_current_process_id() > 0, 'getpid() failed'); requireMacosCondition(macos_logical_processor_count() > 0, 'sysctl() returned no processors'); requireMacosCondition(macos_has_mach_host_port(), 'mach_host_self() failed'); - echo 'macos-arm64-smoke-ok:zts'; + echo 'macos-arm64-smoke-ok:', $zts ? 'zts' : 'nts'; }