From 127ab286b19b6210a2071355a5a90a2b0d6f39f2 Mon Sep 17 00:00:00 2001 From: Teddy Reed Date: Sun, 30 Aug 2015 01:37:07 -0700 Subject: [PATCH] google-benchmark: 0.1.0 (new formula) Closes Homebrew/homebrew#43399. Signed-off-by: Dominyk Tiller --- Formula/google-benchmark.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Formula/google-benchmark.rb diff --git a/Formula/google-benchmark.rb b/Formula/google-benchmark.rb new file mode 100644 index 0000000000000..5314609ada08a --- /dev/null +++ b/Formula/google-benchmark.rb @@ -0,0 +1,35 @@ +class GoogleBenchmark < Formula + desc "C++ microbenchmark support library" + homepage "https://github.com/google/benchmark" + url "https://github.com/google/benchmark/archive/v0.1.0.tar.gz" + sha256 "41aa7dca7aa94911deee078e39f7602d760f2911bb33086b5a2c8204717ddad4" + + depends_on "cmake" => :build + + needs :cxx11 + + def install + ENV.cxx11 + + system "cmake", *std_cmake_args + system "make" + system "make", "test" + system "make", "install" + end + + test do + (testpath/"test.cpp").write <<-EOS.undent + #include + #include + static void BM_StringCreation(benchmark::State& state) { + while (state.KeepRunning()) + std::string empty_string; + } + BENCHMARK(BM_StringCreation); + BENCHMARK_MAIN(); + EOS + flags = ["-stdlib=libc++", "-I#{include}", "-L#{lib}", "-lbenchmark"] + ENV.cflags.to_s.split + system ENV.cxx, "-o", "test", "test.cpp", *flags + system "./test" + end +end