60 lines
2.0 KiB
Ruby
60 lines
2.0 KiB
Ruby
class Luv < Formula
|
|
desc "Bare libuv bindings for lua"
|
|
homepage "https://github.com/luvit/luv"
|
|
url "https://github.com/luvit/luv/archive/1.41.0-0.tar.gz"
|
|
version "1.41.0-0"
|
|
sha256 "13382bc5e896f6247c0e8f7b7cbc12c99388b9a858118a8dc5477f5b7a977c8e"
|
|
license "Apache-2.0"
|
|
head "https://github.com/luvit/luv.git"
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_big_sur: "9d8f0a28026c84843af527dc31766bcfb89761f16ad12ad0eeeb6104514693b0"
|
|
sha256 cellar: :any, big_sur: "08713383f4168d0104f123d1cad78bdeb843f26527a7d68c74aba555883c5b60"
|
|
sha256 cellar: :any, catalina: "b3c644231c6c5d55f82770cf8d0db7649347ec28dc430f6e983f17b9c19febc9"
|
|
sha256 cellar: :any, mojave: "a6cb63c24bba31847e55d04c4426eb84c6eaf24efa38ed55c7d0dd3ff800b32f"
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "luajit-openresty" => [:build, :test]
|
|
depends_on "libuv"
|
|
|
|
resource "lua-compat-5.3" do
|
|
url "https://github.com/keplerproject/lua-compat-5.3/archive/v0.10.tar.gz"
|
|
sha256 "d1ed32f091856f6fffab06232da79c48b437afd4cd89e5c1fc85d7905b011430"
|
|
end
|
|
|
|
def install
|
|
resource("lua-compat-5.3").stage buildpath/"deps/lua-compat-5.3" unless build.head?
|
|
|
|
args = std_cmake_args + %W[
|
|
-DWITH_SHARED_LIBUV=ON
|
|
-DWITH_LUA_ENGINE=LuaJIT
|
|
-DLUA_BUILD_TYPE=System
|
|
-DLUA_COMPAT53_DIR=#{buildpath}/deps/lua-compat-5.3
|
|
-DBUILD_MODULE=ON
|
|
-DBUILD_SHARED_LIBS=ON
|
|
-DBUILD_STATIC_LIBS=ON
|
|
]
|
|
|
|
system "cmake", "-S", ".", "-B", "build", *args
|
|
system "cmake", "--build", "build"
|
|
system "cmake", "--install", "build"
|
|
end
|
|
|
|
test do
|
|
ENV["LUA_CPATH"] = opt_lib/"lua/5.1/?.so"
|
|
ENV.prepend_path "PATH", Formula["luajit-openresty"].opt_bin
|
|
(testpath/"test.lua").write <<~EOS
|
|
local uv = require('luv')
|
|
local timer = uv.new_timer()
|
|
timer:start(1000, 0, function()
|
|
print("Awake!")
|
|
timer:close()
|
|
end)
|
|
print("Sleeping");
|
|
uv.run()
|
|
EOS
|
|
assert_equal "Sleeping\nAwake!\n", shell_output("luajit test.lua")
|
|
end
|
|
end
|