11class Libogg < Formula
22 desc "Ogg Bitstream Library"
33 homepage "https://www.xiph.org/ogg/"
4- url "https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.5 .tar.gz"
5- mirror "https://github.com/xiph/ogg/releases/download/v1.3.5 /libogg-1.3.5 .tar.gz"
6- sha256 "0eb4b4b9420a0f51db142ba3f9c64b333f826532dc0f48c6410ae51f4799b664 "
4+ url "https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.6 .tar.gz"
5+ mirror "https://github.com/xiph/ogg/releases/download/v1.3.6 /libogg-1.3.6 .tar.gz"
6+ sha256 "83e6704730683d004d20e21b8f7f55dcb3383cdf84c0daedf30bde175f774638 "
77 license "BSD-3-Clause"
88 head "https://gitlab.xiph.org/xiph/ogg.git" , branch : "master"
99
@@ -31,21 +31,22 @@ class Libogg < Formula
3131
3232 depends_on "cmake" => :build
3333
34- resource ( "oggfile" ) do
35- url "https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg"
36- sha256 "f57b56d8aae4c847cf01224fb45293610d801cfdac43d932b5eeab1cd318182a"
37- end
38-
3934 def install
4035 system "cmake" , "-S" , "." , "-B" , "build" , "-DBUILD_SHARED_LIBS=TRUE" , *std_cmake_args
4136 system "cmake" , "--build" , "build"
4237 system "cmake" , "--install" , "build"
38+
4339 system "cmake" , "-S" , "." , "-B" , "build-static" , "-DBUILD_SHARED_LIBS=FALSE" , *std_cmake_args
4440 system "cmake" , "--build" , "build-static"
4541 lib . install "build-static/libogg.a"
4642 end
4743
4844 test do
45+ resource "oggfile" do
46+ url "https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg"
47+ sha256 "f57b56d8aae4c847cf01224fb45293610d801cfdac43d932b5eeab1cd318182a"
48+ end
49+
4950 ( testpath /"test.c" ) . write <<~C
5051 #include <ogg/ogg.h>
5152 #include <stdio.h>
@@ -59,9 +60,14 @@ def install
5960 int bytes;
6061
6162 ogg_sync_init (&oy);
62- buffer = ogg_sync_buffer (&oy, 4096);
63- bytes = fread(buffer, 1, 4096, stdin);
64- ogg_sync_wrote (&oy, bytes);
63+
64+ // Read all available input to avoid broken pipe
65+ do {
66+ buffer = ogg_sync_buffer (&oy, 4096);
67+ bytes = fread(buffer, 1, 4096, stdin);
68+ ogg_sync_wrote (&oy, bytes);
69+ } while (bytes == 4096);
70+
6571 if (ogg_sync_pageout (&oy, &og) != 1)
6672 return 1;
6773 ogg_stream_init (&os, ogg_page_serialno (&og));
@@ -76,9 +82,11 @@ def install
7682 testpath . install resource ( "oggfile" )
7783 system ENV . cc , "test.c" , "-I#{ include } " , "-L#{ lib } " , "-logg" ,
7884 "-o" , "test"
85+
7986 # Should work on an OGG file
80- shell_output ( "./test < Example.ogg" )
87+ pipe_output ( "./test" , ( testpath /"Example.ogg" ) . read , 0 )
88+
8189 # Expected to fail on a non-OGG file
82- shell_output ( "./test < #{ test_fixtures ( "test.wav" ) } " , 1 )
90+ pipe_output ( "./test" , test_fixtures ( "test.wav" ) . read , 1 )
8391 end
8492end
0 commit comments