mirror of
https://github.com/gromgit/homebrew-fuse.git
synced 2025-12-31 15:02:17 +00:00
103 lines
2.9 KiB
Ruby
103 lines
2.9 KiB
Ruby
# typed: false
|
|
# frozen_string_literal: true
|
|
|
|
# USAGE: `depends_on MacfuseRequirement`
|
|
class MacfuseRequirement < Requirement
|
|
fatal true
|
|
|
|
satisfy(build_env: false) { self.class.binary_osxfuse_installed? }
|
|
|
|
def self.binary_osxfuse_installed?
|
|
File.exist?("/usr/local/include/fuse.h") &&
|
|
!File.symlink?("/usr/local/include")
|
|
end
|
|
|
|
env do
|
|
ENV.append_path "PKG_CONFIG_PATH", HOMEBREW_LIBRARY/"Homebrew/os/mac/pkgconfig/fuse"
|
|
end
|
|
|
|
def message
|
|
"This formula requires MacFUSE. Please run `brew install --cask macfuse` first."
|
|
end
|
|
end
|
|
|
|
# Add `setup_fuse` to base Formula class, for use by FUSE formulae
|
|
class Formula
|
|
def need_alt_fuse?
|
|
HOMEBREW_PREFIX.to_s != "/usr/local"
|
|
end
|
|
|
|
def alt_fuse_root
|
|
buildpath/"temp"
|
|
end
|
|
|
|
def fuse_cmake_args
|
|
return unless need_alt_fuse?
|
|
|
|
%W[
|
|
-DCMAKE_INCLUDE_PATH=#{alt_fuse_root}/include/fuse;#{alt_fuse_root}/include
|
|
-DCMAKE_LIBRARY_PATH=#{alt_fuse_root}/lib
|
|
-DCMAKE_CXX_FLAGS=-I#{alt_fuse_root}/include/fuse\ -D_USE_FILE_OFFSET_BITS=64
|
|
-DPKG_CONFIG=#{fuse_pkgconfig}
|
|
-DPKG_CONFIG_EXECUTABLE=#{fuse_pkgconfig}
|
|
]
|
|
# -DFUSE_INCLUDE_DIR=#{alt_fuse_root}/include/fuse
|
|
# -DFUSE_LIBRARIES=#{alt_fuse_root}/lib/libfuse.dylib
|
|
end
|
|
|
|
def setup_fuse_includes
|
|
mkdir "#{alt_fuse_root}/include" do
|
|
Dir["/usr/local/include/fuse*"].each { |f| cp_r f, "." }
|
|
end
|
|
end
|
|
|
|
def setup_fuse_libs
|
|
mkdir "#{alt_fuse_root}/lib" do
|
|
Dir["/usr/local/lib/*fuse*"].each { |f| cp_r f, "." }
|
|
end
|
|
end
|
|
|
|
def setup_fuse_pkgconfig
|
|
mkdir "#{alt_fuse_root}/bin" do
|
|
cp path/"../../lib/fuse-pkg-config", "."
|
|
inreplace "fuse-pkg-config", "%FUSE_ROOT%", "#{alt_fuse_root}"
|
|
end
|
|
end
|
|
|
|
def fuse_pkgconfig
|
|
return "#{alt_fuse_root}/bin/fuse-pkg-config" if need_alt_fuse?
|
|
"pkg-config"
|
|
end
|
|
|
|
def setup_fuse_env
|
|
odebug "Setting up FUSE temp environment under #{alt_fuse_root}"
|
|
setup_fuse_includes
|
|
setup_fuse_libs
|
|
setup_fuse_pkgconfig
|
|
Dir.glob("#{alt_fuse_root}/**/*").each { |f| odebug ">>> #{f}" }
|
|
end
|
|
|
|
def setup_fuse_flags
|
|
ENV.append "CFLAGS", "-I#{alt_fuse_root}/include"
|
|
ENV.append "CFLAGS", "-I#{alt_fuse_root}/include/fuse"
|
|
ENV.append "CFLAGS", "-D_USE_FILE_OFFSET_BITS=64"
|
|
ENV.append "CPPFLAGS", "-I#{alt_fuse_root}/include"
|
|
ENV.append "CPPFLAGS", "-I#{alt_fuse_root}/include/fuse"
|
|
ENV.append "CPPFLAGS", "-D_USE_FILE_OFFSET_BITS=64"
|
|
ENV.append "CXXFLAGS", "-I#{alt_fuse_root}/include"
|
|
ENV.append "CXXFLAGS", "-I#{alt_fuse_root}/include/fuse"
|
|
ENV.append "CXXFLAGS", "-D_USE_FILE_OFFSET_BITS=64"
|
|
ENV.append "LDFLAGS", "-L#{alt_fuse_root}/lib"
|
|
ENV.append "CGO_CPPFLAGS", "-I#{alt_fuse_root}/include"
|
|
ENV.append "CGO_CPPFLAGS", "-D_USE_FILE_OFFSET_BITS=64"
|
|
ENV.append "CGO_LDFLAGS", "-L#{alt_fuse_root}/lib"
|
|
ENV.append "PKG_CONFIG", "#{fuse_pkgconfig}"
|
|
end
|
|
|
|
def setup_fuse
|
|
return unless need_alt_fuse?
|
|
|
|
setup_fuse_env
|
|
setup_fuse_flags
|
|
end
|
|
end
|