-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macfuse.rb
118 lines (99 loc) · 3.44 KB
/
macfuse.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# 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
def display_s
"macFUSE"
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
### OLD METHOD: Fake pkg-config
# mkdir "#{alt_fuse_root}/bin" do
# cp path/"../../lib/fuse-pkg-config", "."
# inreplace "fuse-pkg-config", "%FUSE_ROOT%", "#{alt_fuse_root}"
# end
# ENV["PKG_CONFIG"] = "#{fuse_pkgconfig}"
### NEW METHOD: Fix fuse.pc in alt root
mkdir "#{alt_fuse_root}/lib/pkgconfig" do
cp "/usr/local/lib/pkgconfig/fuse.pc", "."
inreplace "fuse.pc", "/usr/local", alt_fuse_root.to_s
end
ENV.prepend_path "PKG_CONFIG_PATH", "#{alt_fuse_root}/lib/pkgconfig"
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"
odebug "PKG_CONFIG = #{ENV.fetch("PKG_CONFIG", nil)}"
odebug "PKG_CONFIG_PATH = #{ENV.fetch("PKG_CONFIG_PATH", nil)}"
odebug "CFLAGS = #{ENV.fetch("CFLAGS", nil)}"
end
def setup_fuse
return unless need_alt_fuse?
setup_fuse_env
setup_fuse_flags
end
end