|
| 1 | +class Libunistring < Formula |
| 2 | + desc "C string library for manipulating Unicode strings" |
| 3 | + homepage "https://www.gnu.org/software/libunistring/" |
| 4 | + url "https://ftp.gnu.org/gnu/libunistring/libunistring-1.2.tar.gz" |
| 5 | + mirror "https://ftpmirror.gnu.org/libunistring/libunistring-1.2.tar.gz" |
| 6 | + mirror "http://ftp.gnu.org/gnu/libunistring/libunistring-1.2.tar.gz" |
| 7 | + sha256 "fd6d5662fa706487c48349a758b57bc149ce94ec6c30624ec9fdc473ceabbc8e" |
| 8 | + license any_of: ["GPL-2.0-only", "LGPL-3.0-or-later"] |
| 9 | + |
| 10 | + bottle do |
| 11 | + root_url "https://github.com/gromgit/homebrew-core-aarch64_linux/releases/download/libunistring-1.2" |
| 12 | + sha256 cellar: :any_skip_relocation, aarch64_linux: "271b35c0744b9cb30c0c24074b37bbf541d9e88286dd31853d8653becb6cdea7" |
| 13 | + end |
| 14 | + |
| 15 | + def install |
| 16 | + system "./configure", "--disable-dependency-tracking", |
| 17 | + "--disable-silent-rules", |
| 18 | + "--prefix=#{prefix}" |
| 19 | + system "make" |
| 20 | + system "make", "check" if !OS.mac? || MacOS.version < :sonoma |
| 21 | + system "make", "install" |
| 22 | + end |
| 23 | + |
| 24 | + test do |
| 25 | + (testpath/"test.c").write <<~EOS |
| 26 | + #include <uniname.h> |
| 27 | + #include <unistdio.h> |
| 28 | + #include <unistr.h> |
| 29 | + #include <stdlib.h> |
| 30 | + int main (void) { |
| 31 | + uint32_t s[2] = {}; |
| 32 | + uint8_t buff[12] = {}; |
| 33 | + if (u32_uctomb (s, unicode_name_character ("BEER MUG"), sizeof s) != 1) abort(); |
| 34 | + if (u8_sprintf (buff, "%llU", s) != 4) abort(); |
| 35 | + printf ("%s\\n", buff); |
| 36 | + return 0; |
| 37 | + } |
| 38 | + EOS |
| 39 | + system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lunistring", |
| 40 | + "-o", "test" |
| 41 | + assert_equal "🍺", shell_output("./test").chomp |
| 42 | + end |
| 43 | +end |
0 commit comments