Module: EnvActivation Private

Includes:
SharedEnvExtension
Included in:
ENV, Sorbet::Private::Static::ENVClass
Defined in:
extend/ENV.rb,
extend/ENV.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 Method Summary collapse

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, #make_jobs, #no_fixup_chains_support?, #no_weak_imports_support?, #permit_arch_flags, #prepend, #prepend_create_path, #prepend_path, #refurbish_args, #remove, #remove_cc_etc, #remove_from_cflags, #setup_build_environment

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