87 lines
2.8 KiB
Ruby
87 lines
2.8 KiB
Ruby
class Luarocks < Formula
|
|
desc "Package manager for the Lua programming language"
|
|
homepage "https://luarocks.org/"
|
|
url "https://luarocks.org/releases/luarocks-3.4.0.tar.gz"
|
|
sha256 "62ce5826f0eeeb760d884ea8330cd1552b5d432138b8bade0fa72f35badd02d0"
|
|
license "MIT"
|
|
revision 1
|
|
head "https://github.com/luarocks/luarocks.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
rebuild 1
|
|
sha256 "467c07a4a1d8caa1c203b018eed458b52d8422eb7462a7c8b660e5039c8ea715" => :big_sur
|
|
sha256 "9a63642081b7f8ea892c2f2af21bb406c3a40ad8104c1611cbdc1af2bb426350" => :catalina
|
|
sha256 "8d2939561e8b8f0c0162458e0460a29954836fa1536c34e5e15b7c91ba8536b7" => :mojave
|
|
end
|
|
|
|
depends_on "lua@5.1" => :test
|
|
depends_on "lua@5.3" => :test
|
|
depends_on "luajit" => :test
|
|
depends_on "lua"
|
|
|
|
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
|
|
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"
|
|
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
|