Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate OS::Mac on Linux #16224

Merged
merged 6 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Library/Homebrew/cmd/gist-logs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ def gistify_logs(formula, args:)
EOS
end

if args.new_issue?
url = GitHub.create_issue(formula.tap, "#{formula.name} failed to build on #{MacOS.full_version}", url)
end
url = GitHub.create_issue(formula.tap, "#{formula.name} failed to build on #{OS_VERSION}", url) if args.new_issue?

puts url if url
end
Expand Down
6 changes: 5 additions & 1 deletion Library/Homebrew/extend/os/linkage_checker.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# typed: strict
# frozen_string_literal: true

require "extend/os/linux/linkage_checker" if OS.linux?
if OS.mac?
require "extend/os/mac/linkage_checker"
else
require "extend/os/linux/linkage_checker"
end
22 changes: 22 additions & 0 deletions Library/Homebrew/extend/os/mac/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,31 @@

class Formula
undef valid_platform?
undef std_cmake_args

sig { returns(T::Boolean) }
def valid_platform?
requirements.none?(LinuxRequirement)
end

sig {
params(

Check warning on line 14 in Library/Homebrew/extend/os/mac/formula.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/mac/formula.rb#L14

Added line #L14 was not covered by tests
install_prefix: T.any(String, Pathname),
install_libdir: T.any(String, Pathname),
find_framework: String,
).returns(T::Array[String])
}
def std_cmake_args(install_prefix: prefix, install_libdir: "lib", find_framework: "LAST")
args = generic_std_cmake_args(install_prefix: install_prefix, install_libdir: install_libdir,

Check warning on line 21 in Library/Homebrew/extend/os/mac/formula.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/mac/formula.rb#L21

Added line #L21 was not covered by tests
find_framework: find_framework)

# Avoid false positives for clock_gettime support on 10.11.
# CMake cache entries for other weak symbols may be added here as needed.
args << "-DHAVE_CLOCK_GETTIME:INTERNAL=0" if MacOS.version == "10.11" && MacOS::Xcode.version >= "8.0"

# Ensure CMake is using the same SDK we are using.
args << "-DCMAKE_OSX_SYSROOT=#{MacOS.sdk_for_formula(self).path}" if MacOS.sdk_root_needed?

args

Check warning on line 31 in Library/Homebrew/extend/os/mac/formula.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/mac/formula.rb#L31

Added line #L31 was not covered by tests
end
end
13 changes: 13 additions & 0 deletions Library/Homebrew/extend/os/mac/linkage_checker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# typed: true
# frozen_string_literal: true

class LinkageChecker
undef system_libraries_exist_in_cache?

private

def system_libraries_exist_in_cache?
# In macOS Big Sur and later, system libraries do not exist on-disk and instead exist in a cache.
MacOS.version >= :big_sur
end
end
15 changes: 15 additions & 0 deletions Library/Homebrew/extend/os/mac/utils/curl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# typed: true
# frozen_string_literal: true

module Utils
module Curl
undef return_value_for_empty_http_status_code

def return_value_for_empty_http_status_code(url_type, url)
# Hack around https://github.com/Homebrew/brew/issues/3199
return if MacOS.version == :el_capitan

generic_return_value_for_empty_http_status_code url_type, url

Check warning on line 12 in Library/Homebrew/extend/os/mac/utils/curl.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/mac/utils/curl.rb#L12

Added line #L12 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
4 changes: 4 additions & 0 deletions Library/Homebrew/extend/os/utils/curl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# typed: strict
# frozen_string_literal: true

require "extend/os/mac/utils/curl" if OS.mac?
12 changes: 2 additions & 10 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ def std_cargo_args(root: prefix, path: ".")
).returns(T::Array[String])
}
def std_cmake_args(install_prefix: prefix, install_libdir: "lib", find_framework: "LAST")
args = %W[
%W[
-DCMAKE_INSTALL_PREFIX=#{install_prefix}
-DCMAKE_INSTALL_LIBDIR=#{install_libdir}
-DCMAKE_BUILD_TYPE=Release
Expand All @@ -1655,16 +1655,8 @@ def std_cmake_args(install_prefix: prefix, install_libdir: "lib", find_framework
-Wno-dev
-DBUILD_TESTING=OFF
]

# Avoid false positives for clock_gettime support on 10.11.
# CMake cache entries for other weak symbols may be added here as needed.
args << "-DHAVE_CLOCK_GETTIME:INTERNAL=0" if MacOS.version == "10.11" && MacOS::Xcode.version >= "8.0"

# Ensure CMake is using the same SDK we are using.
args << "-DCMAKE_OSX_SYSROOT=#{MacOS.sdk_for_formula(self).path}" if MacOS.sdk_root_needed?

args
end
alias generic_std_cmake_args std_cmake_args

# Standard parameters for Go builds.
sig {
Expand Down
8 changes: 6 additions & 2 deletions Library/Homebrew/linkage_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@

if (dep = dylib_to_dep(dylib))
@broken_deps[dep] |= [dylib]
elsif MacOS.version >= :big_sur && dylib_found_via_dlopen(dylib)
elsif system_libraries_exist_in_cache? && dylib_found_via_dlopen(dylib)
# If we cannot associate the dylib with a dependency, then it may be a system library.
# In macOS Big Sur and later, system libraries do not exist on-disk and instead exist in a cache.
# If dlopen finds the dylib, then the linkage is not broken.
@system_dylibs << dylib
elsif !system_framework?(dylib)
Expand Down Expand Up @@ -227,6 +226,11 @@
end
alias generic_check_dylibs check_dylibs

def system_libraries_exist_in_cache?
false

Check warning on line 230 in Library/Homebrew/linkage_checker.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/linkage_checker.rb#L230

Added line #L230 was not covered by tests
end
alias generic_system_libraries_exist_in_cache? system_libraries_exist_in_cache?

def dylib_found_via_dlopen(dylib)
Fiddle.dlopen(dylib).close
true
Expand Down
11 changes: 11 additions & 0 deletions Library/Homebrew/os/linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,49 +55,60 @@
raise "Loaded OS::Linux on generic OS!" if ENV["HOMEBREW_TEST_GENERIC_OS"]

def self.version
odeprecated "`MacOS.version` on Linux"

Check warning on line 58 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L58

Added line #L58 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
MacOSVersion::NULL
end

def self.full_version
odeprecated "`MacOS.full_version` on Linux"

Check warning on line 63 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L63

Added line #L63 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
MacOSVersion::NULL
end

def self.languages
odeprecated "`MacOS.languages` on Linux"

Check warning on line 68 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L68

Added line #L68 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
@languages ||= Array(ENV["LANG"]&.slice(/[a-z]+/)).uniq
end

def self.language
odeprecated "`MacOS.language` on Linux"

Check warning on line 73 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L73

Added line #L73 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
languages.first
end

def self.sdk_root_needed?
odeprecated "`MacOS.sdk_root_needed?` on Linux"

Check warning on line 78 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L78

Added line #L78 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
false
end

def self.sdk_path_if_needed(_version = nil)
odeprecated "`MacOS.sdk_path_if_needed` on Linux"

Check warning on line 83 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L83

Added line #L83 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
nil
end

def self.sdk_path(_version = nil)
odeprecated "`MacOS.sdk_path` on Linux"

Check warning on line 88 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L88

Added line #L88 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
nil
end

module Xcode
def self.version
odeprecated "`MacOS::Xcode.version` on Linux"

Check warning on line 94 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L94

Added line #L94 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
::Version::NULL
end

def self.installed?
odeprecated "`MacOS::Xcode.installed?` on Linux"

Check warning on line 99 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L99

Added line #L99 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
false
end
end

module CLT
def self.version
odeprecated "`MacOS::CLT.version` on Linux"

Check warning on line 106 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L106

Added line #L106 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
::Version::NULL
end

def self.installed?
odeprecated "`MacOS::CLT.installed?` on Linux"

Check warning on line 111 in Library/Homebrew/os/linux.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/linux.rb#L111

Added line #L111 was not covered by tests
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
false
end
end
Expand Down
14 changes: 8 additions & 6 deletions Library/Homebrew/utils/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,7 @@
break if http_status_ok?(details[:status_code])
end

unless details[:status_code]
# Hack around https://github.com/Homebrew/brew/issues/3199
return if MacOS.version == :el_capitan

return "The #{url_type} #{url} is not reachable"
end
return return_value_for_empty_http_status_code(url_type, url) unless details[:status_code]

unless http_status_ok?(details[:status_code])
return if details[:responses].any? do |response|
Expand Down Expand Up @@ -486,6 +481,11 @@
(100..299).cover?(status.to_i)
end

def return_value_for_empty_http_status_code(url_type, url)
"The #{url_type} #{url} is not reachable"

Check warning on line 485 in Library/Homebrew/utils/curl.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/curl.rb#L485

Added line #L485 was not covered by tests
end
alias generic_return_value_for_empty_http_status_code return_value_for_empty_http_status_code

# Separates the output text from `curl` into an array of HTTP responses and
# the final response body (i.e. content). Response hashes contain the
# `:status_code`, `:status_text`, and `:headers`.
Expand Down Expand Up @@ -619,3 +619,5 @@
end
end
end

require "extend/os/utils/curl"
Loading