| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 | class Flatbuffers < Formula
  homepage "https://google.github.io/flatbuffers"
  url "https://github.com/google/flatbuffers/archive/v1.0.3.tar.gz"
  sha1 "8daba5be5436b7cb99f1883e3eb7f1c5da52d6b9"
  bottle do
    cellar :any
    sha1 "2a82aec99c3b5ab9cd643dc7c6d2f88cfe953cce" => :yosemite
    sha1 "a7222fe66033ca2749241e4d253534b3540b1e7c" => :mavericks
    sha1 "d0de7bdea3b5fd43fddcfe20b857e4ec803a73f2" => :mountain_lion
  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 "flatc", "-c", "-b", "test.fbs", "test.json"
  end
end
 |