Add zts support on macOS

This commit is contained in:
Shivam Mathur 2023-12-25 03:09:27 +05:30
parent 97e0a9729a
commit 201dd6c1db
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
2 changed files with 24 additions and 8 deletions

View File

@ -473,7 +473,7 @@ On GitHub Actions you can assign the `setup-php` step an `id`, you can use the s
#### `phpts` (optional) #### `phpts` (optional)
- Specify to set up a thread-safe build of PHP on Linux and Windows. - Specify to set up a thread-safe build of PHP.
- Accepts `nts` for non-thread-safe and `zts` or `ts` for thread-safe. - Accepts `nts` for non-thread-safe and `zts` or `ts` for thread-safe.
- By default, it is set to `nts`. - By default, it is set to `nts`.
- See [thread safe setup](#thread-safe-setup) for more info. - See [thread safe setup](#thread-safe-setup) for more info.
@ -571,16 +571,14 @@ steps:
### Thread Safe Setup ### Thread Safe Setup
> Set up `TS` or `NTS` PHP on `Linux` and `Windows`. > Set up `TS` or `NTS` PHP.
- `NTS` versions are set up by default. - `NTS` versions are set up by default.
- On `macOS` only `NTS` versions are supported currently.
- On `Linux` and `Windows` both `TS` and `NTS` versions are supported.
```yaml ```yaml
jobs: jobs:
run: run:
runs-on: [ubuntu-latest, windows-latest] runs-on: [ubuntu-latest, windows-latest, macos-latest]
name: Setup PHP TS name: Setup PHP TS
steps: steps:
- name: Setup PHP - name: Setup PHP

View File

@ -57,12 +57,21 @@ add_brew_extension() {
if check_extension "$extension"; then if check_extension "$extension"; then
add_log "${tick:?}" "$extension" "Enabled" add_log "${tick:?}" "$extension" "Enabled"
else else
brew_opts=(-f)
add_brew_tap "$php_tap" add_brew_tap "$php_tap"
add_brew_tap "$ext_tap" add_brew_tap "$ext_tap"
if [ "${ts:?}" = "zts" ]; then
brew_opts=(-sf)
suffix="$(get_php_formula_suffix)"
abstract_path="$tap_dir"/"$ext_tap"/Abstract/abstract-php-extension.rb
if [ -f "$abstract_path" ]; then
grep -q zts "$abstract_path" || sed -i '' "s/php@${version}/php@${version}$suffix/" "$abstract_path"
fi
fi
sudo mv "$tap_dir"/"$ext_tap"/.github/deps/"$formula"/* "${core_repo:?}/Formula/" 2>/dev/null || true sudo mv "$tap_dir"/"$ext_tap"/.github/deps/"$formula"/* "${core_repo:?}/Formula/" 2>/dev/null || true
update_dependencies >/dev/null 2>&1 update_dependencies >/dev/null 2>&1
disable_dependency_extensions "$extension" >/dev/null 2>&1 disable_dependency_extensions "$extension" >/dev/null 2>&1
(brew install -f "$ext_tap/$formula@$version" >/dev/null 2>&1 && copy_brew_extensions "$formula") || pecl_install "$extension" >/dev/null 2>&1 (brew install "${brew_opts[@]}" "$ext_tap/$formula@$version" >/dev/null 2>&1 && copy_brew_extensions "$formula") || pecl_install "$extension" >/dev/null 2>&1
add_extension_log "$extension" "Installed and enabled" add_extension_log "$extension" "Installed and enabled"
fi fi
} }
@ -181,8 +190,9 @@ add_php() {
existing_version=$2 existing_version=$2
add_brew_tap "$php_tap" add_brew_tap "$php_tap"
update_dependencies update_dependencies
[ "${debug:?}" = "debug" ] && php_formula="$php_formula-debug" suffix="$(get_php_formula_suffix)"
if [ "$existing_version" != "false" ]; then php_formula="shivammathur/php/php@$version$suffix"
if [[ "$existing_version" != "false" && -z "$suffix" ]]; then
([ "$action" = "upgrade" ] && brew upgrade -f "$php_formula") || brew unlink "$php_formula" ([ "$action" = "upgrade" ] && brew upgrade -f "$php_formula") || brew unlink "$php_formula"
else else
brew install -f "$php_formula" brew install -f "$php_formula"
@ -190,6 +200,14 @@ add_php() {
brew link --force --overwrite "$php_formula" brew link --force --overwrite "$php_formula"
} }
# Function to get formula suffix
get_php_formula_suffix() {
local suffix
[ "${debug:?}" = "debug" ] && suffix="-debug"
[ "${ts:?}" = "zts" ] && suffix="$suffix-zts"
echo "$suffix"
}
# Function to get extra version. # Function to get extra version.
php_extra_version() { php_extra_version() {
php_formula_file="$tap_dir"/"$php_tap"/Formula/php@"$version".rb php_formula_file="$tap_dir"/"$php_tap"/Formula/php@"$version".rb