51 lines
1.5 KiB
Ruby
51 lines
1.5 KiB
Ruby
class NanopbGenerator < Formula
|
|
include Language::Python::Shebang
|
|
|
|
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.4.7.tar.gz"
|
|
sha256 "87055a0d9a99a95429a95497e566e59d8d16103cfd90b7b6e8ee364b6559666a"
|
|
license "Zlib"
|
|
|
|
livecheck do
|
|
url "https://jpa.kapsi.fi/nanopb/download/"
|
|
regex(/href=.*?nanopb[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, all: "8fa99a6f2d8fbb4fc69952cc533309c554578f983f5413d882bd86d9ddef37b7"
|
|
end
|
|
|
|
depends_on "protobuf"
|
|
depends_on "python@3.11"
|
|
|
|
conflicts_with "mesos",
|
|
because: "they depend on an incompatible version of protobuf"
|
|
|
|
def install
|
|
cd "generator" do
|
|
system "make", "-C", "proto"
|
|
rewrite_shebang detected_python_shebang, "nanopb_generator.py"
|
|
libexec.install "nanopb_generator.py", "protoc-gen-nanopb", "proto"
|
|
bin.install_symlink libexec/"protoc-gen-nanopb", libexec/"nanopb_generator.py"
|
|
rewrite_shebang detected_python_shebang, libexec/"protoc-gen-nanopb"
|
|
end
|
|
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", testpath/"test.pb.c"
|
|
system "grep", "Test", testpath/"test.pb.h"
|
|
end
|
|
end
|