92 lines
3.4 KiB
Ruby
92 lines
3.4 KiB
Ruby
class Luarocks < Formula
|
|
desc "Package manager for the Lua programming language"
|
|
homepage "https://luarocks.org/"
|
|
url "https://luarocks.org/releases/luarocks-3.7.0.tar.gz"
|
|
sha256 "9255d97fee95cec5b54fc6ac718b11bf5029e45bed7873e053314919cd448551"
|
|
license "MIT"
|
|
head "https://github.com/luarocks/luarocks.git"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "ecb1a4b542242bf069c24f4c7a12d2a9448c2d29a18f96b19478f9ddd3d1831e"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "884ff51dc8c4b1009ce40d3a6f4a1306566ff9da8417ea4c03dce4c38a136807"
|
|
sha256 cellar: :any_skip_relocation, monterey: "d36503670a5ea22acf6973751a101b9ad19e49d406d01799adeb691b3e56892a"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "631971f2bc3585dc67d7b5c7b07391489442564a0f111ae358008a02e3b8d73d"
|
|
sha256 cellar: :any_skip_relocation, catalina: "b7d91bbc4ec33e19953bc1ed4127557c530b66c0e0ff7eec1a188268b486b594"
|
|
sha256 cellar: :any_skip_relocation, mojave: "bcd1442f092e25f04eac3270b5a468d911716a50a3af716ce3f4f9c44a46920e"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "ecb1a4b542242bf069c24f4c7a12d2a9448c2d29a18f96b19478f9ddd3d1831e"
|
|
end
|
|
|
|
depends_on "lua@5.1" => :test
|
|
depends_on "lua@5.3" => :test
|
|
depends_on "luajit" => :test unless Hardware::CPU.arm?
|
|
depends_on "lua"
|
|
|
|
uses_from_macos "unzip"
|
|
|
|
def install
|
|
system "./configure", "--prefix=#{prefix}",
|
|
"--sysconfdir=#{etc}",
|
|
"--rocks-tree=#{HOMEBREW_PREFIX}"
|
|
system "make", "install"
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
LuaRocks supports multiple versions of Lua. By default it is configured
|
|
to use Lua#{Formula["lua"].version.major_minor}, but you can require it to use another version at runtime
|
|
with the `--lua-dir` flag, like this:
|
|
|
|
luarocks --lua-dir=#{Formula["lua@5.1"].opt_prefix} install say
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
luas = [
|
|
Formula["lua"],
|
|
Formula["lua@5.3"],
|
|
Formula["lua@5.1"],
|
|
]
|
|
|
|
luas.each do |lua|
|
|
luaversion = lua.version.major_minor
|
|
luaexec = "#{lua.bin}/lua-#{luaversion}"
|
|
ENV["LUA_PATH"] = "#{testpath}/share/lua/#{luaversion}/?.lua"
|
|
ENV["LUA_CPATH"] = "#{testpath}/lib/lua/#{luaversion}/?.so"
|
|
|
|
system "#{bin}/luarocks", "install",
|
|
"luafilesystem",
|
|
"--tree=#{testpath}",
|
|
"--lua-dir=#{lua.opt_prefix}"
|
|
|
|
system luaexec, "-e", "require('lfs')"
|
|
|
|
case luaversion
|
|
when "5.1"
|
|
(testpath/"lfs_#{luaversion}test.lua").write <<~EOS
|
|
require("lfs")
|
|
lfs.mkdir("blank_space")
|
|
EOS
|
|
|
|
system luaexec, "lfs_#{luaversion}test.lua"
|
|
assert_predicate testpath/"blank_space", :directory?,
|
|
"Luafilesystem failed to create the expected directory"
|
|
|
|
# LuaJIT is compatible with lua5.1, so we can also test it here
|
|
unless Hardware::CPU.arm?
|
|
rmdir testpath/"blank_space"
|
|
system "#{Formula["luajit"].bin}/luajit", "lfs_#{luaversion}test.lua"
|
|
assert_predicate testpath/"blank_space", :directory?,
|
|
"Luafilesystem failed to create the expected directory"
|
|
end
|
|
else
|
|
(testpath/"lfs_#{luaversion}test.lua").write <<~EOS
|
|
require("lfs")
|
|
print(lfs.currentdir())
|
|
EOS
|
|
|
|
assert_match testpath.to_s, shell_output("#{luaexec} lfs_#{luaversion}test.lua")
|
|
end
|
|
end
|
|
end
|
|
end
|