2015-02-05 04:58:41 +00:00
|
|
|
class Flatbuffers < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "Serialization library for C++, supporting Java, C#, and Go"
|
2015-02-05 04:58:41 +00:00
|
|
|
homepage "https://google.github.io/flatbuffers"
|
|
|
|
url "https://github.com/google/flatbuffers/archive/v1.0.3.tar.gz"
|
|
|
|
sha1 "8daba5be5436b7cb99f1883e3eb7f1c5da52d6b9"
|
|
|
|
|
2015-02-05 05:15:15 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any
|
|
|
|
sha1 "2a82aec99c3b5ab9cd643dc7c6d2f88cfe953cce" => :yosemite
|
|
|
|
sha1 "a7222fe66033ca2749241e4d253534b3540b1e7c" => :mavericks
|
|
|
|
sha1 "d0de7bdea3b5fd43fddcfe20b857e4ec803a73f2" => :mountain_lion
|
|
|
|
end
|
|
|
|
|
2015-05-16 01:51:21 +00:00
|
|
|
head "https://github.com/google/flatbuffers.git"
|
|
|
|
|
2015-02-05 04:58:41 +00:00
|
|
|
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 "flatc", "-c", "-b", "test.fbs", "test.json"
|
|
|
|
end
|
|
|
|
end
|