66 lines
2.0 KiB
Ruby
66 lines
2.0 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.7.0.tar.gz"
|
|
sha256 "f0114a4d3c88be9e696762f37a7c379619443ce9d668546c61b21d41affe5b62"
|
|
license "MIT"
|
|
revision 1
|
|
head "https://github.com/gabime/spdlog.git", branch: "v1.x"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "04276c895db91e7bf90bae4aef73a39b7a8b018bf3c2a34dda50609723b96b47" => :catalina
|
|
sha256 "4c40c947691b56bbbc586b0a15d511f351d8980b8534229047558a801ddf33c9" => :mojave
|
|
sha256 "df958e08b8bfed9c6e4b9ce3e8148706e414634d27ca0ec6f50bda60caccd1f8" => :high_sierra
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "fmt"
|
|
|
|
def install
|
|
ENV.cxx11
|
|
|
|
inreplace "include/spdlog/tweakme.h", "// #define SPDLOG_FMT_EXTERNAL", "#define SPDLOG_FMT_EXTERNAL"
|
|
|
|
mkdir "spdlog-build" do
|
|
args = std_cmake_args + %W[
|
|
-Dpkg_config_libdir=#{lib}
|
|
-DSPDLOG_BUILD_BENCH=OFF
|
|
-DSPDLOG_BUILD_TESTS=OFF
|
|
-DSPDLOG_FMT_EXTERNAL=ON
|
|
]
|
|
system "cmake", "..", "-DSPDLOG_BUILD_SHARED=ON", *args
|
|
system "make", "install"
|
|
system "make", "clean"
|
|
system "cmake", "..", "-DSPDLOG_BUILD_SHARED=OFF", *args
|
|
system "make"
|
|
lib.install "libspdlog.a"
|
|
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}", "-L#{Formula["fmt"].opt_lib}", "-lfmt", "-o", "test"
|
|
system "./test"
|
|
assert_predicate testpath/"basic-log.txt", :exist?
|
|
assert_match "Test", (testpath/"basic-log.txt").read
|
|
end
|
|
end
|