33class PortableRuby < PortableFormula
44 desc "Powerful, clean, object-oriented scripting language"
55 homepage "https://www.ruby-lang.org/"
6- # This is the version shipped in macOS 11.7.1/12.6.1/13.
7- url "https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.10.tar.xz"
8- sha256 "5fd8ded51321b88fdc9c1b4b0eb1b951d2eddbc293865da0151612c2e814c1f2"
6+ url "https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.4.tar.gz"
7+ sha256 "a3d55879a0dfab1d7141fdf10d22a07dbf8e5cdc4415da1bde06127d5cc3c7b6"
98 license "Ruby"
10- revision 1
119
1210 depends_on "pkg-config" => :build
1311 depends_on "portable-libyaml" => :build
1412 depends_on "portable-openssl" => :build
1513
1614 on_linux do
1715 depends_on "portable-libedit" => :build
16+ depends_on "portable-libffi" => :build
1817 depends_on "portable-libxcrypt" => :build
1918 depends_on "portable-ncurses" => :build
2019 depends_on "portable-zlib" => :build
2120 end
2221
2322 def install
24- libedit = Formula [ "portable-libedit" ]
2523 libyaml = Formula [ "portable-libyaml" ]
26- openssl = Formula [ "portable-openssl" ]
2724 libxcrypt = Formula [ "portable-libxcrypt" ]
25+ openssl = Formula [ "portable-openssl" ]
26+ libedit = Formula [ "portable-libedit" ]
27+ libffi = Formula [ "portable-libffi" ]
2828 ncurses = Formula [ "portable-ncurses" ]
2929 zlib = Formula [ "portable-zlib" ]
3030
3131 args = portable_configure_args + %W[
3232 --prefix=#{ prefix }
3333 --enable-load-relative
3434 --with-static-linked-ext
35- --with-out-ext=tk,sdbm,gdbm,dbm
35+ --with-out-ext=win32,win32ole
3636 --without-gmp
3737 --enable-libedit
3838 --disable-install-doc
@@ -43,10 +43,9 @@ def install
4343 # Correct MJIT_CC to not use superenv shim
4444 args << "MJIT_CC=/usr/bin/#{ DevelopmentTools . default_compiler } "
4545
46+ # We don't specify OpenSSL as we want it to use the pkg-config, which `--with-openssl-dir` will disable
4647 args += %W[
47- --with-libedit-dir=#{ libedit . opt_prefix }
4848 --with-libyaml-dir=#{ libyaml . opt_prefix }
49- --with-openssl-dir=#{ openssl . opt_prefix }
5049 ]
5150
5251 if OS . linux?
@@ -60,6 +59,8 @@ def install
6059 end
6160
6261 args += %W[
62+ --with-libedit-dir=#{ libedit . opt_prefix }
63+ --with-libffi-dir=#{ libffi . opt_prefix }
6364 --with-ncurses-dir=#{ ncurses . opt_prefix }
6465 --with-zlib-dir=#{ zlib . opt_prefix }
6566 ]
@@ -75,14 +76,17 @@ def install
7576
7677 # Usually cross-compiling requires a host Ruby of the same version.
7778 # In our scenario though, we can get away with using miniruby as it should run on newer macOS.
79+ make_args = [ ]
7880 if OS . mac? && CROSS_COMPILING
7981 ENV [ "MINIRUBY" ] = "./miniruby -I$(srcdir)/lib -I. -I$(EXTOUT)/common"
80- run_opts = "#{ Dir . pwd } /tool/runruby.rb --extout=.ext"
82+ make_args << "HAVE_BASERUBY=no"
83+ make_args << "PREP=miniruby"
84+ make_args << "RUN_OPTS=#{ Dir . pwd } /tool/runruby.rb --extout=.ext"
8185 end
8286
8387 system "./configure" , *args
84- system "make" , "RUN_OPTS= #{ run_opts } "
85- system "make" , "install" , "RUN_OPTS= #{ run_opts } "
88+ system "make" , * make_args
89+ system "make" , "install" , * make_args
8690
8791 # rake is a binstub for the RubyGem in 2.3 and has a hardcoded PATH.
8892 # We don't need the binstub so remove it.
@@ -96,6 +100,8 @@ def install
96100 inreplace lib /"ruby/#{ abi_version } /#{ abi_arch } /rbconfig.rb" do |s |
97101 s . gsub! ENV . cxx , "c++"
98102 s . gsub! ENV . cc , "cc"
103+ # C++ compiler might have been disabled because we break it with [email protected] builds 104+ s . sub! ( /(CONFIG\[ "CXX"\] = )"false"/ , '\\1"c++"' )
99105 end
100106
101107 cp_r ncurses . share /"terminfo" , share /"terminfo"
@@ -125,7 +131,7 @@ def install
125131 assert_equal "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ,
126132 shell_output ( "#{ ruby } -ropenssl -e 'puts OpenSSL::Digest::SHA256.hexdigest(\" \" )'" ) . chomp
127133 assert_match "200" ,
128- shell_output ( "#{ ruby } -ropen-uri -e 'open(\" https://google.com\" ) { |f| puts f.status.first }'" ) . chomp
134+ shell_output ( "#{ ruby } -ropen-uri -e 'URI. open(\" https://google.com\" ) { |f| puts f.status.first }'" ) . chomp
129135 system testpath /"bin/gem" , "environment"
130136 system testpath /"bin/bundle" , "init"
131137 # install gem with native components
0 commit comments