Module: Superenv

Includes:
SharedEnvExtension
Defined in:
brew/Library/Homebrew/extend/ENV/super.rb,
brew/Library/Homebrew/extend/os/mac/extend/ENV/super.rb,
brew/Library/Homebrew/extend/os/linux/extend/ENV/super.rb

Overview

Why superenv?

  1. Only specify the environment we need (NO LDFLAGS for cmake)
  2. Only apply compiler specific options when we are calling that compiler
  3. Force all incpaths and libpaths into the cc instantiation (less bugs)
  4. Cater toolchain usage to specific Xcode versions
  5. Remove flags that we don’t want or that will break builds
  6. Simpler code
  7. Simpler formula that just work
  8. Build-system agnostic configuration of the tool-chain

Instance Attribute Summary collapse

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_weak_imports, #prepend, #prepend_create_path, #prepend_path, #remove, #remove_cc_etc, #remove_from_cflags

Instance Attribute Details

#x11Object Also known as: x11?

Returns the value of attribute x11



21
22
23
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 21

def x11
  @x11
end

Instance Method Details

#cxx11Object



276
277
278
279
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 276

def cxx11
  append_to_cccfg "x"
  append_to_cccfg "g" if homebrew_cc == "clang"
end

#deparallelizeObject

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.



240
241
242
243
244
245
246
247
248
249
250
251
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 240

def deparallelize
  old = delete("MAKEFLAGS")
  if block_given?
    begin
      yield
    ensure
      self["MAKEFLAGS"] = old
    end
  end

  old
end

#determine_cccfgObject



231
232
233
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 231

def determine_cccfg
  ""
end

#determine_dynamic_linker_pathObject



38
39
40
41
42
43
# File 'brew/Library/Homebrew/extend/os/linux/extend/ENV/super.rb', line 38

def determine_dynamic_linker_path
  path = "#{HOMEBREW_PREFIX}/lib/ld.so"
  return unless File.readable? path

  path
end

#determine_rpath_paths(formula) ⇒ Object



30
31
32
33
34
35
36
# File 'brew/Library/Homebrew/extend/os/linux/extend/ENV/super.rb', line 30

def determine_rpath_paths(formula)
  PATH.new(
    formula&.lib,
    "#{HOMEBREW_PREFIX}/lib",
    PATH.new(run_time_deps.map { |dep| dep.opt_lib.to_s }).existing,
  )
end

#effective_sysrootObject



100
101
102
# File 'brew/Library/Homebrew/extend/os/mac/extend/ENV/super.rb', line 100

def effective_sysroot
  MacOS.sdk_path_if_needed&.to_s
end

#homebrew_extra_aclocal_pathsObject



141
142
143
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 141

def homebrew_extra_aclocal_paths
  []
end

#homebrew_extra_cmake_frameworks_pathsObject



208
209
210
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 208

def homebrew_extra_cmake_frameworks_paths
  []
end

#homebrew_extra_cmake_include_pathsObject



192
193
194
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 192

def homebrew_extra_cmake_include_paths
  []
end

#homebrew_extra_cmake_library_pathsObject



200
201
202
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 200

def homebrew_extra_cmake_library_paths
  []
end

#homebrew_extra_isystem_pathsObject



153
154
155
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 153

def homebrew_extra_isystem_paths
  []
end

#homebrew_extra_library_pathsObject



168
169
170
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 168

def homebrew_extra_library_paths
  []
end

#homebrew_extra_pathsObject



102
103
104
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 102

def homebrew_extra_paths
  []
end

#libcxxObject



281
282
283
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 281

def libcxx
  append_to_cccfg "g" if compiler == :clang
end

#libstdcxxObject



285
286
287
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 285

def libstdcxx
  append_to_cccfg "h" if compiler == :clang
end

#m32Object



268
269
270
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 268

def m32
  append "HOMEBREW_ARCHFLAGS", "-m32"
end

#m64Object



272
273
274
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 272

def m64
  append "HOMEBREW_ARCHFLAGS", "-m64"
end

#make_jobsObject



253
254
255
256
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 253

def make_jobs
  self["MAKEFLAGS"] =~ /-\w*j(\d+)/
  [Regexp.last_match(1).to_i, 1].max
end

#no_weak_importsObject



136
137
138
# File 'brew/Library/Homebrew/extend/os/mac/extend/ENV/super.rb', line 136

def no_weak_imports
  append_to_cccfg "w" if no_weak_imports_support?
end

#permit_arch_flagsObject



264
265
266
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 264

def permit_arch_flags
  append_to_cccfg "K"
end

#resetObject



32
33
34
35
36
37
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 32

def reset
  super
  # Configure scripts generated by autoconf 2.61 or later export as_nl, which
  # we use as a heuristic for running under configure
  delete("as_nl")
end

#set_cpu_flags(_, _ = "", _ = {}) ⇒ Object



302
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 302

def set_cpu_flags(_, _ = "", _ = {}); end

#set_x11_env_if_installedObject



300
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 300

def set_x11_env_if_installed; end

#universal_binaryObject



258
259
260
261
262
# File 'brew/Library/Homebrew/extend/ENV/super.rb', line 258

def universal_binary
  check_for_compiler_universal_support

  self["HOMEBREW_ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags
end