homebrew-core/Formula/flatbuffers.rb
2017-01-04 19:13:50 -08:00

70 lines
1.7 KiB
Ruby

class Flatbuffers < Formula
desc "Serialization library for C++, supporting Java, C#, and Go"
homepage "https://google.github.io/flatbuffers"
url "https://github.com/google/flatbuffers/archive/v1.5.0.tar.gz"
sha256 "85362cb54042e96329cb65396a5b589789b3d42e4ed7c2debddb7a2300a05f41"
head "https://github.com/google/flatbuffers.git"
bottle do
cellar :any_skip_relocation
sha256 "f967e254f1871b9469130fa51442e744b965f262ef0056dc0af59462761891dc" => :sierra
sha256 "0f6ad20c81932296e44addee697f51a578babd72db17713ace7a57e8cfde6704" => :el_capitan
sha256 "c6ab12c74042b373684015a79ba8bed2fc554943b404ce3fcdfd65c8d11f96be" => :yosemite
end
depends_on "cmake" => :build
def install
system "cmake", "-G", "Unix Makefiles", *std_cmake_args
system "make", "install"
end
test do
def testfbs; <<-EOS.undent
// example IDL file
namespace MyGame.Sample;
enum Color:byte { Red = 0, Green, Blue = 2 }
union Any { Monster } // add more elements..
struct Vec3 {
x:float;
y:float;
z:float;
}
table Monster {
pos:Vec3;
mana:short = 150;
hp:short = 100;
name:string;
friendly:bool = false (deprecated);
inventory:[ubyte];
color:Color = Blue;
}
root_type Monster;
EOS
end
(testpath/"test.fbs").write(testfbs)
def testjson; <<-EOS.undent
{
pos: {
x: 1,
y: 2,
z: 3
},
hp: 80,
name: "MyMonster"
}
EOS
end
(testpath/"test.json").write(testjson)
system bin/"flatc", "-c", "-b", "test.fbs", "test.json"
end
end