homebrew-core/Formula/thors-serializer.rb
2019-02-17 12:55:04 +01:00

63 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.10.1",
:revision => "34edb4eec2e51b1eb9772276a69674c003622fef"
bottle do
cellar :any
sha256 "daafaa62ae50a8ce3d64b95f8dde040882f7d3d7c76331b3882eb7fd10b1f288" => :mojave
sha256 "ab1470be44df2fc1f3797565247789ca3a9f061027a71709e948637d6f0c9d35" => :high_sierra
sha256 "fa1a7d0a3d609e9b8d33fe61df17e9476cf7677c4724921ef8e999ecfc3acba7" => :sierra
end
depends_on "libyaml"
def install
ENV["COV"] = "gcov"
system "./configure", "--disable-binary",
"--disable-vera",
"--prefix=#{prefix}"
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