mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 03:41:06 +07:00
Add support for zts and debug extensions on macOS
This commit is contained in:
parent
201dd6c1db
commit
812360879e
@ -57,25 +57,41 @@ 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
|
||||
handle_dependency_extensions_for_suffix >/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
|
||||
}
|
||||
|
||||
# Install dependency extensions if the PHP version is ZTS or Debug.
|
||||
handle_dependency_extensions_for_suffix() {
|
||||
suffix="$(get_php_formula_suffix)"
|
||||
if [[ -n "$suffix" ]]; then
|
||||
brew_opts=(-sf)
|
||||
patch_abstract_file >/dev/null 2>&1
|
||||
dependency_extensions=()
|
||||
while IFS= read -r dependency_extension; do
|
||||
dependency_extensions+=("$dependency_extension")
|
||||
done < <(grep -E "depends_on.*shivammathur/extensions" "$formula_file" | sed -E 's/.*\/([^@]+)@.*/\1/')
|
||||
for dependency_extension in "${dependency_extensions[@]}"; do
|
||||
brew install "${brew_opts[@]}" "$ext_tap/$dependency_extension@$version" >/dev/null 2>&1 && copy_brew_extensions "$dependency_extension"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to patch the abstract file in the extensions tap.
|
||||
patch_abstract_file() {
|
||||
abstract_path="$tap_dir"/"$ext_tap"/Abstract/abstract-php-extension.rb
|
||||
if [ -e "$abstract_path" ] && ! grep -q "$suffix" "$abstract_path"; then
|
||||
sudo sed -i '' -e "s|php@#{\(.*\)}|php@#{\1}$suffix|g" -e "s|php_version /|\"#{php_version}$suffix\" /|g" "$abstract_path"
|
||||
fi
|
||||
}
|
||||
|
||||
# Helper function to add an extension.
|
||||
add_extension_helper() {
|
||||
local extension=$1
|
||||
|
@ -62,6 +62,7 @@ configure_brew() {
|
||||
add_brew
|
||||
brew_path="$(command -v brew)"
|
||||
fi
|
||||
brew_opts=(-f)
|
||||
brew_path_dir="$(dirname "$brew_path")"
|
||||
brew_prefix="$brew_path_dir"/..
|
||||
brew_repo="$brew_path_dir/$(dirname "$(readlink "$brew_path")")"/..
|
||||
@ -74,6 +75,7 @@ configure_brew() {
|
||||
export HOMEBREW_NO_ENV_HINTS=1
|
||||
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
||||
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
|
||||
export brew_opts
|
||||
export brew_path
|
||||
export brew_path_dir
|
||||
export brew_prefix
|
||||
|
Loading…
Reference in New Issue
Block a user