-
Notifications
You must be signed in to change notification settings - Fork 133
/
Copy pathruby.rb
295 lines (253 loc) · 8.5 KB
/
ruby.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
class Ruby < Formula
desc "Powerful, clean, object-oriented scripting language"
homepage "https://www.ruby-lang.org/"
url "https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.10.tar.bz2"
sha256 "6ea3ce7fd0064524ae06dbdcd99741c990901dfc9c66d8139a02f907d30b95a8"
bottle do
end
head do
url "http://svn.ruby-lang.org/repos/ruby/trunk/"
depends_on "autoconf" => :build
end
option :universal
option "with-suffix", "Suffix commands with '24'"
option "with-doc", "Install documentation"
option "with-tcltk", "Install with Tcl/Tk support"
depends_on "pkg-config" => :build
depends_on "readline" => :recommended
depends_on "gdbm" => :optional
depends_on "gmp" => :optional
depends_on "libffi" => :optional
depends_on "libyaml"
depends_on "openssl"
depends_on :x11 if build.with? "tcltk"
if true# MacOS.version <= :leopard
# fix for ext/dbm/extconf.rb
# fix for ext/fiddle/libffi-3.2.1/src/x86/win32.S
# based on https://github.com/macports/macports-ports/blob/8964c98f0e33e4aaabc851d8b684f4c709edceef/devel/libffi/files/PR-44170.patch
patch :DATA
end
# fails_with :llvm do
# build 2326
# end
def install
# mcontext types had a member named `ss` instead of `__ss`
# prior to Leopard; see
# https://github.com/mistydemeo/tigerbrew/issues/473
if Hardware::CPU.intel? && MacOS.version < :leopard
inreplace "signal.c" do |s|
s.gsub! "->__ss.", "->ss."
s.gsub! "__rsp", "rsp"
s.gsub! "__rbp", "rbp"
s.gsub! "__esp", "esp"
s.gsub! "__ebp", "ebp"
end
inreplace "vm_dump.c" do |s|
s.gsub! /uc_mcontext->__(ss)\.__(r\w\w)/,
"uc_mcontext->\1.\2"
s.gsub! "mctx->__ss.__##reg",
"mctx->ss.reg"
# missing include in vm_dump; this is an ugly solution
s.gsub! '#include "iseq.h"',
%{#include "iseq.h"\n#include <ucontext.h>}
end
end
system "autoconf" if build.head?
args = %W[
--prefix=#{prefix} --enable-shared --disable-silent-rules
--with-sitedir=#{HOMEBREW_PREFIX}/lib/ruby/site_ruby
--with-vendordir=#{HOMEBREW_PREFIX}/lib/ruby/vendor_ruby
]
if build.universal?
ENV.universal_binary
args << "--with-arch=#{Hardware::CPU.universal_archs.join(",")}"
end
args << "--program-suffix=24" if build.with? "suffix"
args << "--with-out-ext=tk" if build.without? "tcltk"
args << "--disable-install-doc" if build.without? "doc"
args << "--disable-dtrace" unless MacOS::CLT.installed?
args << "--without-gmp" if build.without? "gmp"
# Reported upstream: https://bugs.ruby-lang.org/issues/10272
args << "--with-setjmp-type=setjmp" if MacOS.version == :lion
paths = [
Formula["libyaml"].opt_prefix,
Formula["openssl"].opt_prefix
]
%w[readline gdbm gmp libffi].each do |dep|
paths << Formula[dep].opt_prefix if build.with? dep
end
args << "--with-opt-dir=#{paths.join(":")}"
system "./configure", *args
# Ruby has been configured to look in the HOMEBREW_PREFIX for the
# sitedir and vendordir directories; however we don't actually want to create
# them during the install.
#
# These directories are empty on install; sitedir is used for non-rubygems
# third party libraries, and vendordir is used for packager-provided libraries.
inreplace "tool/rbinstall.rb" do |s|
s.gsub! 'prepare "extension scripts", sitelibdir', ""
s.gsub! 'prepare "extension scripts", vendorlibdir', ""
s.gsub! 'prepare "extension objects", sitearchlibdir', ""
s.gsub! 'prepare "extension objects", vendorarchlibdir', ""
end
system "make"
system "make", "install"
end
def post_install
# Customize rubygems to look/install in the global gem directory
# instead of in the Cellar, making gems last across reinstalls
config_file = lib/"ruby/#{abi_version}/rubygems/defaults/operating_system.rb"
config_file.unlink if config_file.exist?
config_file.write rubygems_config
# Create the sitedir and vendordir that were skipped during install
mkdir_p `#{bin}/ruby -e 'require "rbconfig"; print RbConfig::CONFIG["sitearchdir"]'`
mkdir_p `#{bin}/ruby -e 'require "rbconfig"; print RbConfig::CONFIG["vendorarchdir"]'`
end
def abi_version
"2.2.0"
end
def rubygems_config; <<-EOS.undent
module Gem
class << self
alias :old_default_dir :default_dir
alias :old_default_path :default_path
alias :old_default_bindir :default_bindir
alias :old_ruby :ruby
end
def self.default_dir
path = [
"#{HOMEBREW_PREFIX}",
"lib",
"ruby",
"gems",
"#{abi_version}"
]
@default_dir ||= File.join(*path)
end
def self.private_dir
path = if defined? RUBY_FRAMEWORK_VERSION then
[
File.dirname(RbConfig::CONFIG['sitedir']),
'Gems',
RbConfig::CONFIG['ruby_version']
]
elsif RbConfig::CONFIG['rubylibprefix'] then
[
RbConfig::CONFIG['rubylibprefix'],
'gems',
RbConfig::CONFIG['ruby_version']
]
else
[
RbConfig::CONFIG['libdir'],
ruby_engine,
'gems',
RbConfig::CONFIG['ruby_version']
]
end
@private_dir ||= File.join(*path)
end
def self.default_path
if Gem.user_home && File.exist?(Gem.user_home)
[user_dir, default_dir, private_dir]
else
[default_dir, private_dir]
end
end
def self.default_bindir
"#{HOMEBREW_PREFIX}/bin"
end
def self.ruby
"#{opt_bin}/ruby#{"24" if build.with? "suffix"}"
end
end
EOS
end
test do
output = `#{bin}/ruby -e "puts 'hello'"`
assert_equal "hello\n", output
assert_equal 0, $?.exitstatus
end
end
__END__
--- a/ext/dbm/extconf.rb 2015-12-16 05:31:54.000000000 +0000
+++ b/ext/dbm/extconf.rb
@@ -137,7 +137,7 @@ def headers.db_check2(db, hdr)
have_library("gdbm") or return false
end
- if !have_type("DBM", hdr, hsearch)
+ if !have_type("DBM", ["db.h", hdr], hsearch)
return false
end
--- a/ext/fiddle/libffi-3.2.1/src/x86/win32.S 2017-04-04 11:14:27.000000000 +0200
+++ b/ext/fiddle/libffi-3.2.1/src/x86/win32.S 2017-04-04 11:16:20.000000000 +0200
@@ -528,7 +528,7 @@
.text
# This assumes we are using gas.
- .balign 16
+ .p2align 4
FFI_HIDDEN(ffi_call_win32)
.globl USCORE_SYMBOL(ffi_call_win32)
#if defined(X86_WIN32) && !defined(__OS2__)
@@ -711,7 +711,7 @@
popl %ebp
ret
.ffi_call_win32_end:
- .balign 16
+ .p2align 4
FFI_HIDDEN(ffi_closure_THISCALL)
.globl USCORE_SYMBOL(ffi_closure_THISCALL)
#if defined(X86_WIN32) && !defined(__OS2__)
@@ -724,7 +724,7 @@
push %ecx
jmp .ffi_closure_STDCALL_internal
- .balign 16
+ .p2align 4
FFI_HIDDEN(ffi_closure_FASTCALL)
.globl USCORE_SYMBOL(ffi_closure_FASTCALL)
#if defined(X86_WIN32) && !defined(__OS2__)
@@ -753,7 +753,7 @@
.LFE1:
# This assumes we are using gas.
- .balign 16
+ .p2align 4
FFI_HIDDEN(ffi_closure_SYSV)
#if defined(X86_WIN32)
.globl USCORE_SYMBOL(ffi_closure_SYSV)
@@ -897,7 +897,7 @@
#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
#ifdef X86_WIN32
- .balign 16
+ .p2align 4
FFI_HIDDEN(ffi_closure_raw_THISCALL)
.globl USCORE_SYMBOL(ffi_closure_raw_THISCALL)
#if defined(X86_WIN32) && !defined(__OS2__)
@@ -916,7 +916,7 @@
#endif /* X86_WIN32 */
# This assumes we are using gas.
- .balign 16
+ .p2align 4
#if defined(X86_WIN32)
.globl USCORE_SYMBOL(ffi_closure_raw_SYSV)
#if defined(X86_WIN32) && !defined(__OS2__)
@@ -1039,7 +1039,7 @@
#endif /* !FFI_NO_RAW_API */
# This assumes we are using gas.
- .balign 16
+ .p2align 4
FFI_HIDDEN(ffi_closure_STDCALL)
.globl USCORE_SYMBOL(ffi_closure_STDCALL)
#if defined(X86_WIN32) && !defined(__OS2__)
@@ -1184,7 +1184,6 @@
#if defined(X86_WIN32) && !defined(__OS2__)
.section .eh_frame,"w"
-#endif
.Lframe1:
.LSCIE1:
.long .LECIE1-.LASCIE1 /* Length of Common Information Entry */
@@ -1343,6 +1342,7 @@
/* End of DW_CFA_xxx CFI instructions. */
.align 4
.LEFDE5:
+#endif
#endif /* !_MSC_VER */