mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Add zts support on macOS
This commit is contained in:
parent
97e0a9729a
commit
201dd6c1db
@ -473,7 +473,7 @@ On GitHub Actions you can assign the `setup-php` step an `id`, you can use the s
|
||||
|
||||
#### `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.
|
||||
- By default, it is set to `nts`.
|
||||
- See [thread safe setup](#thread-safe-setup) for more info.
|
||||
@ -571,16 +571,14 @@ steps:
|
||||
|
||||
### 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.
|
||||
- On `macOS` only `NTS` versions are supported currently.
|
||||
- On `Linux` and `Windows` both `TS` and `NTS` versions are supported.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
run:
|
||||
runs-on: [ubuntu-latest, windows-latest]
|
||||
runs-on: [ubuntu-latest, windows-latest, macos-latest]
|
||||
name: Setup PHP TS
|
||||
steps:
|
||||
- name: Setup PHP
|
||||
|
@ -57,12 +57,21 @@ add_brew_extension() {
|
||||
if check_extension "$extension"; then
|
||||
add_log "${tick:?}" "$extension" "Enabled"
|
||||
else
|
||||
brew_opts=(-f)
|
||||
add_brew_tap "$php_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
|
||||
update_dependencies >/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"
|
||||
fi
|
||||
}
|
||||
@ -181,8 +190,9 @@ add_php() {
|
||||
existing_version=$2
|
||||
add_brew_tap "$php_tap"
|
||||
update_dependencies
|
||||
[ "${debug:?}" = "debug" ] && php_formula="$php_formula-debug"
|
||||
if [ "$existing_version" != "false" ]; then
|
||||
suffix="$(get_php_formula_suffix)"
|
||||
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"
|
||||
else
|
||||
brew install -f "$php_formula"
|
||||
@ -190,6 +200,14 @@ add_php() {
|
||||
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.
|
||||
php_extra_version() {
|
||||
php_formula_file="$tap_dir"/"$php_tap"/Formula/php@"$version".rb
|
||||
|
Loading…
Reference in New Issue
Block a user