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

ENV/std: port superenv SDK changes #7426

Merged
merged 1 commit into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 13 additions & 10 deletions Library/Homebrew/extend/os/mac/extend/ENV/std.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ def setup_build_environment(formula = nil)
self["LC_CTYPE"] = "C"

# Add lib and include etc. from the current macosxsdk to compiler flags:
macosxsdk MacOS.version
macosxsdk(formula: formula)

return unless MacOS::Xcode.without_clt?

append_path "PATH", "#{MacOS::Xcode.prefix}/usr/bin"
append_path "PATH", "#{MacOS::Xcode.toolchain_path}/usr/bin"
end

def remove_macosxsdk(version = MacOS.version)
def remove_macosxsdk(version = nil)
# Clear all lib and include dirs from CFLAGS, CPPFLAGS, LDFLAGS that were
# previously added by macosxsdk
version = version.to_s
remove_from_cflags(/ ?-mmacosx-version-min=10\.\d+/)
delete("CPATH")
remove "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"

return unless (sdk = MacOS.sdk_path_if_needed(version))
sdk = self["SDKROOT"] || MacOS.sdk_path_if_needed(version)
return unless sdk

delete("SDKROOT")
remove_from_cflags "-isysroot#{sdk}"
Expand All @@ -72,15 +72,18 @@ def remove_macosxsdk(version = MacOS.version)
remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
end

def macosxsdk(version = MacOS.version)
def macosxsdk(version = nil, formula: nil)
# Sets all needed lib and include dirs to CFLAGS, CPPFLAGS, LDFLAGS.
remove_macosxsdk
version = version.to_s
append_to_cflags("-mmacosx-version-min=#{version}")
min_version = version || MacOS.version
append_to_cflags("-mmacosx-version-min=#{min_version}")
self["CPATH"] = "#{HOMEBREW_PREFIX}/include"
prepend "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"

return unless (sdk = MacOS.sdk_path_if_needed(version))
sdk = formula ? MacOS.sdk_for_formula(formula, version) : MacOS.sdk(version)
return if !MacOS.sdk_root_needed? && sdk.source != :xcode

sdk = sdk.path

# Extra setup to support Xcode 4.3+ without CLT.
self["SDKROOT"] = sdk
Expand All @@ -99,10 +102,10 @@ def macosxsdk(version = MacOS.version)
# Some configure scripts won't find libxml2 without help
# This is a no-op with macOS SDK 10.15.4 and later
def libxml2
sdk = MacOS.sdk_path_if_needed
sdk = self["SDKROOT"] || MacOS.sdk_path_if_needed
if !sdk
append "CPPFLAGS", "-I/usr/include/libxml2"
elsif !(sdk/"usr/include/libxml").directory?
elsif !Pathname("#{sdk}/usr/include/libxml").directory?
# Use the includes form the sdk
append "CPPFLAGS", "-I#{sdk}/usr/include/libxml2"
end
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io)
error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)

ENV.extend(Stdenv)
ENV.setup_build_environment

trap("INT", old_trap)

formula = Homebrew.args.resolved_formulae.first
formula.extend(Homebrew::Assertions)
formula.extend(Homebrew::FreePort)
formula.extend(Debrew::Formula) if Homebrew.args.debug?

ENV.extend(Stdenv)
ENV.setup_build_environment(formula)

# tests can also return false to indicate failure
Timeout.timeout TEST_TIMEOUT_SECONDS do
raise "test returned false" if formula.run_test == false
Expand Down