58 lines
2.2 KiB
Ruby
58 lines
2.2 KiB
Ruby
class NanopbGenerator < Formula
|
|
desc "C library for encoding and decoding Protocol Buffer messages"
|
|
homepage "https://jpa.kapsi.fi/nanopb/docs/index.html"
|
|
url "https://jpa.kapsi.fi/nanopb/download/nanopb-0.3.9.tar.gz"
|
|
sha256 "f6fe05441150bf158c2adfec29fa8206785bbb6c3dcd4a3ddbafcf8f9ad9f251"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "030d054005b5167d327d8cd95df7e04a8bfdc66dd2354890babafa11c197a18e" => :high_sierra
|
|
sha256 "030d054005b5167d327d8cd95df7e04a8bfdc66dd2354890babafa11c197a18e" => :sierra
|
|
sha256 "a5f6e9fab63d0ecf3f7f52f1191ff16b7e01d2de063b9163462e4d5a49082b00" => :el_capitan
|
|
end
|
|
|
|
depends_on "python" if MacOS.version <= :snow_leopard
|
|
depends_on "protobuf"
|
|
|
|
resource "protobuf-python" do
|
|
url "https://files.pythonhosted.org/packages/14/3e/56da1ecfa58f6da0053a523444dff9dfb8a18928c186ad529a24b0e82dec/protobuf-3.0.0.tar.gz"
|
|
sha256 "ecc40bc30f1183b418fe0ec0c90bc3b53fa1707c4205ee278c6b90479e5b6ff5"
|
|
end
|
|
|
|
resource "six" do
|
|
url "https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz"
|
|
sha256 "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a"
|
|
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 <<~EOS
|
|
syntax = "proto2";
|
|
|
|
message Test {
|
|
required string test_field = 1;
|
|
}
|
|
EOS
|
|
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
|