Module: SharedEnvExtension Private
- Extended by:
- T::Helpers
- Includes:
- CompilerConstants, OS::Linux::SharedEnvExtension, OS::Mac::SharedEnvExtension, Utils::Output::Mixin
- Included in:
- EnvActivation, Stdenv, Superenv
- Defined in:
- extend/ENV/shared.rb,
extend/ENV/shared.rbi
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Constant Summary
Constants included from CompilerConstants
CompilerConstants::COMPILERS, CompilerConstants::COMPILER_SYMBOL_MAP, CompilerConstants::GNU_GCC_REGEXP, CompilerConstants::GNU_GCC_VERSIONS
Instance Attribute Summary collapse
- #bottle_arch ⇒ String? readonly private
- #build_bottle ⇒ Boolean? readonly private
Instance Method Summary collapse
-
#[]=(key, value) ⇒ T.type_parameter(:U)
private
Overload to allow
PATHvalues. - #append(keys, value, separator = " ") ⇒ void private
- #append_path(key, path) ⇒ void private
- #append_to_cccfg(value) ⇒ void private
- #append_to_cflags(newflags) ⇒ void private
- #append_to_rustflags(rustflags) ⇒ void private
- #cc ⇒ String? private
- #cflags ⇒ String? private
-
#compiler ⇒ Symbol, String
private
Outputs the current compiler.
- #cppflags ⇒ String? private
- #cxx ⇒ String? private
- #cxxflags ⇒ String? private
- #effective_arch ⇒ Symbol private
- #fc ⇒ String? private
- #fcflags ⇒ String? private
- #fflags ⇒ String? private
- #fortran ⇒ void private
- #ldflags ⇒ String? private
- #make_jobs ⇒ Integer private
- #permit_arch_flags ⇒ void private
- #prepend(keys, value, separator = " ") ⇒ void private
- #prepend_create_path(key, path) ⇒ void private
-
#prepend_path(key, path) ⇒ void
private
Prepends a directory to
PATH. - #refurbish_args ⇒ void private
- #remove(keys, value) ⇒ void private
- #remove_cc_etc ⇒ Hash{String => String, nil} private
- #remove_from_cflags(val) ⇒ void private
- #setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false, debug_symbols: false) ⇒ void private
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
Methods included from OS::Mac::SharedEnvExtension
#no_fixup_chains_support?, #no_weak_imports_support?
Instance Attribute Details
#bottle_arch ⇒ String? (readonly)
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
43 44 45 |
# File 'extend/ENV/shared.rb', line 43 def bottle_arch @bottle_arch end |
#build_bottle ⇒ Boolean? (readonly)
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
40 41 42 |
# File 'extend/ENV/shared.rb', line 40 def build_bottle @build_bottle end |
Instance Method Details
#[]=(key, value) ⇒ T.type_parameter(:U)
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Overload to allow PATH values.
11 |
# File 'extend/ENV/shared.rbi', line 11 def []=(key, value); end |
#append(keys, value, separator = " ") ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
94 95 96 97 98 99 100 101 102 103 104 |
# File 'extend/ENV/shared.rb', line 94 def append(keys, value, separator = " ") value = value.to_s Array(keys).each do |key| old_value = self[key] self[key] = if old_value.blank? value else old_value + separator + value end end end |
#append_path(key, path) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
120 121 122 |
# File 'extend/ENV/shared.rb', line 120 def append_path(key, path) self[key] = PATH.new(self[key]).append(path) end |
#append_to_cccfg(value) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
89 90 91 |
# File 'extend/ENV/shared.rb', line 89 def append_to_cccfg(value) append("HOMEBREW_CCCFG", value, "") end |
#append_to_cflags(newflags) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
79 80 81 |
# File 'extend/ENV/shared.rb', line 79 def append_to_cflags(newflags) append(CC_FLAG_VARS, newflags) end |
#append_to_rustflags(rustflags) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
125 126 127 |
# File 'extend/ENV/shared.rb', line 125 def append_to_rustflags(rustflags) append("HOMEBREW_RUSTFLAGS", rustflags) end |
#cc ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
168 169 170 |
# File 'extend/ENV/shared.rb', line 168 def cc self["CC"] end |
#cflags ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
178 179 180 |
# File 'extend/ENV/shared.rb', line 178 def cflags self["CFLAGS"] end |
#compiler ⇒ Symbol, String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Outputs the current compiler.
# Do something only for the system clang
if ENV.compiler == :clang
# modify CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS in one go:
ENV.append_to_cflags "-I ./missing/includes"
end
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'extend/ENV/shared.rb', line 219 def compiler @compiler ||= T.let(nil, T.nilable(T.any(Symbol, String))) @compiler ||= if (cc = @cc) warn_about_non_apple_gcc(cc) if cc.match?(GNU_GCC_REGEXP) fetch_compiler(cc, "--cc") elsif (cc = homebrew_cc) warn_about_non_apple_gcc(cc) if cc.match?(GNU_GCC_REGEXP) compiler = fetch_compiler(cc, "HOMEBREW_CC") if @formula compilers = [compiler] + CompilerSelector.compilers compiler = CompilerSelector.select_for(@formula, compilers, testing_formula: @testing_formula == true) end compiler elsif @formula CompilerSelector.select_for(@formula, testing_formula: @testing_formula == true) else DevelopmentTools.default_compiler end end |
#cppflags ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
188 189 190 |
# File 'extend/ENV/shared.rb', line 188 def cppflags self["CPPFLAGS"] end |
#cxx ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
173 174 175 |
# File 'extend/ENV/shared.rb', line 173 def cxx self["CXX"] end |
#cxxflags ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
183 184 185 |
# File 'extend/ENV/shared.rb', line 183 def cxxflags self["CXXFLAGS"] end |
#effective_arch ⇒ Symbol
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
295 296 297 298 299 300 301 |
# File 'extend/ENV/shared.rb', line 295 def effective_arch if @build_bottle && @bottle_arch @bottle_arch.to_sym else Hardware.oldest_cpu end end |
#fc ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
198 199 200 |
# File 'extend/ENV/shared.rb', line 198 def fc self["FC"] end |
#fcflags ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
208 209 210 |
# File 'extend/ENV/shared.rb', line 208 def fcflags self["FCFLAGS"] end |
#fflags ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
203 204 205 |
# File 'extend/ENV/shared.rb', line 203 def fflags self["FFLAGS"] end |
#fortran ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'extend/ENV/shared.rb', line 264 def fortran # Ignore repeated calls to this function as it will misleadingly warn about # building with an alternative Fortran compiler without optimization flags, # despite it often being the Homebrew-provided one set up in the first call. return if @fortran_setup_done @fortran_setup_done = T.let(true, T.nilable(TrueClass)) flags = [] if fc opoo "Building with an unsupported Fortran compiler" self["F77"] ||= fc else if (gfortran = which("gfortran", (HOMEBREW_PREFIX/"bin").to_s)) ohai "Using Homebrew-provided Fortran compiler" elsif (gfortran = which("gfortran", PATH.new(ORIGINAL_PATHS))) ohai "Using a Fortran compiler found at #{gfortran}" end if gfortran puts "This may be changed by setting the `$FC` environment variable." self["FC"] = self["F77"] = gfortran flags = FC_FLAG_VARS end end flags.each { |key| self[key] = cflags } set_cpu_flags(flags) end |
#ldflags ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
193 194 195 |
# File 'extend/ENV/shared.rb', line 193 def ldflags self["LDFLAGS"] end |
#make_jobs ⇒ Integer
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
340 341 342 |
# File 'extend/ENV/shared.rb', line 340 def make_jobs Homebrew::EnvConfig.make_jobs.to_i end |
#permit_arch_flags ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
337 |
# File 'extend/ENV/shared.rb', line 337 def permit_arch_flags; end |
#prepend(keys, value, separator = " ") ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
107 108 109 110 111 112 113 114 115 116 117 |
# File 'extend/ENV/shared.rb', line 107 def prepend(keys, value, separator = " ") value = value.to_s Array(keys).each do |key| old_value = self[key] self[key] = if old_value.blank? value else value + separator + old_value end end end |
#prepend_create_path(key, path) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
144 145 146 147 148 |
# File 'extend/ENV/shared.rb', line 144 def prepend_create_path(key, path) path = Pathname(path) path.mkpath prepend_path key, path end |
#prepend_path(key, path) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
Prepends a directory to PATH.
Is the formula struggling to find the pkgconfig file? Point it to it.
This is done automatically for keg-only formulae.
ENV.prepend_path "PKG_CONFIG_PATH", "#{Formula["glib"].opt_lib}/pkgconfig"
Prepending a system path such as /usr/bin is a no-op so that requirements
don't accidentally override superenv shims or formulae's bin directories.
ENV.prepend_path "PATH", which("emacs").dirname
137 138 139 140 141 |
# File 'extend/ENV/shared.rb', line 137 def prepend_path(key, path) return if %w[/usr/bin /bin /usr/sbin /sbin].include? path.to_s self[key] = PATH.new(self[key]).prepend(path) end |
#refurbish_args ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
345 |
# File 'extend/ENV/shared.rb', line 345 def refurbish_args; end |
#remove(keys, value) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'extend/ENV/shared.rb', line 151 def remove(keys, value) return if value.nil? Array(keys).each do |key| old_value = self[key] next if old_value.nil? new_value = old_value.sub(value, "") if new_value.empty? delete(key) else self[key] = new_value end end end |
#remove_cc_etc ⇒ Hash{String => String, nil}
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
73 74 75 76 |
# File 'extend/ENV/shared.rb', line 73 def remove_cc_etc keys = %w[CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS] keys.to_h { |key| [key, delete(key)] } end |
#remove_from_cflags(val) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
84 85 86 |
# File 'extend/ENV/shared.rb', line 84 def remove_from_cflags(val) remove CC_FLAG_VARS, val end |
#setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false, debug_symbols: false) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
55 56 57 58 59 60 61 62 63 64 |
# File 'extend/ENV/shared.rb', line 55 def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false, debug_symbols: false) @formula = T.let(formula, T.nilable(Formula)) @cc = T.let(cc, T.nilable(String)) @build_bottle = T.let(build_bottle, T.nilable(T::Boolean)) @bottle_arch = T.let(bottle_arch, T.nilable(String)) @debug_symbols = T.let(debug_symbols, T.nilable(T::Boolean)) @testing_formula = T.let(testing_formula, T.nilable(T::Boolean)) reset end |