-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
/
Copy pathr.rb
172 lines (146 loc) · 5.6 KB
/
r.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
170
171
172
class R < Formula
desc "Software environment for statistical computing"
homepage "https://www.r-project.org/"
url "https://cran.r-project.org/src/base/R-4/R-4.4.2.tar.gz"
sha256 "1578cd603e8d866b58743e49d8bf99c569e81079b6a60cf33cdf7bdffeb817ec"
license "GPL-2.0-or-later"
revision 2
livecheck do
url "https://cran.rstudio.com/banner.shtml"
regex(%r{href=(?:["']?|.*?/)R[._-]v?(\d+(?:\.\d+)+)\.t}i)
end
bottle do
sha256 arm64_sequoia: "f1d78b921640ef5812a8bd94937853dd01f0a21da2d69d18a20f627101ed9bcb"
sha256 arm64_sonoma: "953086cec342bd7cc121c0c59f7dddf1c666905d719eadf1d77aefc76f57dbde"
sha256 arm64_ventura: "5b394ab291177353357bfcc2d5d7ab4097b23ddc50f9346bd3ef94659a75f09d"
sha256 sonoma: "e575dff30a4305b5a9a1e9e510c3583ce51d991281fdb48c5138f582e7c82055"
sha256 ventura: "40f8186e96f4fd507f7b8d653a5d891dc488fa950e987c651feafa3ff81fb025"
sha256 x86_64_linux: "6a984c21e657a33571022f0254219c0f220c225a9d39379f5e3240eedcd71188"
end
depends_on "pkgconf" => :build
depends_on "cairo"
depends_on "gcc" # for gfortran
depends_on "gettext"
depends_on "jpeg-turbo"
depends_on "libpng"
depends_on "libxext"
depends_on "openblas"
depends_on "pcre2"
depends_on "readline"
depends_on "tcl-tk@8"
depends_on "xz"
uses_from_macos "bzip2"
uses_from_macos "curl"
uses_from_macos "libffi", since: :catalina
uses_from_macos "zlib"
on_macos do
depends_on "fontconfig"
depends_on "freetype"
depends_on "libx11"
depends_on "libxau"
depends_on "libxcb"
depends_on "libxdmcp"
depends_on "libxrender"
depends_on "pixman"
end
on_linux do
depends_on "glib"
depends_on "harfbuzz"
depends_on "icu4c@76"
depends_on "libice"
depends_on "libsm"
depends_on "libtirpc"
depends_on "libx11"
depends_on "libxt"
depends_on "pango"
end
# needed to preserve executable permissions on files without shebangs
skip_clean "lib/R/bin", "lib/R/doc"
fails_with :gcc do
version "11"
cause "Unknown. FIXME."
end
def install
# `configure` doesn't like curl 8+, but convince it that everything is ok.
# TODO: report this upstream.
ENV["r_cv_have_curl728"] = "yes"
args = [
"--prefix=#{prefix}",
"--enable-memory-profiling",
"--with-tcl-config=#{Formula["tcl-tk@8"].opt_lib}/tclConfig.sh",
"--with-tk-config=#{Formula["tcl-tk@8"].opt_lib}/tkConfig.sh",
"--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas",
"--enable-R-shlib",
"--disable-java",
"--with-cairo",
# This isn't necessary to build R, but it's saved in Makeconf
# and helps CRAN packages find gfortran when Homebrew may not be
# in PATH (e.g. under RStudio, launched from Finder)
"FC=#{Formula["gcc"].opt_bin}/gfortran",
]
if OS.mac?
args << "--without-x"
args << "--with-aqua"
else
args << "--libdir=#{lib}" # avoid using lib64 on CentOS
# Avoid references to homebrew shims
args << "LD=ld"
# If LDFLAGS contains any -L options, configure sets LD_LIBRARY_PATH to
# search those directories. Remove -LHOMEBREW_PREFIX/lib from LDFLAGS.
ENV.remove "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
ENV.append "CPPFLAGS", "-I#{Formula["libtirpc"].opt_include}/tirpc"
ENV.append "LDFLAGS", "-L#{Formula["libtirpc"].opt_lib}"
end
# Help CRAN packages find gettext and readline
["gettext", "readline", "xz"].each do |f|
ENV.append "CPPFLAGS", "-I#{Formula[f].opt_include}"
ENV.append "LDFLAGS", "-L#{Formula[f].opt_lib}"
end
system "./configure", *args
system "make"
ENV.deparallelize do
system "make", "install"
end
system "make", "-C", "src/nmath/standalone"
ENV.deparallelize do
system "make", "-C", "src/nmath/standalone", "install"
end
r_home = lib/"R"
# make Homebrew packages discoverable for R CMD INSTALL
inreplace r_home/"etc/Makeconf" do |s|
s.gsub!(/^CPPFLAGS =.*/, "\\0 -I#{HOMEBREW_PREFIX}/include")
s.gsub!(/^LDFLAGS =.*/, "\\0 -L#{HOMEBREW_PREFIX}/lib")
s.gsub!(/.LDFLAGS =.*/, "\\0 $(LDFLAGS)")
end
include.install_symlink Dir[r_home/"include/*"]
lib.install_symlink Dir[r_home/"lib/*"]
# avoid triggering mandatory rebuilds of r when gcc is upgraded
inreplace lib/"R/etc/Makeconf", Formula["gcc"].prefix.realpath,
Formula["gcc"].opt_prefix,
audit_result: OS.mac?
end
def post_install
short_version = Utils.safe_popen_read(bin/"Rscript", "-e", "cat(as.character(getRversion()[1,1:2]))")
site_library = HOMEBREW_PREFIX/"lib/R"/short_version/"site-library"
site_library.mkpath
touch site_library/".keepme"
site_library_cellar = lib/"R/site-library"
site_library_cellar.unlink if site_library_cellar.exist?
site_library_cellar.parent.install_symlink site_library
end
test do
assert_equal "[1] 2", shell_output("#{bin}/Rscript -e 'print(1+1)'").chomp
assert_equal shared_library(""), shell_output("#{bin}/R CMD config DYLIB_EXT").chomp
system bin/"Rscript", "-e", "if(!capabilities('cairo')) stop('cairo not available')"
system bin/"Rscript", "-e", "install.packages('gss', '.', 'https://cloud.r-project.org')"
assert_predicate testpath/"gss/libs/gss.so", :exist?,
"Failed to install gss package"
winsys = "[1] \"aqua\""
if OS.linux?
return if ENV["HOMEBREW_GITHUB_ACTIONS"]
winsys = "[1] \"x11\""
end
assert_equal winsys,
shell_output("#{bin}/Rscript -e 'library(tcltk)' -e 'tclvalue(.Tcl(\"tk windowingsystem\"))'").chomp
end
end