homebrew-core/Formula/h2o.rb
2015-07-30 06:14:03 +01:00

90 lines
2.5 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/v1.4.2.tar.gz"
sha256 "3024e6a8b704d119570551db2cbca701cb6c2fa7126336239044674ee02ea09c"
head "https://github.com/h2o/h2o.git"
bottle do
sha256 "3d5210691bb828997293277daee86168902fb357683bc4cbf2519aa21bb6c263" => :yosemite
sha256 "589789896b33f4029a6b8237b0e974481bcb21af0f62aff90dae413838535c90" => :mavericks
sha256 "9491c1fc379d5cc099771b9df8232170e497f8fbde56229fdf754e9849ddd01f" => :mountain_lion
end
option "with-libuv", "Build the H2O library in addition to the executable"
depends_on "cmake" => :build
depends_on "pkg-config" => :build
depends_on "openssl" => :recommended
depends_on "libressl" => :optional
depends_on "libuv" => :optional
depends_on "wslay" => :optional
depends_on "mruby" => :optional
def install
args = std_cmake_args
args << "-DWITH_BUNDLED_SSL=OFF"
args << "-DWITH_MRUBY=ON" if build.with? "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
system bin/"h2o", "--version"
end
end