homebrew-core/Formula/magic_enum.rb

42 lines
1.1 KiB
Ruby

class MagicEnum < Formula
desc "Static reflection for enums (to string, from string, iteration) for modern C++"
homepage "https://github.com/Neargye/magic_enum"
url "https://github.com/Neargye/magic_enum/archive/v0.8.2.tar.gz"
sha256 "62bd7034bbbfc3d7806001767d5775ab42f3ff33bb38366e1ceb21102f0dff9a"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, all: "db14fda773775cba338ac65b391fc7af1afb1c3771aefdc471f6f201f708bd2c"
end
depends_on "cmake" => :build
fails_with gcc: "5" # C++17
def install
system "cmake", ".", *std_cmake_args
system "make", "install"
system "./test/test-cpp17"
system "./test/test-cpp17"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <iostream>
#include <magic_enum.hpp>
enum class Color : int { RED = -10, BLUE = 0, GREEN = 10 };
int main() {
Color c1 = Color::RED;
auto c1_name = magic_enum::enum_name(c1);
std::cout << c1_name << std::endl;
return 0;
}
EOS
system ENV.cxx, "test.cpp", "-I#{include}", "-std=c++17", "-o", "test"
assert_equal "RED\n", shell_output(testpath/"test")
end
end