-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathroot.rb
169 lines (147 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
168
169
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.26.06.source.tar.gz"
sha256 "b1f73c976a580a5c56c8c8a0152582a1dfc560b4dd80e1b7545237b65e6c89cb"
license "LGPL-2.1-or-later"
revision 2
head "https://github.com/root-project/root.git", branch: "master"
livecheck do
url "https://root.cern/install/all_releases/"
regex(%r{Release\s+v?(\d+(?:[./]\d*[02468])+)[ >]}i)
strategy :page_match do |page, regex|
page.scan(regex).map { |match| match[0].tr("/", ".") }
end
end
bottle do
sha256 arm64_ventura: "518327e8d51327dd15e831e2c62295b7e097631a1784458ab24556330107a09b"
sha256 arm64_monterey: "45877591c1f918118d22af0a64f8eed6e2ea5e72065e83880f456b6a1d659a90"
sha256 arm64_big_sur: "da66a37c80908ebc07f42711389826594c863e63e7dc6f2a84b22bc2b4648864"
sha256 ventura: "3339efad3893620bcea994f98118ac9ee38ef891471dc974df772a46e88c25af"
sha256 monterey: "04a4970b5c8343e92141c20a9bbb613e5925d4d9b6c67d764030aac2d958c610"
sha256 big_sur: "2e2fb3dc681cdae836443ec3eeeb671e03c3bec8cc17372339598a71e7a8f959"
sha256 x86_64_linux: "4eeebd8873194ba310f5b388b767ec682e5369ef52a9e655abed65ba2747240b"
end
depends_on "cmake" => :build
depends_on "ninja" => :build
depends_on "cfitsio"
depends_on "davix"
depends_on "fftw"
depends_on "freetype"
depends_on "gcc" # for gfortran
depends_on "gl2ps"
depends_on "glew"
depends_on "graphviz"
depends_on "gsl"
depends_on "lz4"
depends_on "mysql-client"
depends_on "numpy" # for tmva
depends_on "openblas"
depends_on "openssl@1.1"
depends_on "pcre"
depends_on "python@3.10"
depends_on "sqlite"
depends_on "tbb"
depends_on :xcode
depends_on "xrootd"
depends_on "xz" # for LZMA
depends_on "zstd"
uses_from_macos "libxcrypt"
uses_from_macos "libxml2"
uses_from_macos "zlib"
on_linux do
depends_on "libxft"
depends_on "libxpm"
end
skip_clean "bin"
fails_with gcc: "5"
def install
python = Formula["python@3.10"].opt_bin/"python3.10"
ENV.append "LDFLAGS", "-Wl,-rpath,#{lib}/root"
inreplace "cmake/modules/SearchInstalledSoftware.cmake" do |s|
# Enforce secure downloads of vendored dependencies. These are
# checksummed in the cmake file with sha256.
s.gsub! "http://lcgpackages", "https://lcgpackages"
# Patch out check that skips using brewed glew.
s.gsub! "CMAKE_VERSION VERSION_GREATER 3.15", "CMAKE_VERSION VERSION_GREATER 99.99"
end
args = std_cmake_args + %W[
-DCLING_CXX_PATH=clang++
-DCMAKE_INSTALL_ELISPDIR=#{elisp}
-DPYTHON_EXECUTABLE=#{python}
-DCMAKE_CXX_STANDARD=17
-Dbuiltin_cfitsio=OFF
-Dbuiltin_freetype=ON
-Dbuiltin_glew=OFF
-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=OFF
-Dxrootd=ON
-GNinja
]
# Workaround the shim directory being embedded into the output
inreplace "build/unix/compiledata.sh", "`type -path $CXX`", ENV.cxx
# Homebrew now sets CMAKE_INSTALL_LIBDIR to /lib, which is incorrect
# for ROOT with gnuinstall, so we set it back here.
system "cmake", "-S", ".", "-B", "builddir", *args, *std_cmake_args(install_libdir: "lib/root")
system "cmake", "--build", "builddir"
system "cmake", "--install", "builddir"
chmod 0755, bin.glob("*.*sh")
pth_contents = "import site; site.addsitedir('#{lib}/root')\n"
(prefix/Language::Python.site_packages(python)/"homebrew-root.pth").write pth_contents
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
system bin/"root", "-b", "-l", "-q", "-e", "gSystem->LoadAllLibraries(); 0"
# Test ROOT executable
assert_equal "\nProcessing test.C...\nHello, world!\n",
shell_output("#{bin}/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
flags = %w[cflags libs ldflags].map { |f| "$(#{bin}/root-config --#{f})" }
flags << "-Wl,-rpath,#{lib}/root"
shell_output("$(#{bin}/root-config --cxx) test.cpp #{flags.join(" ")}")
assert_equal "Hello, world!\n", shell_output("./a.out")
# Test Python module
system Formula["python@3.10"].opt_bin/"python3.10", "-c", "import ROOT; ROOT.gSystem.LoadAllLibraries()"
end
end