Merge pull request #14411 from hyuraku/move_default_prefix_to-extend-os

separate default_prefix to `extend/os` files
This commit is contained in:
Mike McQuaid 2023-01-25 13:16:12 +00:00 committed by GitHub
commit 41765e6512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 10 deletions

View File

@ -1,15 +1,9 @@
# typed: true
# frozen_string_literal: true
require "simulate_system"
module Homebrew
# TODO: Refactor and move to extend/os
DEFAULT_PREFIX, DEFAULT_REPOSITORY = if OS.mac? && Hardware::CPU.arm? # rubocop:disable Homebrew/MoveToExtendOS
[HOMEBREW_MACOS_ARM_DEFAULT_PREFIX, HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY]
elsif Homebrew::SimulateSystem.simulating_or_running_on_linux?
[HOMEBREW_LINUX_DEFAULT_PREFIX, HOMEBREW_LINUX_DEFAULT_REPOSITORY]
else
[HOMEBREW_DEFAULT_PREFIX, HOMEBREW_DEFAULT_REPOSITORY]
end.freeze
DEFAULT_PREFIX = HOMEBREW_DEFAULT_PREFIX
DEFAULT_REPOSITORY = HOMEBREW_DEFAULT_REPOSITORY
end
require "extend/os/default_prefix"

View File

@ -0,0 +1,8 @@
# typed: true
# frozen_string_literal: true
if OS.mac?
require "extend/os/mac/default_prefix"
elsif OS.linux?
require "extend/os/linux/default_prefix"
end

View File

@ -0,0 +1,10 @@
# typed: true
# frozen_string_literal: true
module Homebrew
remove_const(:DEFAULT_PREFIX)
DEFAULT_PREFIX = HOMEBREW_LINUX_DEFAULT_PREFIX
remove_const(:DEFAULT_REPOSITORY)
DEFAULT_REPOSITORY = HOMEBREW_LINUX_DEFAULT_REPOSITORY
end

View File

@ -0,0 +1,17 @@
# typed: true
# frozen_string_literal: true
require "simulate_system"
module Homebrew
if Hardware::CPU.arm? || Homebrew::SimulateSystem.simulating_or_running_on_linux?
remove_const(:DEFAULT_PREFIX)
remove_const(:DEFAULT_REPOSITORY)
DEFAULT_PREFIX, DEFAULT_REPOSITORY = if Hardware::CPU.arm?
[HOMEBREW_MACOS_ARM_DEFAULT_PREFIX, HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY]
elsif Homebrew::SimulateSystem.simulating_or_running_on_linux?
[HOMEBREW_LINUX_DEFAULT_PREFIX, HOMEBREW_LINUX_DEFAULT_REPOSITORY]
end
end
end