Module: Stdenv Private

Extended by:
T::Sig
Includes:
SharedEnvExtension
Defined in:
brew/Library/Homebrew/extend/os/mac/extend/ENV/std.rb,
brew/Library/Homebrew/extend/os/linux/extend/ENV/std.rb,
brew/Library/Homebrew/extend/ENV/std.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Methods included from SharedEnvExtension

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

Instance Method Details

#clangvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



131
132
133
134
135
136
137
138
139
140
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 131

def clang
  super()
  replace_in_cflags(/-Xarch_#{Hardware::CPU.arch_32_bit} (-march=\S*)/, '\1')
  map = Hardware::CPU.optimization_flags.dup
  if DevelopmentTools.clang_build_version < 700
    # Clang mistakenly enables AES-NI on plain Nehalem
    map[:nehalem] = "-march=nehalem -Xclang -target-feature -Xclang -aes"
  end
  set_cpu_cflags(map)
end

#cxx11void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



175
176
177
178
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 175

def cxx11
  append "CXX", "-std=c++11"
  libcxx
end

#define_cflags(val) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Convenience method to set all C compiler flags in one shot.

Parameters:



202
203
204
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 202

def define_cflags(val)
  CC_FLAG_VARS.each { |key| self[key] = val }
end

#deparallelize(&block) ⇒ T.untyped

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Removes the MAKEFLAGS environment variable, causing make to use a single job. This is useful for makefiles with race conditions. When passed a block, MAKEFLAGS is removed only for the duration of the block and is restored after its completion.

Parameters:

  • block (T.proc.returns(T.untyped))

Returns:

  • (T.untyped)


86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 86

def deparallelize(&block)
  old = self["MAKEFLAGS"]
  remove "MAKEFLAGS", /-j\d+/
  if block
    begin
      yield
    ensure
      self["MAKEFLAGS"] = old
    end
  end

  old
end

#determine_pkg_config_libdirPATH?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



73
74
75
76
77
78
79
80
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 73

def determine_pkg_config_libdir
  PATH.new(
    HOMEBREW_PREFIX/"lib/pkgconfig",
    HOMEBREW_PREFIX/"share/pkgconfig",
    homebrew_extra_pkg_config_paths,
    "/usr/lib/pkgconfig",
  ).existing
end

#homebrew_extra_pkg_config_pathsArray<Pathname>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



68
69
70
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 68

def homebrew_extra_pkg_config_paths
  ["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
end

#libcxxvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



181
182
183
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 181

def libcxx
  append "CXX", "-stdlib=libc++" if compiler == :clang
end

#libstdcxxvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



186
187
188
189
190
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 186

def libstdcxx
  odeprecated "ENV.libstdcxx"

  append "CXX", "-stdlib=libstdc++" if compiler == :clang
end

#libxml2Object

Some configure scripts won’t find libxml2 without help. This is a no-op with macOS SDK 10.15.4 and later.



87
88
89
90
91
92
93
94
95
# File 'brew/Library/Homebrew/extend/os/mac/extend/ENV/std.rb', line 87

def libxml2
  sdk = self["SDKROOT"] || MacOS.sdk_path_if_needed
  if !sdk
    append "CPPFLAGS", "-I/usr/include/libxml2"
  elsif !Pathname("#{sdk}/usr/include/libxml").directory?
    # Use the includes form the sdk
    append "CPPFLAGS", "-I#{sdk}/usr/include/libxml2"
  end
end

#m32void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



151
152
153
154
155
156
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 151

def m32
  odeprecated "ENV.m32"

  append_to_cflags "-m32"
  append "LDFLAGS", "-arch #{Hardware::CPU.arch_32_bit}"
end

#m64void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



143
144
145
146
147
148
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 143

def m64
  odeprecated "ENV.m64"

  append_to_cflags "-m64"
  append "LDFLAGS", "-arch #{Hardware::CPU.arch_64_bit}"
end

#macosxsdk(version = nil, formula: nil, testing_formula: false) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'brew/Library/Homebrew/extend/os/mac/extend/ENV/std.rb', line 53

def macosxsdk(version = nil, formula: nil, testing_formula: false)
  # Sets all needed lib and include dirs to CFLAGS, CPPFLAGS, LDFLAGS.
  remove_macosxsdk
  min_version = version || MacOS.version
  append_to_cflags("-mmacosx-version-min=#{min_version}")
  self["CPATH"] = "#{HOMEBREW_PREFIX}/include"
  prepend "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"

  sdk = if formula
    MacOS.sdk_for_formula(formula, version, check_only_runtime_requirements: testing_formula)
  else
    MacOS.sdk(version)
  end
  return if !MacOS.sdk_root_needed? && sdk&.source != :xcode

  Homebrew::Diagnostic.checks(:fatal_setup_build_environment_checks)
  sdk = sdk.path

  # Extra setup to support Xcode 4.3+ without CLT.
  self["SDKROOT"] = sdk
  # Tell clang/gcc where system include's are:
  append_path "CPATH", "#{sdk}/usr/include"
  # The -isysroot is needed, too, because of the Frameworks
  append_to_cflags "-isysroot#{sdk}"
  append "CPPFLAGS", "-isysroot#{sdk}"
  # And the linker needs to find sdk/usr/lib
  append "LDFLAGS", "-isysroot#{sdk}"
  # Needed to build cmake itself and perhaps some cmake projects:
  append_path "CMAKE_PREFIX_PATH", "#{sdk}/usr"
  append_path "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
end

#make_jobsInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


233
234
235
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 233

def make_jobs
  Homebrew::EnvConfig.make_jobs.to_i
end

#no_weak_importsObject



97
98
99
# File 'brew/Library/Homebrew/extend/os/mac/extend/ENV/std.rb', line 97

def no_weak_imports
  append "LDFLAGS", "-Wl,-no_weak_imports" if no_weak_imports_support?
end

#remove_macosxsdk(version = nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'brew/Library/Homebrew/extend/os/mac/extend/ENV/std.rb', line 30

def remove_macosxsdk(version = nil)
  # Clear all lib and include dirs from CFLAGS, CPPFLAGS, LDFLAGS that were
  # previously added by macosxsdk
  remove_from_cflags(/ ?-mmacosx-version-min=\d+\.\d+/)
  delete("CPATH")
  remove "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"

  sdk = self["SDKROOT"] || MacOS.sdk_path_if_needed(version)
  return unless sdk

  delete("SDKROOT")
  remove_from_cflags "-isysroot#{sdk}"
  remove "CPPFLAGS", "-isysroot#{sdk}"
  remove "LDFLAGS", "-isysroot#{sdk}"
  if HOMEBREW_PREFIX.to_s == "/usr/local"
    delete("CMAKE_PREFIX_PATH")
  else
    # It was set in setup_build_environment, so we have to restore it here.
    self["CMAKE_PREFIX_PATH"] = HOMEBREW_PREFIX.to_s
  end
  remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
end

#universal_binaryvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 159

def universal_binary
  odeprecated "ENV.universal_binary"

  check_for_compiler_universal_support

  append_to_cflags Hardware::CPU.universal_archs.as_arch_flags
  append "LDFLAGS", Hardware::CPU.universal_archs.as_arch_flags

  return if compiler_any_clang?
  return unless Hardware::CPU.is_32_bit?

  # Can't mix "-march" for a 32-bit CPU with "-arch x86_64"
  replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0")
end

#x11void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.



222
223
224
# File 'brew/Library/Homebrew/extend/ENV/std.rb', line 222

def x11
  odeprecated "ENV.x11", "depends_on specific X11 formula(e)"
end