homebrew-core/Formula/zxing-cpp.rb
2017-03-21 22:05:42 +01:00

64 lines
2.4 KiB
Ruby

class ZxingCpp < Formula
desc "C++ port of the ZXing barcode decoder"
homepage "https://github.com/zxing/zxing"
url "https://github.com/zxing/zxing/releases/download/zxing-2.3.0/ZXing-2.3.0.zip"
sha256 "a9b9c7e2cd61c7918dc5f8856c0f91665ab6a109c6cd30ce1795d09bf4baf9c4"
head "https://github.com/glassechidna/zxing-cpp.git"
bottle do
cellar :any_skip_relocation
sha256 "d7e4ad48851787a6a5d0b13909fc933cc23d3a84b6373537db376d2838ea75b8" => :sierra
sha256 "91fa0ff78f6bb7a12b708ac7d11976386fd74a7e472047697a90d8b9e8c652ee" => :el_capitan
sha256 "e63999fce9edc362a526881e0f40e6cb51d8df0a5f4d22e74f1675c7e344f59e" => :yosemite
end
depends_on "cmake" => :build
def install
if build.stable?
cd "cpp"
end
mkdir "build" do
system "cmake", "..", *std_cmake_args
system "make"
if build.stable?
lib.install "libzxing.a"
bin.install "zxing"
cd "../core/src/"
Dir.glob "./zxing/**/*.h" do |header|
(include/File.dirname(header)).install header
end
end
if build.head?
system "make", "install"
end
end
end
test do
path = testpath/"qr.png"
path.binwrite [
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x32,
0x01, 0x00, 0x00, 0x00, 0x00, 0x36, 0x44, 0xb5, 0x1c, 0x00, 0x00, 0x00,
0x73, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0x74, 0xc5, 0x01, 0x06, 0x04,
0x40, 0x08, 0x05, 0xd0, 0xe8, 0x00, 0x73, 0x95, 0x08, 0x60, 0xe8, 0xea,
0x31, 0x00, 0x4b, 0x57, 0x89, 0x00, 0x86, 0xbf, 0x2c, 0xd4, 0x60, 0x1f,
0x3c, 0xc2, 0x8f, 0xff, 0x3d, 0xc9, 0x82, 0xb8, 0x2f, 0xc8, 0xb1, 0x1a,
0xf3, 0x0e, 0xd1, 0xb9, 0xd4, 0xbb, 0xad, 0x67, 0x08, 0x5b, 0xf5, 0x49,
0xaa, 0xc4, 0x3d, 0x00, 0x06, 0xfa, 0x64, 0xf2, 0x4f, 0x8c, 0x23, 0x76,
0xd6, 0x98, 0xcc, 0x77, 0xf4, 0x60, 0xaf, 0x6b, 0x63, 0x65, 0xb6, 0x1a,
0x23, 0x97, 0xa3, 0x4f, 0x92, 0x73, 0x57, 0x5f, 0xd8, 0xe2, 0x36, 0x66,
0x95, 0xc0, 0xb3, 0xe5, 0x9a, 0x4b, 0x5e, 0x1b, 0x43, 0xae, 0x8f, 0x93,
0x54, 0x22, 0xfa, 0xef, 0x08, 0x84, 0x37, 0x00, 0x26, 0x09, 0xda, 0x71,
0x35, 0xe5, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
0xae, 0x42, 0x60, 0x82
].pack("C*")
assert_equal "Homebrew QR test\n", shell_output("#{bin}/zxing #{path}")
end
end