134 lines
4.8 KiB
Ruby
134 lines
4.8 KiB
Ruby
class Mavsdk < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
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: "v1.4.4",
|
|
revision: "8b974d8df8fe3cec60ec14c5d9380c8984b6813e"
|
|
license "BSD-3-Clause"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "5aa08d40b5ef46b7216c436201f195cac1a0bad817cb54260623023e59f152d1"
|
|
sha256 cellar: :any, arm64_big_sur: "6c6377dfeefb7de5ff42b64b60a80a5855abadc893c38cc5071afc2f9051284c"
|
|
sha256 cellar: :any, monterey: "780f725ea8c022fd1b7536cc11a519711df390c6177b41241119fe0d3c9895dd"
|
|
sha256 cellar: :any, big_sur: "f86d329776bdb7c70a26d1ffdec2ae1c1b04131760d93b9025c485bf4fac0c08"
|
|
sha256 cellar: :any, catalina: "25a5f566b4729aa1e4e9b9e07f0c5d3c85bc1ec191d6393617cd9494e9b2d6c7"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "a3d62255c66092bc1d2ffbb9b50c4b076f04f1afd46e1463bcd4bc7cdac6430c"
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "python@3.9" => :build
|
|
depends_on "six" => :build
|
|
depends_on "abseil"
|
|
depends_on "c-ares"
|
|
depends_on "curl"
|
|
depends_on "grpc"
|
|
depends_on "jsoncpp"
|
|
depends_on "openssl@1.1"
|
|
depends_on "protobuf"
|
|
depends_on "re2"
|
|
depends_on "tinyxml2"
|
|
|
|
uses_from_macos "zlib"
|
|
|
|
on_macos do
|
|
depends_on "llvm" if DevelopmentTools.clang_build_version <= 1100
|
|
end
|
|
|
|
on_linux do
|
|
depends_on "gcc"
|
|
end
|
|
|
|
fails_with :clang do
|
|
build 1100
|
|
cause <<-EOS
|
|
Undefined symbols for architecture x86_64:
|
|
"std::__1::__fs::filesystem::__status(std::__1::__fs::filesystem::path const&, std::__1::error_code*)"
|
|
EOS
|
|
end
|
|
|
|
fails_with gcc: "5"
|
|
|
|
# To update the resources, use homebrew-pypi-poet on the PyPI package `protoc-gen-mavsdk`.
|
|
# These resources are needed to install protoc-gen-mavsdk, which we use to regenerate protobuf headers.
|
|
# This is needed when brewed protobuf is newer than upstream's vendored protobuf.
|
|
resource "future" do
|
|
url "https://files.pythonhosted.org/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz"
|
|
sha256 "b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"
|
|
end
|
|
|
|
resource "Jinja2" do
|
|
url "https://files.pythonhosted.org/packages/7a/ff/75c28576a1d900e87eb6335b063fab47a8ef3c8b4d88524c4bf78f670cce/Jinja2-3.1.2.tar.gz"
|
|
sha256 "31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"
|
|
end
|
|
|
|
resource "MarkupSafe" do
|
|
url "https://files.pythonhosted.org/packages/1d/97/2288fe498044284f39ab8950703e88abbac2abbdf65524d576157af70556/MarkupSafe-2.1.1.tar.gz"
|
|
sha256 "7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b"
|
|
end
|
|
|
|
def install
|
|
# Fix version being reported as `v#{version}-dirty`
|
|
inreplace "CMakeLists.txt", "OUTPUT_VARIABLE VERSION_STR", "OUTPUT_VARIABLE VERSION_STR_IGNORED"
|
|
|
|
ENV.llvm_clang if OS.mac? && (DevelopmentTools.clang_build_version <= 1100)
|
|
|
|
# Install protoc-gen-mavsdk deps
|
|
venv_dir = buildpath/"bootstrap"
|
|
venv = virtualenv_create(venv_dir, "python3")
|
|
venv.pip_install resources
|
|
|
|
# Install protoc-gen-mavsdk
|
|
venv.pip_install "proto/pb_plugins"
|
|
|
|
# Run generator script in an emulated virtual env.
|
|
with_env(
|
|
VIRTUAL_ENV: venv_dir,
|
|
PATH: "#{venv_dir}/bin:#{ENV["PATH"]}",
|
|
) do
|
|
system "tools/generate_from_protos.sh"
|
|
|
|
# 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",
|
|
"-DVERSION_STR=v#{version}-#{tap.user}",
|
|
"-DCMAKE_INSTALL_RPATH=#{rpath}",
|
|
"-H."
|
|
end
|
|
system "cmake", "--build", "build/default"
|
|
system "cmake", "--build", "build/default", "--target", "install"
|
|
end
|
|
|
|
test do
|
|
# Force use of Clang on Mojave
|
|
ENV.clang if OS.mac?
|
|
|
|
(testpath/"test.cpp").write <<~EOS
|
|
#include <iostream>
|
|
#include <mavsdk/mavsdk.h>
|
|
int main() {
|
|
mavsdk::Mavsdk mavsdk;
|
|
std::cout << mavsdk.version() << std::endl;
|
|
return 0;
|
|
}
|
|
EOS
|
|
system ENV.cxx, "-std=c++17", testpath/"test.cpp", "-o", "test",
|
|
"-I#{include}", "-L#{lib}", "-lmavsdk"
|
|
assert_match "v#{version}-#{tap.user}", shell_output("./test").chomp
|
|
|
|
assert_equal "Usage: #{bin}/mavsdk_server [Options] [Connection URL]",
|
|
shell_output("#{bin}/mavsdk_server --help").split("\n").first
|
|
end
|
|
end
|