cc shim path sanitization workaround

Homebrew's `cc` shim removes all `/usr/local` paths for non-`/usr/local`
Homebrew installations (e.g. Apple Silicon Homebrew). This adds a
`setup_fuse` method that copies FUSE files into a temp hierarchy for
use during builds. (Symlinking the files doesn't work because the
shim canonicalizes all paths.)

Also add `ntfs-3g-mac` as a test case.
This commit is contained in:
Adrian Ho 2021-06-30 23:31:40 +08:00
parent eb3fb874c1
commit cff1a61202
2 changed files with 23 additions and 7 deletions

View file

@ -37,6 +37,7 @@ class Ntfs3gMac < Formula
depends_on :macos depends_on :macos
def install def install
setup_fuse
ENV.append "LDFLAGS", "-lintl" ENV.append "LDFLAGS", "-lintl"
args = %W[ args = %W[

View file

@ -11,17 +11,32 @@ class MacfuseRequirement < Requirement
end end
env do env do
:std if Hardware::CPU.arm?
ENV.append_path "PKG_CONFIG_PATH", HOMEBREW_LIBRARY/"Homebrew/os/mac/pkgconfig/fuse" ENV.append_path "PKG_CONFIG_PATH", HOMEBREW_LIBRARY/"Homebrew/os/mac/pkgconfig/fuse"
unless HOMEBREW_PREFIX.to_s == "/usr/local"
ENV.append_path "HOMEBREW_LIBRARY_PATHS", "/usr/local/lib"
ENV.append_path "HOMEBREW_INCLUDE_PATHS", "/usr/local/include"
end
end end
def message def message
"This formula requires MacFUSE. Please run `brew install --cask macfuse` first." "This formula requires MacFUSE. Please run `brew install --cask macfuse` first."
end end
end end
class Formula
def setup_fuse
unless HOMEBREW_PREFIX.to_s == "/usr/local"
odebug "Setting up FUSE temp environment under #{buildpath}/temp"
mkdir buildpath/"temp/include" do
Dir["/usr/local/include/fuse*"].each { |f| cp_r f, "." }
end
mkdir buildpath/"temp/lib" do
Dir["/usr/local/lib/*fuse*"].each { |f| cp_r f, "." }
end
Dir.glob(buildpath/"temp/**/*.*").each { |f| odebug ">>> #{f}" }
ENV.append "CFLAGS", "-I#{buildpath}/temp/include"
ENV.append "CFLAGS", "-I#{buildpath}/temp/include/fuse"
ENV.append "CPPFLAGS", "-I#{buildpath}/temp/include"
ENV.append "CPPFLAGS", "-I#{buildpath}/temp/include/fuse"
ENV.append "LDFLAGS", "-I#{buildpath}/temp/lib"
end
end
end