Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes Homebrew/legacy-homebrew#36544. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
- Loading branch information
1 parent
9186a8d
commit 8594b51
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
class Flatbuffers < Formula | ||
homepage "https://google.github.io/flatbuffers" | ||
url "https://github.com/google/flatbuffers/archive/v1.0.3.tar.gz" | ||
sha1 "8daba5be5436b7cb99f1883e3eb7f1c5da52d6b9" | ||
|
||
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 |