-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
/
Copy pathutf8cpp.rb
41 lines (35 loc) · 1.32 KB
/
utf8cpp.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Utf8cpp < Formula
desc "UTF-8 with C++ in a Portable Way"
homepage "https://github.com/nemtrif/utfcpp"
url "https://github.com/nemtrif/utfcpp/archive/refs/tags/v4.0.6.tar.gz"
sha256 "6920a6a5d6a04b9a89b2a89af7132f8acefd46e0c2a7b190350539e9213816c0"
license "BSL-1.0"
bottle do
sha256 cellar: :any_skip_relocation, all: "bd37e8f689dc81593f8c8be6e074b4c97f4cd0f0881ee9c9735cb6d75a2f603e"
end
depends_on "cmake" => [:build, :test]
def install
system "cmake", "-S", ".", "-B", "build", *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
test do
(testpath/"CMakeLists.txt").write <<~CMAKE
cmake_minimum_required(VERSION 4.0 FATAL_ERROR)
project(utf8_append LANGUAGES CXX)
find_package(utf8cpp REQUIRED CONFIG)
add_executable(utf8_append utf8_append.cpp)
CMAKE
(testpath/"utf8_append.cpp").write <<~CPP
#include <utf8cpp/utf8.h>
int main() {
unsigned char u[5] = {0, 0, 0, 0, 0};
utf8::append(0x0448, u);
return (u[0] == 0xd1 && u[1] == 0x88 && u[2] == 0 && u[3] == 0 && u[4] == 0) ? 0 : 1;
}
CPP
system "cmake", "-S", ".", "-B", "build", "-DCMAKE_PREFIX_PATH=#{opt_lib}", "-DCMAKE_VERBOSE_MAKEFILE=ON"
system "cmake", "--build", "build"
system "./build/utf8_append"
end
end