2015-01-13 04:24:36 +00:00
|
|
|
class H2o < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "HTTP server with support for HTTP/1.x and HTTP/2"
|
2015-01-13 04:24:36 +00:00
|
|
|
homepage "https://github.com/h2o/h2o/"
|
2015-11-12 19:49:09 +00:00
|
|
|
url "https://github.com/h2o/h2o/archive/v1.5.4.tar.gz"
|
|
|
|
sha256 "59858a157823f8a71bcfa7564d6fb117381c20bf596a226039452be5643fcc67"
|
2015-01-13 04:24:36 +00:00
|
|
|
head "https://github.com/h2o/h2o.git"
|
|
|
|
|
2015-01-13 13:48:29 +00:00
|
|
|
bottle do
|
2015-11-12 19:54:15 +00:00
|
|
|
sha256 "366682f93f9f8b347343a9a6c9f2efe77978069d0f2dce592dfc7581d1d0525d" => :el_capitan
|
|
|
|
sha256 "732bfc831f1d7b2d372faa09a6126b98e375e762b04985e704395f288a8857b0" => :yosemite
|
|
|
|
sha256 "ef1bb499977a42a3e100f9a2f1252bcce89ac1841c864d5d53b1dd03c852b821" => :mavericks
|
2015-01-13 13:48:29 +00:00
|
|
|
end
|
|
|
|
|
2015-06-18 01:10:34 +00:00
|
|
|
option "with-libuv", "Build the H2O library in addition to the executable"
|
2015-09-30 21:03:10 +00:00
|
|
|
option "without-mruby", "Don't build the bundled statically-linked mruby"
|
2015-01-13 04:24:36 +00:00
|
|
|
|
|
|
|
depends_on "cmake" => :build
|
2015-06-18 01:10:34 +00:00
|
|
|
depends_on "pkg-config" => :build
|
2015-04-14 18:45:49 +00:00
|
|
|
depends_on "openssl" => :recommended
|
|
|
|
depends_on "libressl" => :optional
|
2015-01-13 04:24:36 +00:00
|
|
|
depends_on "libuv" => :optional
|
2015-02-18 20:55:15 +00:00
|
|
|
depends_on "wslay" => :optional
|
2015-01-13 04:24:36 +00:00
|
|
|
|
|
|
|
def install
|
2015-04-14 18:45:49 +00:00
|
|
|
args = std_cmake_args
|
|
|
|
args << "-DWITH_BUNDLED_SSL=OFF"
|
2015-09-30 21:03:10 +00:00
|
|
|
args << "-DWITH_MRUBY=OFF" if build.without? "mruby"
|
2015-04-14 18:45:49 +00:00
|
|
|
|
|
|
|
system "cmake", *args
|
2015-01-13 04:24:36 +00:00
|
|
|
|
|
|
|
if build.with? "libuv"
|
|
|
|
system "make", "libh2o"
|
|
|
|
lib.install "libh2o.a"
|
|
|
|
end
|
|
|
|
|
|
|
|
system "make", "install"
|
|
|
|
|
2015-06-18 01:10:34 +00:00
|
|
|
(etc/"h2o").mkpath
|
|
|
|
(var/"h2o").install "examples/doc_root/index.html"
|
2015-01-21 02:38:20 +00:00
|
|
|
# Write up a basic example conf for testing.
|
2015-06-18 01:10:34 +00:00
|
|
|
(buildpath/"brew/h2o.conf").write conf_example
|
|
|
|
(etc/"h2o").install buildpath/"brew/h2o.conf"
|
2015-01-13 04:24:36 +00:00
|
|
|
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
|
2015-09-30 21:03:10 +00:00
|
|
|
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
|
2015-01-13 04:24:36 +00:00
|
|
|
end
|
|
|
|
end
|