diff options
| author | Jiayong Ou | 2014-04-16 17:51:40 +0200 |
|---|---|---|
| committer | Adam Vandenberg | 2014-05-27 21:25:24 -0700 |
| commit | 10c93386dc73d4e3a2f06059db7d2e910df8b0fe (patch) | |
| tree | f096d7d50397c1e66b8424e7d70804f26fc5b8a7 | |
| parent | 95698e62485cb18ff6bd51a53f9523f7f16a60e0 (diff) | |
| download | homebrew-10c93386dc73d4e3a2f06059db7d2e910df8b0fe.tar.bz2 | |
nanopb-generator 0.2.7
Closes #28449
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
| -rw-r--r-- | Library/Formula/nanopb-generator.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Library/Formula/nanopb-generator.rb b/Library/Formula/nanopb-generator.rb new file mode 100644 index 000000000..15922ba53 --- /dev/null +++ b/Library/Formula/nanopb-generator.rb @@ -0,0 +1,44 @@ +require "formula" + +class NanopbGenerator < Formula + homepage "http://koti.kapsi.fi/jpa/nanopb/docs/index.html" + url "http://koti.kapsi.fi/~jpa/nanopb/download/nanopb-0.2.7.tar.gz" + sha1 "7dce0b9e1f9e5d0614697a8ea1678cee76f14858" + + depends_on :python + depends_on "protobuf" + + resource "protobuf-python" do + url "https://pypi.python.org/packages/source/p/protobuf/protobuf-2.5.0.tar.gz" + sha1 "1a6028d113484089edbde95900b6d9467160cc41" + end + + def install + ENV.prepend_create_path "PYTHONPATH", libexec+"lib/python2.7/site-packages" + resource("protobuf-python").stage do + system "python", "setup.py", "install", "--prefix=#{libexec}" + end + + Dir.chdir "generator" + + system "make", "-C", "proto" + + libexec.install "nanopb_generator.py", "protoc-gen-nanopb", "proto" + + (bin/"protoc-gen-nanopb").write_env_script libexec/"protoc-gen-nanopb", :PYTHONPATH => ENV["PYTHONPATH"] + (bin/"nanopb_generator").write_env_script libexec/"nanopb_generator.py", :PYTHONPATH => ENV["PYTHONPATH"] + end + + test do + (testpath/"test.proto").write <<-PROTO.undent + message Test { + required string test_field = 1; + } + PROTO + system Formula["protobuf"].bin/"protoc", + "--proto_path=#{testpath}", "--plugin=#{bin/"protoc-gen-nanopb"}", + "--nanopb_out=#{testpath}", testpath/"test.proto" + system "grep", "test_field", testpath/"test.pb.c" + system "grep", "test_field", testpath/"test.pb.h" + end +end |
