homebrew-core/Formula/mavsdk.rb

72 lines
2.2 KiB
Ruby

class Mavsdk < Formula
desc "API and library for MAVLink compatible systems written in C++17"
homepage "https://mavsdk.mavlink.io"
url "https://github.com/mavlink/MAVSDK.git",
tag: "v0.38.2",
revision: "be7640a45f956ea715f830b502ba172b951989c4"
license "BSD-3-Clause"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 arm64_big_sur: "71c6b73c8d4ce874f4a5c0460e6461784f682c63dac8258da13143ca81584fa6"
sha256 big_sur: "cbf78c8f108c8e8ceb9b27365e7fc981a36b50070bc5c24e43f4ecdd11b6ed3b"
sha256 catalina: "8c7d222ce525c5eb030947f61b8250906ff76a0e4f26503c2a80d5fa50155e4b"
end
depends_on "cmake" => :build
depends_on "abseil"
depends_on "c-ares"
depends_on "curl"
depends_on "grpc"
depends_on "jsoncpp"
depends_on macos: :catalina # Mojave libc++ is too old
depends_on "openssl@1.1"
depends_on "protobuf"
depends_on "re2"
depends_on "tinyxml2"
uses_from_macos "zlib"
def install
# Source build adapted from
# https://mavsdk.mavlink.io/develop/en/contributing/build.html
system "cmake", *std_cmake_args,
"-Bbuild/default",
"-DSUPERBUILD=OFF",
"-DBUILD_SHARED_LIBS=ON",
"-DBUILD_MAVSDK_SERVER=ON",
"-DBUILD_TESTS=OFF",
"-DCMAKE_INSTALL_RPATH=#{lib}",
"-H."
system "cmake", "--build", "build/default"
system "cmake", "--build", "build/default", "--target", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <mavsdk/mavsdk.h>
#include <mavsdk/plugins/info/info.h>
int main() {
mavsdk::Mavsdk mavsdk;
mavsdk.version();
mavsdk::System& system = mavsdk.system();
auto info = std::make_shared<mavsdk::Info>(system);
return 0;
}
EOS
system ENV.cxx, "-std=c++17", testpath/"test.cpp", "-o", "test",
"-I#{include}/mavsdk",
"-L#{lib}",
"-lmavsdk",
"-lmavsdk_info"
system "./test"
assert_equal "Usage: #{bin}/mavsdk_server [-h | --help]",
shell_output("#{bin}/mavsdk_server --help").split("\n").first
end
end