Separate MacOS references

This commit is contained in:
Rylan Polster 2023-11-15 19:52:21 +00:00
parent 0839e21425
commit 8704e79cc0
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
9 changed files with 76 additions and 22 deletions

View File

@ -73,9 +73,7 @@ module Homebrew
EOS EOS
end end
if args.new_issue? url = GitHub.create_issue(formula.tap, "#{formula.name} failed to build on #{OS_VERSION}", url) if args.new_issue?
url = GitHub.create_issue(formula.tap, "#{formula.name} failed to build on #{MacOS.full_version}", url)
end
puts url if url puts url if url
end end

View File

@ -1,4 +1,8 @@
# typed: strict # typed: strict
# frozen_string_literal: true # 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

View File

@ -3,9 +3,31 @@
class Formula class Formula
undef valid_platform? undef valid_platform?
undef std_cmake_args
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def valid_platform? def valid_platform?
requirements.none?(LinuxRequirement) requirements.none?(LinuxRequirement)
end end
sig {
params(
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,
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
end
end end

View File

@ -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

View File

@ -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
end
end
end

View File

@ -0,0 +1,4 @@
# typed: strict
# frozen_string_literal: true
require "extend/os/mac/utils/curl" if OS.mac?

View File

@ -1646,7 +1646,7 @@ class Formula
).returns(T::Array[String]) ).returns(T::Array[String])
} }
def std_cmake_args(install_prefix: prefix, install_libdir: "lib", find_framework: "LAST") def std_cmake_args(install_prefix: prefix, install_libdir: "lib", find_framework: "LAST")
args = %W[ %W[
-DCMAKE_INSTALL_PREFIX=#{install_prefix} -DCMAKE_INSTALL_PREFIX=#{install_prefix}
-DCMAKE_INSTALL_LIBDIR=#{install_libdir} -DCMAKE_INSTALL_LIBDIR=#{install_libdir}
-DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Release
@ -1655,16 +1655,8 @@ class Formula
-Wno-dev -Wno-dev
-DBUILD_TESTING=OFF -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 end
alias generic_std_cmake_args std_cmake_args
# Standard parameters for Go builds. # Standard parameters for Go builds.
sig { sig {

View File

@ -196,9 +196,8 @@ class LinkageChecker
if (dep = dylib_to_dep(dylib)) if (dep = dylib_to_dep(dylib))
@broken_deps[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. # 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. # If dlopen finds the dylib, then the linkage is not broken.
@system_dylibs << dylib @system_dylibs << dylib
elsif !system_framework?(dylib) elsif !system_framework?(dylib)
@ -227,6 +226,11 @@ class LinkageChecker
end end
alias generic_check_dylibs check_dylibs alias generic_check_dylibs check_dylibs
def system_libraries_exist_in_cache?
false
end
alias generic_system_libraries_exist_in_cache? system_libraries_exist_in_cache?
def dylib_found_via_dlopen(dylib) def dylib_found_via_dlopen(dylib)
Fiddle.dlopen(dylib).close Fiddle.dlopen(dylib).close
true true

View File

@ -320,12 +320,7 @@ module Utils
break if http_status_ok?(details[:status_code]) break if http_status_ok?(details[:status_code])
end end
unless details[:status_code] return return_value_for_empty_http_status_code(url_type, url) 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
unless http_status_ok?(details[:status_code]) unless http_status_ok?(details[:status_code])
return if details[:responses].any? do |response| return if details[:responses].any? do |response|
@ -486,6 +481,11 @@ module Utils
(100..299).cover?(status.to_i) (100..299).cover?(status.to_i)
end end
def return_value_for_empty_http_status_code(url_type, url)
"The #{url_type} #{url} is not reachable"
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 # Separates the output text from `curl` into an array of HTTP responses and
# the final response body (i.e. content). Response hashes contain the # the final response body (i.e. content). Response hashes contain the
# `:status_code`, `:status_text`, and `:headers`. # `:status_code`, `:status_text`, and `:headers`.
@ -619,3 +619,5 @@ module Utils
end end
end end
end end
require "extend/os/utils/curl"