homebrew-core/Formula/spdlog.rb
2018-11-04 13:32:49 +01:00

54 lines
1.6 KiB
Ruby

class Spdlog < Formula
desc "Super fast C++ logging library"
homepage "https://github.com/gabime/spdlog"
url "https://github.com/gabime/spdlog/archive/v1.2.1.tar.gz"
sha256 "867a4b7cedf9805e6f76d3ca41889679054f7e5a3b67722fe6d0eae41852a767"
head "https://github.com/gabime/spdlog.git"
bottle do
cellar :any_skip_relocation
sha256 "e94a8414b9acff01d5d80a99993402724f76190f6e070f8c4b8e3b7311089f4c" => :mojave
sha256 "074eabca74ff4274589e5eea0d9f39394126201b73468650c3958786110fc5ec" => :high_sierra
sha256 "074eabca74ff4274589e5eea0d9f39394126201b73468650c3958786110fc5ec" => :sierra
end
depends_on "cmake" => :build
needs :cxx11
def install
ENV.cxx11
mkdir "spdlog-build" do
args = std_cmake_args
args << "-Dpkg_config_libdir=#{lib}" << ".."
system "cmake", *args
system "make", "install"
end
end
test do
(testpath/"test.cpp").write <<~EOS
#include "spdlog/sinks/basic_file_sink.h"
#include <iostream>
#include <memory>
int main()
{
try {
auto console = spdlog::basic_logger_mt("basic_logger", "#{testpath}/basic-log.txt");
console->info("Test");
}
catch (const spdlog::spdlog_ex &ex)
{
std::cout << "Log init failed: " << ex.what() << std::endl;
return 1;
}
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp", "-I#{include}", "-o", "test"
system "./test"
assert_predicate testpath/"basic-log.txt", :exist?
assert_match "Test", (testpath/"basic-log.txt").read
end
end