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"
|
2015-06-13 15:18:20 +00:00
|
|
|
url "https://github.com/google/flatbuffers/archive/v1.1.0.tar.gz"
|
|
|
|
sha1 "c9324d5e3e27e97d2e8883dccd02e18ca4057890"
|
2015-02-05 04:58:41 +00:00
|
|
|
|
2015-02-05 05:15:15 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any
|
2015-06-13 15:32:28 +00:00
|
|
|
sha256 "b5722008fa44851f7a4005d757b40bf2583e8eb8b1861e4bf7f6f21497e66b57" => :yosemite
|
|
|
|
sha256 "6f31e9e4cb05aa895ed19562b959c7f736c4688277debb6e5cf8f3f29670a5fd" => :mavericks
|
|
|
|
sha256 "ddbf240d9fe9307f82812ac6872899c89d741bb27a2aed54efa3826aea95973f" => :mountain_lion
|
2015-02-05 05:15:15 +00:00
|
|
|
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
|