homebrew-core/Formula/arduino-cli.rb

51 lines
1.8 KiB
Ruby

class ArduinoCli < Formula
desc "Arduino command-line interface"
homepage "https://github.com/arduino/arduino-cli"
url "https://github.com/arduino/arduino-cli.git",
tag: "0.12.1",
revision: "48383dad5e53f155beff1178742ed5e2ea810c5f"
license "GPL-3.0"
head "https://github.com/arduino/arduino-cli.git"
livecheck do
url :head
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
cellar :any_skip_relocation
sha256 "cee001376951036fc6dba3ca7d5988846074a57d8992c3e600485d8c69d13d48" => :catalina
sha256 "52278e7dd0a3522c6f21a60694f61c60b0a65ba190ca1c7fcf91666d38cef8f5" => :mojave
sha256 "ee42928545a41658b9ba6d0fc01c936121cd0fd58c0bfa3b510daad2c5a47d9b" => :high_sierra
end
depends_on "go" => :build
def install
commit = Utils.safe_popen_read("git", "rev-parse", "HEAD").chomp
ldflags = %W[
-s -w
-X github.com/arduino/arduino-cli/version.versionString=#{version}
-X github.com/arduino/arduino-cli/version.commit=#{commit}
]
system "go", "build", *std_go_args, "-ldflags", ldflags.join(" ")
output = Utils.safe_popen_read({ "SHELL" => "bash" }, "#{bin}/arduino-cli", "completion", "bash")
(bash_completion/"arduino-cli").write output
output = Utils.safe_popen_read({ "SHELL" => "zsh" }, "#{bin}/arduino-cli", "completion", "zsh")
(zsh_completion/"_arduino-cli").write output
output = Utils.safe_popen_read({ "SHELL" => "fish" }, "#{bin}/arduino-cli", "completion", "fish")
(fish_completion/"arduino-cli.fish").write output
end
test do
system "#{bin}/arduino-cli", "sketch", "new", "test_sketch"
assert File.directory?("#{testpath}/test_sketch")
version_output = shell_output("#{bin}/arduino-cli version 2>&1")
assert_match "arduino-cli Version: #{version}", version_output
end
end