Skip to content

Commit

Permalink
Add commented out deprecations for MacOS when simulating Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Rylan12 committed Nov 23, 2023
1 parent 4efd7cd commit b7532a8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Library/Homebrew/os/mac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
require "os/mac/sdk"
require "os/mac/keg"

# TODO: remove this once the `MacOS` module is undefined on Linux
require "simulate_system"

module OS
# Helper module for querying system information on macOS.
module Mac
Expand All @@ -21,13 +24,15 @@ module Mac
# using the standard Ruby Comparable methods.
sig { returns(MacOSVersion) }
def self.version
# odeprecated "`MacOS.version` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
@version ||= full_version.strip_patch
end

# This can be compared to numerics, strings, or symbols
# using the standard Ruby Comparable methods.
sig { returns(MacOSVersion) }
def self.full_version
# odeprecated "`MacOS.full_version` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
@full_version ||= if ENV["HOMEBREW_FAKE_EL_CAPITAN"] # for Portable Ruby building
MacOSVersion.new("10.11.6")
else
Expand Down Expand Up @@ -60,6 +65,7 @@ def self.preferred_perl_version
end

def self.languages
# odeprecated "`MacOS.languages` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
return @languages if @languages

os_langs = Utils.popen_read("defaults", "read", "-g", "AppleLanguages")
Expand All @@ -73,6 +79,7 @@ def self.languages
end

def self.language
# odeprecated "`MacOS.language` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
languages.first
end

Expand All @@ -83,6 +90,7 @@ def self.active_developer_dir

sig { returns(T::Boolean) }
def self.sdk_root_needed?
# odeprecated "`MacOS.sdk_root_needed?` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
if MacOS::CLT.installed?
# If there's no CLT SDK, return false
return false unless MacOS::CLT.provides_sdk?
Expand Down Expand Up @@ -131,11 +139,13 @@ def self.sdk_for_formula(formula, version = nil, check_only_runtime_requirements

# Returns the path to an SDK or nil, following the rules set by {sdk}.
def self.sdk_path(version = nil)
# odeprecated "`MacOS.sdk_path` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
s = sdk(version)
s&.path
end

def self.sdk_path_if_needed(version = nil)
# odeprecated "`MacOS.sdk_path_if_needed` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
# Prefer CLT SDK when both Xcode and the CLT are installed.
# Expected results:
# 1. On Xcode-only systems, return the Xcode SDK.
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/os/mac/xcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def self.bundle_path

sig { returns(T::Boolean) }
def self.installed?
# odeprecated "`MacOS::Xcode.installed?` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
!prefix.nil?
end

Expand Down Expand Up @@ -174,6 +175,7 @@ def self.update_instructions

sig { returns(::Version) }
def self.version
# odeprecated "`MacOS::Xcode.version` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
# may return a version string
# that is guessed based on the compiler, so do not
# use it in order to check if Xcode is installed.
Expand Down Expand Up @@ -264,6 +266,7 @@ module CLT
# Returns true even if outdated tools are installed.
sig { returns(T::Boolean) }
def self.installed?
# odeprecated "`MacOS::CLT.installed?` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
!version.null?
end

Expand Down Expand Up @@ -397,6 +400,7 @@ def self.detect_version_from_clang_version
# version numbers.
sig { returns(::Version) }
def self.version
# odeprecated "`MacOS::CLT.version` on Linux" if Homebrew::SimulateSystem.simulating_or_running_on_linux?
if @version ||= detect_version
::Version.new @version
else
Expand Down
8 changes: 7 additions & 1 deletion Library/Homebrew/readall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module Readall
class << self
include Cachable

# TODO: remove this once the `MacOS` module is undefined on Linux
MACOS_MODULE_REGEX = /\b(MacOS|OS::Mac)(\.|::)\b/.freeze
private_constant :MACOS_MODULE_REGEX

private :cache

def valid_ruby_syntax?(ruby_files)
Expand Down Expand Up @@ -59,7 +63,9 @@ def valid_formulae?(tap, bottle_tag: nil)
flags: [], ignore_errors: false)
readall_formula = readall_formula_class.new(formula_name, file, :stable, tap: tap)
readall_formula.to_hash
cache[:valid_formulae][file] = if readall_formula.on_system_blocks_exist?
# TODO: Remove check for MACOS_MODULE_REGEX once the `MacOS` module is undefined on Linux
cache[:valid_formulae][file] = if readall_formula.on_system_blocks_exist? ||
formula_contents.match?(MACOS_MODULE_REGEX)
[bottle_tag, *cache[:valid_formulae][file]]
else
true
Expand Down

0 comments on commit b7532a8

Please sign in to comment.