homebrew-core/Formula/flatbuffers.rb

71 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.6.0.tar.gz"
sha256 "768c50ebf5823f8cde81a9e38ffff115c8f5a5d031a37520d0024e7b9c6cd22e"
head "https://github.com/google/flatbuffers.git"
bottle do
cellar :any_skip_relocation
sha256 "fa8cd253153c183ba6f0359eefb41a736081f315e46efc6d0cea96aae6ee13be" => :sierra
sha256 "85a47127465af93d466d034dd4d19690554c1f655663e5e9fcc362cf315ad2b8" => :el_capitan
sha256 "e14573ba98e2a81ff89ac4f111930bd038c57bf1fc89c59bb7d00fb6bcbd774b" => :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