<commit_before>class Ldc < Formula
  desc "Portable D programming language compiler"
  homepage "https://wiki.dlang.org/LDC"
  url "https://github.com/ldc-developers/ldc/releases/download/v1.28.1/ldc-1.28.1-src.tar.gz"
  sha256 "654958bca5378cd97819f2ef61d3f220aa652a9d2b5ff41d6f2109302ae6eb94"
  license "BSD-3-Clause"
  head "https://github.com/ldc-developers/ldc.git", branch: "master"

  livecheck do
    url :stable
    strategy :github_latest
  end

  bottle do
    sha256 arm64_monterey: "716c816c0e9599d2785c50ac887daca2a29184dce695eb8100184e9ad2277765"
    sha256 arm64_big_sur:  "637e28ca77d0059fe71e27a17b59711506864e8f4dd25646399360591ce3dc03"
    sha256 monterey:       "671129d1f9e69ccaf59a66a4eba24f512f9d1ff1c64cf487d954529387a4e3ab"
    sha256 big_sur:        "c6adc7612c0430fbae0e9d225bf72117b9ebbb90756abcd532b78f9cca7eca10"
    sha256 catalina:       "d6f48b47db93110623ef08a5d0d8605d1655b6c2740013af47f6968fe0288272"
    sha256 x86_64_linux:   "fc18d517eff72ab724b4ce8e4a5d47a41cb4f5047592cd2a8fe1c25f9b4a9af4"
  end

  depends_on "cmake" => :build
  depends_on "libconfig" => :build
  depends_on "pkg-config" => :build

  uses_from_macos "libxml2" => :build
  # CompilerSelectionError: ldc cannot be built with any available compilers.
  uses_from_macos "llvm" => [:build, :test]

  on_macos do
    depends_on "llvm"
  end

  on_linux do
    # When built with LLVM, errors with:
    # undefined reference to `std::__throw_bad_array_new_length()'
    depends_on "llvm@12"
  end

  fails_with :gcc

  resource "ldc-bootstrap" do
    on_macos do
      if Hardware::CPU.intel?
        url "https://github.com/ldc-developers/ldc/releases/download/v1.28.0/ldc2-1.28.0-osx-x86_64.tar.xz"
        sha256 "02472507de988c8b5dd83b189c6df3b474741546589496c2ff3d673f26b8d09a"
      else
        url "https://github.com/ldc-developers/ldc/releases/download/v1.28.0/ldc2-1.28.0-osx-arm64.tar.xz"
        sha256 "f9786b8c28d8af1fdd331d8eb889add80285dbebfb97ea47d5dd9110a7df074b"
      end
    end

    on_linux do
      # ldc 1.27 requires glibc 2.27, which is too new for Ubuntu 16.04 LTS.  The last version we can bootstrap with
      # is 1.26.  Change this when we migrate to Ubuntu 18.04 LTS.
      url "https://github.com/ldc-developers/ldc/releases/download/v1.26.0/ldc2-1.26.0-linux-x86_64.tar.xz"
      sha256 "06063a92ab2d6c6eebc10a4a9ed4bef3d0214abc9e314e0cd0546ee0b71b341e"
    end
  end

  def llvm<commit_msg>ldc: switch back to LLVM 12 on macOS<commit_after>class Ldc < Formula
  desc "Portable D programming language compiler"
  homepage "https://wiki.dlang.org/LDC"
  url "https://github.com/ldc-developers/ldc/releases/download/v1.28.1/ldc-1.28.1-src.tar.gz"
  sha256 "654958bca5378cd97819f2ef61d3f220aa652a9d2b5ff41d6f2109302ae6eb94"
  license "BSD-3-Clause"
  revision 1
  head "https://github.com/ldc-developers/ldc.git", branch: "master"

  livecheck do
    url :stable
    strategy :github_latest
  end

  bottle do
    sha256 arm64_monterey: "716c816c0e9599d2785c50ac887daca2a29184dce695eb8100184e9ad2277765"
    sha256 arm64_big_sur:  "637e28ca77d0059fe71e27a17b59711506864e8f4dd25646399360591ce3dc03"
    sha256 monterey:       "671129d1f9e69ccaf59a66a4eba24f512f9d1ff1c64cf487d954529387a4e3ab"
    sha256 big_sur:        "c6adc7612c0430fbae0e9d225bf72117b9ebbb90756abcd532b78f9cca7eca10"
    sha256 catalina:       "d6f48b47db93110623ef08a5d0d8605d1655b6c2740013af47f6968fe0288272"
    sha256 x86_64_linux:   "fc18d517eff72ab724b4ce8e4a5d47a41cb4f5047592cd2a8fe1c25f9b4a9af4"
  end

  depends_on "cmake" => :build
  depends_on "libconfig" => :build
  depends_on "pkg-config" => :build
  depends_on "llvm@12"

  uses_from_macos "libxml2" => :build
  # CompilerSelectionError: ldc cannot be built with any available compilers.
  uses_from_macos "llvm" => [:build, :test]

  fails_with :gcc

  resource "ldc-bootstrap" do
    on_macos do
      if Hardware::CPU.intel?
        url "https://github.com/ldc-developers/ldc/releases/download/v1.28.0/ldc2-1.28.0-osx-x86_64.tar.xz"
        sha256 "02472507de988c8b5dd83b189c6df3b474741546589496c2ff3d673f26b8d09a"
      else
        url "https://github.com/ldc-developers/ldc/releases/download/v1.28.0/ldc2-1.28.0-osx-arm64.tar.xz"
        sha256 "f9786b8c28d8af1fdd331d8eb889add80285dbebfb97ea47d5dd9110a7df074b"
      end
    end

    on_linux do
      # ldc 1.27 requires glibc 2.27, which is too new for Ubuntu 16.04 LTS.  The last version we can bootstrap with
      # is 1.26.  Change this when we migrate to Ubuntu 18.04 LTS.
      url "https://github.com/ldc-developers/ldc/releases/download/v1.26.0/ldc2-1.26.0-linux-x86_64.tar.xz"
      sha256 "06063a92ab2d6c6eebc10a4a9ed4bef3d0214abc9e314e0cd0546ee0b71b341e"
    end
  end

  def llvm
{'fraction_non_alphanumeric': 0.08834745762711864, 'fraction_numerical': 0.21419491525423728, 'mean_word_length': 4.022340425531915, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3339649', 'n_tokens_mistral': 2613, 'n_tokens_neox': 2087, 'n_words': 302}