<commit_before># typed: false
# frozen_string_literal: true

module Superenv
  extend T::Sig

  class << self
    undef bin

    # @private
    def bin
      return unless DevelopmentTools.installed?

      (HOMEBREW_SHIMS_PATH/"mac/super").realpath
    end
  end

  alias x11? x11

  undef homebrew_extra_paths,
        homebrew_extra_pkg_config_paths, homebrew_extra_aclocal_paths,
        homebrew_extra_isystem_paths, homebrew_extra_library_paths,
        homebrew_extra_cmake_include_paths,
        homebrew_extra_cmake_library_paths,
        homebrew_extra_cmake_frameworks_paths,
        determine_cccfg

  def homebrew_extra_paths
    paths = []
    paths << MacOS::XQuartz.bin if x11?
    paths
  end

  # @private
  def homebrew_extra_pkg_config_paths
    paths = \
      ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
    paths << "#{MacOS::XQuartz.lib}/pkgconfig" << "#{MacOS::XQuartz.share}/pkgconfig" if x11?
    paths
  end

  def homebrew_extra_aclocal_paths
    paths = []
    paths << "#{MacOS::XQuartz.share}/aclocal" if x11?
    paths
  end

  # @private
  sig { returns(T::Boolean) }
  def libxml2_include_needed?
    return false if deps.any? { |d| d.name == "libxml2" }
    return false if Pathname("#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml").directory?

    true
  end

  def homebrew_extra_isystem_paths
    paths = []
    paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
    paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt?
    paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11?
    paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
    paths
  end

  def homebrew_extra_library_paths
    paths = []
    if compiler == :llvm_clang
      paths << "#{self["HOMEBREW_SDKROOT"]}/usr/lib"
      paths << Formula["llvm"].opt_lib.to_s
    end
    paths << MacOS::XQuartz.lib.to_s if x11?
    paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
    paths
  end

  def homebrew_extra_cmake_include_paths
    paths = []
    paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
    paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt?
    paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11?
    paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
    paths
  end

  def homebrew_extra_cmake_library_paths
    paths = []
    paths << MacOS::XQuartz.lib.to_s if x11?
    paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
    paths
  end

  def homebrew_extra_cmake_frameworks_paths
    paths = []
    paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks" if MacOS::Xcode.without_clt?
    paths
  end

  def determine_cccfg
    s = +""
    # Fix issue with sed barfing on unicode characters on Mountain Lion
    s << "s"
    # Fix issue with >= Mountain Lion apr-1-config having broken paths
    s << "a"
    s.freeze
  end

  # @private
  def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
    sdk = formula ? MacOS.sdk_for_formula(formula) : MacOS.sdk
    if MacOS.sdk_root_needed? || sdk&.source == :xcode
      Homebrew::Diagnostic.checks(:fatal_setup_build_environment_checks)
      self["HOMEBREW_SDKROOT"] = sdk.path

      self["HOMEBREW_DEVELOPER_DIR"] = if sdk.source == :xcode
        MacOS::Xcode.prefix
      else
        MacOS::CLT::PKG_PATH
      end
    else
      self["HOMEBREW_SDKROOT"] = nil
      self["HOMEBREW_DEVELOPER_DIR"] = nil
    end
    generic_setup_build_environment(
      formula: formula, cc: cc, build_bottle: build_bottle,<commit_msg>Library/Homebrew/extend/os/mac/extend/ENV/super.rb: obsolete HOMEBREW_CCCFG flag `s`<commit_after># typed: false
# frozen_string_literal: true

module Superenv
  extend T::Sig

  class << self
    undef bin

    # @private
    def bin
      return unless DevelopmentTools.installed?

      (HOMEBREW_SHIMS_PATH/"mac/super").realpath
    end
  end

  alias x11? x11

  undef homebrew_extra_paths,
        homebrew_extra_pkg_config_paths, homebrew_extra_aclocal_paths,
        homebrew_extra_isystem_paths, homebrew_extra_library_paths,
        homebrew_extra_cmake_include_paths,
        homebrew_extra_cmake_library_paths,
        homebrew_extra_cmake_frameworks_paths,
        determine_cccfg

  def homebrew_extra_paths
    paths = []
    paths << MacOS::XQuartz.bin if x11?
    paths
  end

  # @private
  def homebrew_extra_pkg_config_paths
    paths = \
      ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
    paths << "#{MacOS::XQuartz.lib}/pkgconfig" << "#{MacOS::XQuartz.share}/pkgconfig" if x11?
    paths
  end

  def homebrew_extra_aclocal_paths
    paths = []
    paths << "#{MacOS::XQuartz.share}/aclocal" if x11?
    paths
  end

  # @private
  sig { returns(T::Boolean) }
  def libxml2_include_needed?
    return false if deps.any? { |d| d.name == "libxml2" }
    return false if Pathname("#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml").directory?

    true
  end

  def homebrew_extra_isystem_paths
    paths = []
    paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
    paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt?
    paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11?
    paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
    paths
  end

  def homebrew_extra_library_paths
    paths = []
    if compiler == :llvm_clang
      paths << "#{self["HOMEBREW_SDKROOT"]}/usr/lib"
      paths << Formula["llvm"].opt_lib.to_s
    end
    paths << MacOS::XQuartz.lib.to_s if x11?
    paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
    paths
  end

  def homebrew_extra_cmake_include_paths
    paths = []
    paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
    paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt?
    paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11?
    paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
    paths
  end

  def homebrew_extra_cmake_library_paths
    paths = []
    paths << MacOS::XQuartz.lib.to_s if x11?
    paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
    paths
  end

  def homebrew_extra_cmake_frameworks_paths
    paths = []
    paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks" if MacOS::Xcode.without_clt?
    paths
  end

  def determine_cccfg
    s = +""
    # Fix issue with >= Mountain Lion apr-1-config having broken paths
    s << "a"
    s.freeze
  end

  # @private
  def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false)
    sdk = formula ? MacOS.sdk_for_formula(formula) : MacOS.sdk
    if MacOS.sdk_root_needed? || sdk&.source == :xcode
      Homebrew::Diagnostic.checks(:fatal_setup_build_environment_checks)
      self["HOMEBREW_SDKROOT"] = sdk.path

      self["HOMEBREW_DEVELOPER_DIR"] = if sdk.source == :xcode
        MacOS::Xcode.prefix
      else
        MacOS::CLT::PKG_PATH
      end
    else
      self["HOMEBREW_SDKROOT"] = nil
      self["HOMEBREW_DEVELOPER_DIR"] = nil
    end
    generic_setup_build_environment(
      formula: formula, cc: cc, build_bottle: build_bottle,
{'fraction_non_alphanumeric': 0.12312769738512312, 'fraction_numerical': 0.007362274689007363, 'mean_word_length': 3.7521109770808203, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4733737', 'n_tokens_mistral': 2919, 'n_tokens_neox': 2771, 'n_words': 462}