forked from sjackman/linuxbrew-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.rb
167 lines (146 loc) · 5.23 KB
/
root.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
class Root < Formula
desc "Object oriented framework for large scale data analysis"
homepage "https://root.cern.ch/"
url "https://root.cern.ch/download/root_v6.22.00.source.tar.gz"
version "6.22.00"
sha256 "efd961211c0f9cd76cf4a486e4f89badbcf1d08e7535bba556862b3c1a80beed"
head "https://github.com/root-project/root.git"
bottle do
sha256 "89875687bce5d216d8e76104702150031d7b71339513966e359f2961cd18721a" => :catalina
sha256 "2774ff7cdba2727959afb169c22e9a55bd42640a31c5ebf222a3a25d8f47a6d9" => :mojave
sha256 "b34628d0657c3378870cedc065f72d9243249ec68c581ccae9eed7560adab795" => :high_sierra
end
if OS.mac?
# https://github.com/Homebrew/homebrew-core/issues/30726
# strings libCling.so | grep Xcode:
# /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
# /Applications/Xcode.app/Contents/Developer
pour_bottle? do
reason "The bottle hardcodes locations inside Xcode.app"
satisfy do
MacOS::Xcode.installed? &&
MacOS::Xcode.prefix.to_s.include?("/Applications/Xcode.app/")
end
end
end
depends_on "cmake" => :build
depends_on "cfitsio"
depends_on "davix"
depends_on "fftw"
depends_on "gcc" # for gfortran
depends_on "gl2ps"
depends_on "graphviz"
depends_on "gsl"
# Temporarily depend on Homebrew libxml2 to work around a brew issue:
# https://github.com/Homebrew/brew/issues/5068
depends_on "libxml2" if MacOS.version >= :mojave
depends_on "lz4"
depends_on "numpy" # for tmva
depends_on "openssl@1.1"
depends_on "pcre"
depends_on "python@3.8"
depends_on "tbb"
depends_on "xrootd"
depends_on "xz" # for LZMA
depends_on "zstd"
unless OS.mac?
depends_on "linuxbrew/xorg/libx11"
depends_on "linuxbrew/xorg/libxext"
depends_on "linuxbrew/xorg/libxft"
depends_on "linuxbrew/xorg/libxpm"
end
skip_clean "bin"
allow_missing_libs
def install
# Work around "error: no member named 'signbit' in the global namespace"
ENV.delete("SDKROOT") if DevelopmentTools.clang_build_version >= 900
# Freetype/afterimage/gl2ps/lz4 are vendored in the tarball, so are fine.
# However, this is still permitting the build process to make remote
# connections. As a hack, since upstream support it, we inreplace
# this file to "encourage" the connection over HTTPS rather than HTTP.
inreplace "cmake/modules/SearchInstalledSoftware.cmake",
"http://lcgpackages",
"https://lcgpackages"
args = std_cmake_args + %W[
-DCMAKE_INSTALL_ELISPDIR=#{elisp}
-DPYTHON_EXECUTABLE=#{Formula["python@3.8"].opt_bin}/python3
-Dbuiltin_cfitsio=OFF
-Dbuiltin_freetype=ON
-Dbuiltin_glew=ON
-Ddavix=ON
-Dfftw3=ON
-Dfitsio=ON
-Dfortran=ON
-Dgdml=ON
-Dgnuinstall=ON
-Dimt=ON
-Dmathmore=ON
-Dminuit2=ON
-Dmysql=OFF
-Dpgsql=OFF
-Dpyroot=ON
-Droofit=ON
-Dssl=ON
-Dtmva=ON
-Dxrootd=ON
]
args << "-DCLING_CXX_PATH=clang++" if OS.mac?
cxx_version = (MacOS.version < :mojave) ? 14 : 17
args << "-DCMAKE_CXX_STANDARD=#{cxx_version}"
# Workaround the shim directory being embedded into the output
inreplace "build/unix/compiledata.sh", "`type -path $CXX`", ENV.cxx
mkdir "builddir" do
system "cmake", "..", *args
system "make", "install"
chmod 0755, Dir[bin/"*.*sh"]
version = Language::Python.major_minor_version Formula["python@3.8"].opt_bin/"python3"
pth_contents = "import site; site.addsitedir('#{lib}/root')\n"
(prefix/"lib/python#{version}/site-packages/homebrew-root.pth").write pth_contents
end
end
def caveats
<<~EOS
As of ROOT 6.22, you should not need the thisroot scripts; but if you
depend on the custom variables set by them, you can still run them:
For bash users:
. #{HOMEBREW_PREFIX}/bin/thisroot.sh
For zsh users:
pushd #{HOMEBREW_PREFIX} >/dev/null; . bin/thisroot.sh; popd >/dev/null
For csh/tcsh users:
source #{HOMEBREW_PREFIX}/bin/thisroot.csh
For fish users:
. #{HOMEBREW_PREFIX}/bin/thisroot.fish
EOS
end
test do
(testpath/"test.C").write <<~EOS
#include <iostream>
void test() {
std::cout << "Hello, world!" << std::endl;
}
EOS
# Test ROOT command line mode
ENV.prepend_path "LD_LIBRARY_PATH", lib/"root" unless OS.mac?
system "#{bin}/root", "-b", "-l", "-q", "-e", "gSystem->LoadAllLibraries(); 0"
# Test ROOT executable
assert_equal "\nProcessing test.C...\nHello, world!\n",
shell_output("root -l -b -n -q test.C")
# Test linking
(testpath/"test.cpp").write <<~EOS
#include <iostream>
#include <TString.h>
int main() {
std::cout << TString("Hello, world!") << std::endl;
return 0;
}
EOS
(testpath/"test_compile.bash").write <<~EOS
$(root-config --cxx) $(root-config --cflags) $(root-config --libs) $(root-config --ldflags) test.cpp
./a.out
EOS
assert_equal "Hello, world!\n",
shell_output("/bin/bash test_compile.bash")
# Test Python module
system Formula["python@3.8"].opt_bin/"python3", "-c", "import ROOT; ROOT.gSystem.LoadAllLibraries()"
end
end