Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luvit: build from source + depend on luajit-openresty #69036

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 58 additions & 4 deletions Formula/luvit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Luvit < Formula
url "https://github.com/luvit/luvit/archive/2.17.0.tar.gz"
sha256 "80657aa752322560fcde780212b6807b626b45d65aca3f3dae254e5c4fb0ee78"
license "Apache-2.0"
revision 1
head "https://github.com/luvit/luvit.git"

bottle do
Expand All @@ -14,15 +15,68 @@ class Luvit < Formula
sha256 "2c704b1f98b965c0b6010a897a0c951f47cb896bbbf5381e7d4ee80238692033" => :high_sierra
end

depends_on "cmake" => :build
depends_on "luajit-openresty" => :build
depends_on "luv" => :build
depends_on "pkg-config" => :build
depends_on "luajit"
depends_on "libuv"
depends_on "openssl@1.1"
depends_on "pcre"

# To update this resource, check LIT_VERSION in the Makefile:
# https://github.com/luvit/luvit/blob/#{version}/Makefile
resource "lit" do
url "https://github.com/luvit/lit.git",
tag: "3.8.1",
revision: "27114d94b9299437b2229eac6a6c3a9ef41fa83a"
end

# To update this resource, check LUVI_VERSION in
# https://github.com/luvit/lit/raw/$(LIT_VERSION)/get-lit.sh
resource "luvi" do
url "https://github.com/luvit/luvi.git",
tag: "v2.11.0",
revision: "9da12caaf01337ef0609d07b2af9a5296c13922a"
end

def install
ENV["USE_SYSTEM_SSL"] = "1"
ENV["USE_SYSTEM_LUAJIT"] = "1"
ENV["PREFIX"] = prefix
system "make"
luajit = Formula["luajit-openresty"]

resource("luvi").stage do
# Build scripts set LUA_PATH before invoking LuaJIT, but that causes errors.
# Reported at https://github.com/luvit/luvi/issues/242
inreplace "cmake/Modules/LuaJITAddExecutable.cmake",
"COMMAND \"LUA_PATH=${LUA_PATH}\" luajit", "COMMAND luajit"

# Build scripts double the prefix of this directory, so we set it manually.
# Reported in the issue linked above.
ENV["LPEGLIB_DIR"] = "deps/lpeg"

# CMake flags adapted from
# https://github.com/luvit/luvi/blob/#{luvi_version}/Makefile#L73-L74
luvi_args = std_cmake_args + %W[
-DWithOpenSSL=ON
-DWithSharedOpenSSL=ON
-DWithPCRE=ON
-DWithLPEG=ON
-DWithSharedPCRE=ON
-DWithSharedLibluv=ON
-DLIBLUV_INCLUDE_DIR=#{Formula["luv"].opt_include}/luv
-DLIBLUV_LIBRARIES=#{Formula["luv"].opt_lib}/libluv_a.a
-DLUAJIT_INCLUDE_DIR=#{luajit.opt_include}/luajit-2.1
-DLUAJIT_LIBRARIES=#{luajit.opt_lib}/libluajit.a
]

system "cmake", ".", "-B", "build", *luvi_args
system "cmake", "--build", "build"
buildpath.install "build/luvi"
end

resource("lit").stage do
system buildpath/"luvi", ".", "--", "make", ".", buildpath/"lit", buildpath/"luvi"
end

system "make", "install"
end

Expand Down