Module: Stdenv Private
- Extended by:
- T::Sig
- Includes:
- SharedEnvExtension
- Defined in:
- extend/os/mac/extend/ENV/std.rb,
extend/os/linux/extend/ENV/std.rb,
extend/ENV/std.rb
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.
Instance Method Summary collapse
-
#clang ⇒ void
private
-
#cxx11 ⇒ void
private
-
#define_cflags(val) ⇒ void
private
Convenience method to set all C compiler flags in one shot.
-
#deparallelize(&block) ⇒ T.untyped
private
Removes the MAKEFLAGS environment variable, causing make to use a single job.
-
#determine_pkg_config_libdir ⇒ PATH?
private
-
#homebrew_extra_pkg_config_paths ⇒ Array<Pathname>
private
-
#libcxx ⇒ void
private
-
#libxml2 ⇒ Object
Some configure scripts won’t find libxml2 without help.
-
#macosxsdk(version = nil, formula: nil, testing_formula: false) ⇒ Object
-
#make_jobs ⇒ Integer
private
-
#no_weak_imports ⇒ Object
-
#remove_macosxsdk(version = nil) ⇒ Object
Methods included from SharedEnvExtension
#append, #append_path, #append_to_cccfg, #append_to_cflags, #cc, #cflags, #compiler, #cppflags, #cxx, #cxxflags, #fc, #fcflags, #fflags, #fortran, #ldflags, #no_weak_imports_support?, #permit_arch_flags, #prepend, #prepend_create_path, #prepend_path, #remove, #remove_cc_etc, #remove_from_cflags
Instance Method Details
#clang ⇒ 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.
129 130 131 132 133 134 135 136 137 138 |
# File 'extend/ENV/std.rb', line 129 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 |
#cxx11 ⇒ 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.
141 142 143 144 |
# File 'extend/ENV/std.rb', line 141 def cxx11 append "CXX", "-std=c++11" libcxx end |
#define_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.
Convenience method to set all C compiler flags in one shot.
161 162 163 |
# File 'extend/ENV/std.rb', line 161 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. 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.
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.
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File '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_libdir ⇒ PATH?
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 77 78 79 80 |
# File '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_paths ⇒ Array<Pathname>
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.
68 69 70 |
# File 'extend/ENV/std.rb', line 68 def homebrew_extra_pkg_config_paths ["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"] end |
#libcxx ⇒ 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.
147 148 149 |
# File 'extend/ENV/std.rb', line 147 def libcxx append "CXX", "-stdlib=libc++" if compiler == :clang end |
#libxml2 ⇒ Object
Some configure scripts won’t find libxml2 without help. This is a no-op with macOS SDK 10.15.4 and later.
92 93 94 95 96 97 98 99 100 |
# File 'extend/os/mac/extend/ENV/std.rb', line 92 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 |
#macosxsdk(version = nil, formula: nil, testing_formula: false) ⇒ Object
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 84 85 86 87 88 |
# File 'extend/os/mac/extend/ENV/std.rb', line 58 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_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.
187 188 189 |
# File 'extend/ENV/std.rb', line 187 def make_jobs Homebrew::EnvConfig.make_jobs.to_i end |
#no_weak_imports ⇒ Object
102 103 104 |
# File 'extend/os/mac/extend/ENV/std.rb', line 102 def no_weak_imports append "LDFLAGS", "-Wl,-no_weak_imports" if no_weak_imports_support? end |
#remove_macosxsdk(version = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'extend/os/mac/extend/ENV/std.rb', line 35 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 |