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.6.1.tar.gz" sha256 "b9ffb59ecce6c35ea55cc95c71c7d85e91ac5fc888ada264da7c77f1d8e655f0" head "https://github.com/h2o/h2o.git" bottle do sha256 "0c64bb64a2ccb9065c4ad79dca90e20e66dea74c7a8116c166a6f22f65117ea4" => :el_capitan sha256 "d0603d6520f363e8c1f47698337c0431aee8be3e5948920ced8fbef84debfda5" => :yosemite sha256 "6dc8da7d19191070e2ff1a95edfddaccc6c349886c1bfa6a15fc1dba184ed57f" => :mavericks 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" => :recommended depends_on "libressl" => :optional depends_on "libuv" => :optional depends_on "wslay" => :optional def install 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 Label #{plist_name} RunAtLoad KeepAlive ProgramArguments #{opt_bin}/h2o -c #{etc}/h2o/h2o.conf 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