homebrew-core/Formula/thors-serializer.rb

65 lines
1.8 KiB
Ruby

class ThorsSerializer < Formula
desc "Declarative serialization library (JSON/YAML) for C++"
homepage "https://github.com/Loki-Astari/ThorsSerializer"
url "https://github.com/Loki-Astari/ThorsSerializer.git",
tag: "1.15.1",
revision: "89ee7d6ae390547054c2c8603d8654dbfeff85e4"
bottle do
cellar :any
sha256 "1b97ecce2308db268a651067bc2d307d88cc8480358bc1cc0386ecac4fbd32fb" => :catalina
sha256 "35a422d8c4751f89850c0043a7339220eb6684959c7183551f76d2a977946b5c" => :mojave
sha256 "df5bfe38925f7bf7abdd136a55079e024a641e79ebb6fdf76cf89dd40fd8445f" => :high_sierra
end
depends_on "libyaml"
def install
ENV["COV"] = "gcov"
system "./configure", "--disable-binary",
"--disable-vera",
"--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include "ThorSerialize/JsonThor.h"
#include "ThorSerialize/SerUtil.h"
#include <sstream>
#include <iostream>
#include <string>
struct Block
{
std::string key;
int code;
};
ThorsAnvil_MakeTrait(Block, key, code);
int main()
{
using ThorsAnvil::Serialize::jsonImport;
using ThorsAnvil::Serialize::jsonExport;
std::stringstream inputData(R"({"key":"XYZ","code":37373})");
Block object;
inputData >> jsonImport(object);
if (object.key != "XYZ" || object.code != 37373) {
std::cerr << "Fail";
return 1;
}
std::cerr << "OK";
return 0;
}
EOS
system ENV.cxx, "-std=c++14", "test.cpp", "-o", "test",
"-I#{include}", "-L#{lib}", "-lThorSerialize17"
system "./test"
end
end