<commit_before>class Glui < Formula
  desc "C++ user interface library"
  homepage "https://glui.sourceforge.io/"
  url "https://github.com/libglui/glui/archive/2.37.tar.gz"
  sha256 "f7f6983f7410fe8dfaa032b2b7b1aac2232ec6a400a142b73f680683dad795f8"
  license "Zlib"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "2436b9df6b4d25bcd4734c5257ad4388fe4b9591396f155e6dd7d716093d8836"
    sha256 cellar: :any_skip_relocation, big_sur:       "e0e6490b5f5044282ef8769a9702597667dfc5bfc72331790deeac6997116d6d"
    sha256 cellar: :any_skip_relocation, catalina:      "a9e404e892ccdf44f28504a433b598a08533290486189bc4a707b3e333dd3950"
    sha256 cellar: :any_skip_relocation, mojave:        "24c323dbaa5f6f1b01fbf8f837c379ef503d323a448d2bb3d673c31ced622f0d"
    sha256 cellar: :any_skip_relocation, high_sierra:   "7cd9b9d6bffa3b6b6ff806c4041f495d5a7ef40296cb50097db25d17eb616265"
    sha256 cellar: :any_skip_relocation, sierra:        "c087de27b46b86a14d583904e0a9d293428af37d8710b521ae7aeeb5174fc8fd"
  end

  # Fix compiler warnings in glui.h. Merged into master on November 28, 2016.
  patch do
    url "https://github.com/libglui/glui/commit/fc9ad76733034605872a0d1323bb19cbc23d87bf.patch?full_index=1"
    sha256 "b1afada854f920692ab7cb6b6292034f3488936c4332e3e996798ee494a3fdd7"
  end

  def install
    system "make", "setup"
    system "make", "lib/libglui.a"
    lib.install "lib/libglui.a"
    include.install "include/GL"
  end

  test do
    (testpath/"test.cpp").write <<~EOS
      #include <cassert>
      #include <GL/glui.h>
      int main() {
        GLUI *glui = GLUI_Master.create_glui("GLUI");
        assert(glui != nullptr);
        return 0;
      }
    EOS
    system ENV.cxx, "-framework", "GLUT", "-framework", "OpenGL", "-I#{include}",
      "-L#{lib}", "-lglui", "-std=c++11", "test.cpp"
    system "./a.out"
  end
end
<commit_msg>glui: upstream Linux fix (#74535)<commit_after>class Glui < Formula
  desc "C++ user interface library"
  homepage "https://glui.sourceforge.io/"
  url "https://github.com/libglui/glui/archive/2.37.tar.gz"
  sha256 "f7f6983f7410fe8dfaa032b2b7b1aac2232ec6a400a142b73f680683dad795f8"
  license "Zlib"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "2436b9df6b4d25bcd4734c5257ad4388fe4b9591396f155e6dd7d716093d8836"
    sha256 cellar: :any_skip_relocation, big_sur:       "e0e6490b5f5044282ef8769a9702597667dfc5bfc72331790deeac6997116d6d"
    sha256 cellar: :any_skip_relocation, catalina:      "a9e404e892ccdf44f28504a433b598a08533290486189bc4a707b3e333dd3950"
    sha256 cellar: :any_skip_relocation, mojave:        "24c323dbaa5f6f1b01fbf8f837c379ef503d323a448d2bb3d673c31ced622f0d"
    sha256 cellar: :any_skip_relocation, high_sierra:   "7cd9b9d6bffa3b6b6ff806c4041f495d5a7ef40296cb50097db25d17eb616265"
    sha256 cellar: :any_skip_relocation, sierra:        "c087de27b46b86a14d583904e0a9d293428af37d8710b521ae7aeeb5174fc8fd"
  end

  on_linux do
    depends_on "freeglut"
    depends_on "mesa"
    depends_on "mesa-glu"
  end

  # Fix compiler warnings in glui.h. Merged into master on November 28, 2016.
  patch do
    url "https://github.com/libglui/glui/commit/fc9ad76733034605872a0d1323bb19cbc23d87bf.patch?full_index=1"
    sha256 "b1afada854f920692ab7cb6b6292034f3488936c4332e3e996798ee494a3fdd7"
  end

  def install
    system "make", "setup"
    system "make", "lib/libglui.a"
    lib.install "lib/libglui.a"
    include.install "include/GL"
  end

  test do
    on_macos do
      (testpath/"test.cpp").write <<~EOS
        #include <cassert>
        #include <GL/glui.h>
        int main() {
          GLUI *glui = GLUI_Master.create_glui("GLUI");
          assert(glui != nullptr);
          return 0;
        }
      EOS
      system ENV.cxx, "-framework", "GLUT", "-framework", "OpenGL", "-I#{include}",
        "-L#{lib}", "-lglui", "-std=c++11", "test.cpp"
      system "./a.out"
    end

    on_linux do
      (testpath/"test.cpp").write <<~EOS
        #include <cassert>
        #include <GL/glui.h>
        #include <GL/glut.h>
        int main(int argc, char **argv) {
          glutInit(&argc, argv);
          GLUI *glui = GLUI_Master.create_glui("GLUI");
          assert(glui != nullptr);
          return 0;
        }
      EOS
      system ENV.cxx, "-I#{include}", "-std=c++11", "test.cpp",
        "-L#{lib}", "-lglui", "-lglut", "-lGLU", "-lGL"
      if ENV["DISPLAY"]
        # Fails without X display: freeglut (./a.out): failed to open display ''
        system "./a.out"
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.11280353200883002, 'fraction_numerical': 0.17660044150110377, 'mean_word_length': 3.6046747967479673, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 10, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2829217', 'n_tokens_mistral': 2325, 'n_tokens_neox': 1895, 'n_words': 295}