Remove MacOS definition from generic OS

We don't want to define `MacOS` in the generic OS, so let's make sure we
refer to it as `OS::Mac` in the places we need it.

This reverts commit 575cb0263cb1428c63b9428bbd913ffde83bd317.
This commit is contained in:
Carlo Cabrera 2023-04-04 23:10:51 +08:00
parent 575cb0263c
commit a4ebb96fe6
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
7 changed files with 14 additions and 19 deletions

View File

@ -46,7 +46,7 @@ class TestRunnerFormula
formula.requirements.find { |r| r.is_a?(MacOSRequirement) && r.version_specified? }
end
sig { params(macos_version: MacOS::Version).returns(T::Boolean) }
sig { params(macos_version: OS::Mac::Version).returns(T::Boolean) }
def compatible_with?(macos_version)
# Assign to a variable to assist type-checking.
requirement = versioned_macos_requirement
@ -93,7 +93,7 @@ module Homebrew
testing_formulae: T::Array[TestRunnerFormula],
reject_platform: T.nilable(Symbol),
reject_arch: T.nilable(Symbol),
select_macos_version: T.nilable(MacOS::Version),
select_macos_version: T.nilable(OS::Mac::Version),
).returns(T::Boolean)
}
def self.formulae_have_untested_dependents?(testing_formulae, reject_platform:, reject_arch:, select_macos_version:)
@ -123,7 +123,7 @@ module Homebrew
deleted_formulae: T.nilable(T::Array[String]),
reject_platform: T.nilable(Symbol),
reject_arch: T.nilable(Symbol),
select_macos_version: T.nilable(MacOS::Version),
select_macos_version: T.nilable(OS::Mac::Version),
).returns(T::Boolean)
}
def self.add_runner?(formulae,
@ -200,7 +200,7 @@ module Homebrew
ephemeral_suffix = "-#{github_run_id}-#{github_run_attempt}"
MacOSVersions::SYMBOLS.each do |symbol, version|
macos_version = MacOS::Version.new(version)
macos_version = OS::Mac::Version.new(version)
next if macos_version.outdated_release? || macos_version.prerelease?
if args.dependents?

View File

@ -28,13 +28,13 @@ module OnSystem
return false if Homebrew::SimulateSystem.simulating_or_running_on_linux?
base_os = MacOS::Version.from_symbol(os_name)
base_os = OS::Mac::Version.from_symbol(os_name)
current_os = if Homebrew::SimulateSystem.current_os == :macos
# Assume the oldest macOS version when simulating a generic macOS version
# Version::NULL is always treated as less than any other version.
Version::NULL
else
MacOS::Version.from_symbol(Homebrew::SimulateSystem.current_os)
OS::Mac::Version.from_symbol(Homebrew::SimulateSystem.current_os)
end
return current_os >= base_os if or_condition == :or_newer

View File

@ -55,7 +55,6 @@ module OS
LINUX_PREFERRED_GCC_COMPILER_FORMULA = "gcc@11" # https://packages.ubuntu.com/jammy/gcc
LINUX_PREFERRED_GCC_RUNTIME_FORMULA = "gcc"
require "os/generic"
if OS.mac?
require "os/mac"
# Don't tell people to report issues on unsupported configurations.

View File

@ -1,8 +0,0 @@
# typed: strict
# frozen_string_literal: true
module OS
module Mac
::MacOS = OS::Mac
end
end

View File

@ -54,6 +54,8 @@ module OS
module Mac
module_function
::MacOS = OS::Mac
raise "Loaded OS::Linux on generic OS!" if ENV["HOMEBREW_TEST_GENERIC_OS"]
def version

View File

@ -13,6 +13,8 @@ module OS
module_function
::MacOS = OS::Mac
raise "Loaded OS::Mac on generic OS!" if ENV["HOMEBREW_TEST_GENERIC_OS"]
VERSION = ENV.fetch("HOMEBREW_MACOS_VERSION").chomp.freeze

View File

@ -23,9 +23,9 @@ class MacOSRequirement < Requirement
def initialize(tags = [], comparator: ">=")
@version = begin
if comparator == "==" && tags.first.respond_to?(:map)
tags.first.map { |s| MacOS::Version.from_symbol(s) }
tags.first.map { |s| OS::Mac::Version.from_symbol(s) }
else
MacOS::Version.from_symbol(tags.first) unless tags.empty?
OS::Mac::Version.from_symbol(tags.first) unless tags.empty?
end
rescue MacOSVersionError => e
if DISABLED_MACOS_VERSIONS.include?(e.version)
@ -43,7 +43,7 @@ class MacOSRequirement < Requirement
end
# Otherwise fallback to the oldest allowed if comparator is >=.
MacOS::Version.new(HOMEBREW_MACOS_OLDEST_ALLOWED) if comparator == ">="
OS::Mac::Version.new(HOMEBREW_MACOS_OLDEST_ALLOWED) if comparator == ">="
end
@comparator = comparator
@ -56,7 +56,7 @@ class MacOSRequirement < Requirement
satisfy(build_env: false) do
T.bind(self, MacOSRequirement)
next Array(@version).any? { |v| MacOS.version.public_send(@comparator, v) } if OS.mac? && version_specified?
next Array(@version).any? { |v| OS::Mac.version.public_send(@comparator, v) } if OS.mac? && version_specified?
next true if OS.mac?
next true if @version