homebrew-core/Formula/thors-serializer.rb
2019-07-15 08:53:16 +08:00

64 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.13.5",
:revision => "9a276568714ad6482ce9c3dccc50ad88cfa55246"
bottle do
cellar :any
sha256 "2467f04a88cd83134da7b857a50a5309c5d5576b911ce698f7583496879049e1" => :mojave
sha256 "52f052ad21a72f28b4eeb071f53131aa53899e4964ba90b311ce4193954b4e20" => :high_sierra
sha256 "4529431f870a848cf22bedd03d2752819f1c9dd6618bea8eb5e29152738754fc" => :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