homebrew-core/Formula/flatbuffers.rb

72 lines
1.6 KiB
Ruby
Raw Normal View History

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.1.0.tar.gz"
sha1 "c9324d5e3e27e97d2e8883dccd02e18ca4057890"
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
head "https://github.com/google/flatbuffers.git"
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