Skip to content

Commit

Permalink
asio: make boost optional
Browse files Browse the repository at this point in the history
Revision bump since this commit makes boost optional by default, whereas
previously you'd have to pass --c++11 to build without boost, and boost
would install (though not be used) when `depends_on "asio" => "c++11"`
was used.
  • Loading branch information
ilovezfs committed Jan 4, 2017
1 parent 7660e27 commit fe303b4
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Formula/asio.rb
Expand Up @@ -3,6 +3,7 @@ class Asio < Formula
homepage "https://think-async.com/Asio"
url "https://downloads.sourceforge.net/project/asio/asio/1.10.8%20%28Stable%29/asio-1.10.8.tar.bz2"
sha256 "26deedaebbed062141786db8cfce54e77f06588374d08cccf11c02de1da1ed49"
revision 1
head "https://github.com/chriskohlhoff/asio.git"

bottle do
Expand All @@ -19,19 +20,18 @@ class Asio < Formula
option "with-boost-coroutine", "Use Boost.Coroutine to implement stackful coroutines"
option :cxx11

needs :cxx11 if build.cxx11?

depends_on "autoconf" => :build
depends_on "automake" => :build
if !build.cxx11? || build.with?("boost-coroutine")
depends_on "boost"
else
depends_on "boost" => :optional
end

depends_on "boost" => :optional
depends_on "boost" if build.with?("boost-coroutine")
depends_on "openssl"

needs :cxx11 if build.without? "boost"

def install
ENV.cxx11 if build.cxx11?
ENV.cxx11 if build.cxx11? || build.without?("boost")

if build.head?
cd "asio"
system "./autogen.sh"
Expand All @@ -42,7 +42,7 @@ def install
--disable-dependency-tracking
--disable-silent-rules
--prefix=#{prefix}
--with-boost=#{(build.with?("boost") || build.with?("boost-coroutine") || !build.cxx11?) ? Formula["boost"].opt_include : "no"}
--with-boost=#{(build.with?("boost") || build.with?("boost-coroutine")) ? Formula["boost"].opt_include : "no"}
]
args << "--enable-boost-coroutine" if build.with? "boost-coroutine"

Expand All @@ -52,9 +52,11 @@ def install
end

test do
httpserver = pkgshare/"examples/cpp03/http/server/http_server"
found = [pkgshare/"examples/cpp11/http/server/http_server",
pkgshare/"examples/cpp03/http/server/http_server"].select(&:exist?)
raise "no http_server example file found" if found.empty?
pid = fork do
exec httpserver, "127.0.0.1", "8080", "."
exec found.first, "127.0.0.1", "8080", "."
end
sleep 1
begin
Expand Down

0 comments on commit fe303b4

Please sign in to comment.