aa8cf95e3b
Closes #11244. Signed-off-by: Tomasz Pajor <tomek@polishgeeks.com>
108 lines
3 KiB
Ruby
108 lines
3 KiB
Ruby
class H2o < Formula
|
|
desc "HTTP server with support for HTTP/1.x and HTTP/2"
|
|
homepage "https://github.com/h2o/h2o/"
|
|
url "https://github.com/h2o/h2o/archive/v2.1.0.tar.gz"
|
|
sha256 "41f3853f3083c2fe8e70d3ab7be02c3de3c26fb77ba5fc56fdaf46712418b999"
|
|
|
|
bottle do
|
|
sha256 "c19354cb6b90a2f17c785c23d263f811e4c32a9481be08a0b09e9ea904fc983b" => :sierra
|
|
sha256 "214dcea3516890acf068dd052d3706b59e76f23c97eaaba32635554b973e3bb8" => :el_capitan
|
|
sha256 "b7f26e40e1f9d4f76ea5e6ae0d3fdbcb6fcddd9e915758c136636120eeea3685" => :yosemite
|
|
end
|
|
|
|
devel do
|
|
url "https://github.com/h2o/h2o/archive/v2.2.0-beta2.tar.gz"
|
|
sha256 "9461d3187cba7635954837f8daad73319315b5b88ab40da2322e3d8657cc34cf"
|
|
version "2.2.0-beta2"
|
|
end
|
|
|
|
option "with-libuv", "Build the H2O library in addition to the executable"
|
|
option "without-mruby", "Don't build the bundled statically-linked mruby"
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "openssl"
|
|
depends_on "libuv" => :optional
|
|
depends_on "wslay" => :optional
|
|
|
|
def install
|
|
# https://github.com/Homebrew/homebrew-core/pull/1046
|
|
# https://github.com/Homebrew/brew/pull/251
|
|
ENV.delete("SDKROOT")
|
|
|
|
args = std_cmake_args
|
|
args << "-DWITH_BUNDLED_SSL=OFF"
|
|
args << "-DWITH_MRUBY=OFF" if build.without? "mruby"
|
|
|
|
system "cmake", *args
|
|
|
|
if build.with? "libuv"
|
|
system "make", "libh2o"
|
|
lib.install "libh2o.a"
|
|
end
|
|
|
|
system "make", "install"
|
|
|
|
(etc/"h2o").mkpath
|
|
(var/"h2o").install "examples/doc_root/index.html"
|
|
# Write up a basic example conf for testing.
|
|
(buildpath/"brew/h2o.conf").write conf_example
|
|
(etc/"h2o").install buildpath/"brew/h2o.conf"
|
|
end
|
|
|
|
# This is simplified from examples/h2o/h2o.conf upstream.
|
|
def conf_example; <<-EOS.undent
|
|
listen: 8080
|
|
hosts:
|
|
"127.0.0.1.xip.io:8080":
|
|
paths:
|
|
/:
|
|
file.dir: #{var}/h2o/
|
|
EOS
|
|
end
|
|
|
|
def caveats; <<-EOS.undent
|
|
A basic example configuration file has been placed in #{etc}/h2o.
|
|
You can find fuller, unmodified examples here:
|
|
https://github.com/h2o/h2o/tree/master/examples/h2o
|
|
EOS
|
|
end
|
|
|
|
plist_options :manual => "h2o"
|
|
|
|
def plist; <<-EOS.undent
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>KeepAlive</key>
|
|
<true/>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{opt_bin}/h2o</string>
|
|
<string>-c</string>
|
|
<string>#{etc}/h2o/h2o.conf</string>
|
|
</array>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
pid = fork do
|
|
exec "#{bin}/h2o -c #{etc}/h2o/h2o.conf"
|
|
end
|
|
sleep 2
|
|
|
|
begin
|
|
assert_match "Welcome to H2O", shell_output("curl localhost:8080")
|
|
ensure
|
|
Process.kill("SIGINT", pid)
|
|
Process.wait(pid)
|
|
end
|
|
end
|
|
end
|