Module: EnvActivation Private

Includes:
Superenv
Included in:
ENV, Sorbet::Private::Static::ENVClass
Defined in:
extend/ENV.rb,
extend/ENV.rbi

Overview

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

Attributes included from Superenv

#deps, #keg_only_deps, #run_time_deps

Instance Method Summary collapse

Methods included from Superenv

#O0, #O1, #O3, bin, #cxx11, #deparallelize, #determine_cccfg, #determine_dynamic_linker_path, #determine_rpath_paths, extended, #homebrew_extra_cmake_frameworks_paths, #homebrew_extra_cmake_include_paths, #homebrew_extra_cmake_library_paths, #homebrew_extra_isystem_paths, #homebrew_extra_library_paths, #homebrew_extra_paths, #libcxx, #make_jobs, #no_fixup_chains, #no_weak_imports, #permit_arch_flags, #refurbish_args, #reset, #runtime_cpu_detection, #set_debug_symbols, shims_path

Methods included from SharedEnvExtension

#append, #append_path, #append_to_cccfg, #append_to_cflags, #cc, #cflags, #compiler, #cppflags, #cxx, #cxxflags, #effective_arch, #fc, #fcflags, #fflags, #fortran, #ldflags, #no_fixup_chains_support?, #no_weak_imports_support?, #permit_arch_flags, #prepend, #prepend_create_path, #prepend_path, #remove, #remove_cc_etc, #remove_from_cflags

Methods included from Kernel

#disk_usage_readable, #ensure_executable!, #ensure_formula_installed!, #exec_browser, #exec_editor, #ignore_interrupts, #interactive_shell, #number_readable, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #paths, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #quiet_system, #redact_secrets, #redirect_stdout, #require?, #safe_system, #tap_and_name_comparison, #truncate_text_to_approximate_size, #which, #which_all, #which_editor, #with_custom_locale, #with_env, #with_homebrew_path

Instance Method Details

#activate_extensions!(env: nil) ⇒ 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.

Parameters:

  • env (String, nil) (defaults to: nil)


32
33
34
35
36
37
38
# File 'extend/ENV.rb', line 32

def activate_extensions!(env: nil)
  if superenv?(env)
    extend(Superenv)
  else
    extend(Stdenv)
  end
end

#clear_sensitive_environment!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.



77
78
79
# File 'extend/ENV.rb', line 77

def clear_sensitive_environment!
  each_key { |key| delete key if sensitive?(key) }
end

#sensitive?(key) ⇒ Boolean

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.

Parameters:

Returns:

  • (Boolean)


67
68
69
# File 'extend/ENV.rb', line 67

def sensitive?(key)
  key.match?(/(cookie|key|token|password|passphrase)/i)
end

#sensitive_environmentHash{String => 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.

Returns:



72
73
74
# File 'extend/ENV.rb', line 72

def sensitive_environment
  select { |key, _| sensitive?(key) }
end

#with_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil, debug_symbols: false, &_block) ⇒ T.untyped

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.

Parameters:

  • env (String, nil) (defaults to: nil)
  • cc (String, nil) (defaults to: nil)
  • build_bottle (Boolean) (defaults to: false)
  • bottle_arch (String, nil) (defaults to: nil)
  • debug_symbols (Boolean, nil) (defaults to: false)
  • _block (T.proc.returns(T.untyped))

Returns:

  • (T.untyped)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'extend/ENV.rb', line 50

def with_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil, debug_symbols: false, &_block)
  old_env = to_hash.dup
  tmp_env = to_hash.dup.extend(EnvActivation)
  T.cast(tmp_env, EnvActivation).activate_extensions!(env:)
  T.cast(tmp_env, T.any(Superenv, Stdenv))
   .setup_build_environment(cc:, build_bottle:, bottle_arch:,
                            debug_symbols:)
  replace(tmp_env)

  begin
    yield
  ensure
    replace(old_env)
  end
end