homebrew-core/Formula/root.rb
Dominyk Tiller 258820d458
root: only conditionally pour bottle
Ref: https://github.com/Homebrew/homebrew-core/issues/30726

And locally with `Xcode-beta.app`:
```
==> /bin/bash test.bash
ERROR in cling::CIFactory::createCI(): cannot extract standard library include paths!
Invoking:
  LC_ALL=C /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++   -O2 -DNDEBUG -xc++ -E -v /dev/null 2>&1 >/dev/null | awk '/^#include </,/^End of search/{if (!/^#include </ && !/^End of search/){ print }}' | GREP_OPTIONS= grep -E "(c|g)\+\+"
Results was:
With exit code 256
input_line_1:1:10: fatal error: 'new' file not found
\#include <new>
         ^~~~~
input_line_3:37:10: fatal error: 'string' file not found
\#include <string>
         ^~~~~~~~
input_line_9:1:10: fatal error: 'iostream' file not found
\#include <iostream>
         ^~~~~~~~~~
In file included from input_line_10:1:
/private/tmp/root-test-20180806-72769-a6spq0/test.C:1:10: fatal error: 'iostream' file not found
\#include <iostream>
         ^~~~~~~~~~
Error: root: failed
<0> expected but was
<1>.
```

Closes #30841.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
2018-08-08 16:10:45 +01:00

168 lines
5.7 KiB
Ruby

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.14.02.source.tar.gz"
version "6.14.02"
sha256 "93816519523e87ac75924178d87112d1573eaa108fc65691aea9a9dd5bc05b3e"
head "http://root.cern.ch/git/root.git"
bottle do
sha256 "735843cdf42536af424d90471cba12e4834f42b728b40b2d170b6dc13dd863c1" => :high_sierra
sha256 "d77502bde56a1b0aa8c2d2f8b249f730c77d92c9d3729cbaf6a721052a6ad669" => :sierra
sha256 "7b3f1c52f9aa32d8e7c47376b1ae74b09e94df9030c10e4bc87d8e556298fdc6" => :el_capitan
end
depends_on "cmake" => :build
depends_on "davix"
depends_on "fftw"
depends_on "gcc" # for gfortran.
depends_on "graphviz"
depends_on "gsl"
depends_on "lz4"
depends_on "openssl"
depends_on "pcre"
depends_on "tbb"
depends_on "xrootd"
depends_on "xz" # For LZMA.
depends_on "python" => :recommended
depends_on "python@2" => :optional
# 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
needs :cxx11
skip_clean "bin"
# Upstream commit from 30 Jun 2018 "Fixes for Python 3.7"
patch do
url "https://github.com/root-project/root/commit/94412f7eab8.patch?full_index=1"
sha256 "29a719b00931381cbe75b0e23c5e970d03aa28a8455a5f840e82a8cae83d9c24"
end
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[
-Dgnuinstall=ON
-DCMAKE_INSTALL_ELISPDIR=#{elisp}
-Dbuiltin_freetype=ON
-Dbuiltin_cfitsio=OFF
-Ddavix=ON
-Dfitsio=OFF
-Dfftw3=ON
-Dfortran=ON
-Dgdml=ON
-Dmathmore=ON
-Dminuit2=ON
-Dmysql=OFF
-Dpgsql=OFF
-Droofit=ON
-Dssl=ON
-Dimt=ON
-Dxrootd=ON
]
if build.with?("python") && build.with?("python@2")
odie "Root: Does not support building both python 2 and 3 wrappers"
elsif build.with?("python") || build.with?("python@2")
if build.with? "python@2"
ENV.prepend_path "PATH", Formula["python@2"].opt_libexec/"bin"
python_executable = Utils.popen_read("which python").strip
python_version = Language::Python.major_minor_version("python")
elsif build.with? "python"
python_executable = Utils.popen_read("which python3").strip
python_version = Language::Python.major_minor_version("python3")
end
python_prefix = Utils.popen_read("#{python_executable} -c 'import sys;print(sys.prefix)'").chomp
python_include = Utils.popen_read("#{python_executable} -c 'from distutils import sysconfig;print(sysconfig.get_python_inc(True))'").chomp
args << "-Dpython=ON"
# cmake picks up the system's python dylib, even if we have a brewed one
if File.exist? "#{python_prefix}/Python"
python_library = "#{python_prefix}/Python"
elsif File.exist? "#{python_prefix}/lib/lib#{python_version}.a"
python_library = "#{python_prefix}/lib/lib#{python_version}.a"
elsif File.exist? "#{python_prefix}/lib/lib#{python_version}.dylib"
python_library = "#{python_prefix}/lib/lib#{python_version}.dylib"
else
odie "No libpythonX.Y.{a,dylib} file found!"
end
args << "-DPYTHON_EXECUTABLE='#{python_executable}'"
args << "-DPYTHON_INCLUDE_DIR='#{python_include}'"
args << "-DPYTHON_LIBRARY='#{python_library}'"
else
args << "-Dpython=OFF"
end
mkdir "builddir" do
system "cmake", "..", *args
# Work around superenv stripping out isysroot leading to errors with
# libsystem_symptoms.dylib (only available on >= 10.12) and
# libsystem_darwin.dylib (only available on >= 10.13)
if MacOS.version < :high_sierra
system "xcrun", "make", "install"
else
system "make", "install"
end
chmod 0755, Dir[bin/"*.*sh"]
end
end
def caveats; <<~EOS
Because ROOT depends on several installation-dependent
environment variables to function properly, you should
add the following commands to your shell initialization
script (.bashrc/.profile/etc.), or call them directly
before using ROOT.
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
EOS
end
test do
(testpath/"test.C").write <<~EOS
#include <iostream>
void test() {
std::cout << "Hello, world!" << std::endl;
}
EOS
(testpath/"test.bash").write <<~EOS
. #{bin}/thisroot.sh
root -l -b -n -q test.C
EOS
assert_equal "\nProcessing test.C...\nHello, world!\n",
shell_output("/bin/bash test.bash")
if build.with? "python"
ENV["PYTHONPATH"] = lib/"root"
system "python3", "-c", "import ROOT"
end
end
end