homebrew-core/Formula/thors-serializer.rb
2018-08-05 23:42:40 -07:00

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.6.1",
:revision => "76d99cb2cd540052509cf2d2652c494943a18b84"
bottle do
cellar :any
sha256 "674f0e06466264f89be23e48c59ee4b0fa2a8960ed0d52283e7fa81dfdddfa82" => :high_sierra
sha256 "81d5312ec6a778c0ad4ba47496e0b1ef8633516cf299e579363a6ab231295bc9" => :sierra
sha256 "0e74887f39114c9429cf9927703efdc6cf61fe2af4685a1ffc0e8106a89eadc7" => :el_capitan
end
depends_on "libyaml"
needs :cxx14
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