Module: Superenv

Includes:
SharedEnvExtension
Defined in:
Library/Homebrew/extend/ENV/super.rb,
Library/Homebrew/extend/os/mac/extend/ENV/super.rb,
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 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 Method Details

#cxx11Object


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

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.


235
236
237
238
239
240
241
242
243
244
245
246
# File 'Library/Homebrew/extend/ENV/super.rb', line 235

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

  old
end

#determine_cccfgObject


226
227
228
# File 'Library/Homebrew/extend/ENV/super.rb', line 226

def determine_cccfg
  ""
end

#determine_dynamic_linker_pathObject


36
37
38
39
40
41
# File 'Library/Homebrew/extend/os/linux/extend/ENV/super.rb', line 36

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

  path
end

#determine_rpath_paths(formula) ⇒ Object


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

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

#homebrew_extra_aclocal_pathsObject


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

def homebrew_extra_aclocal_paths
  []
end

#homebrew_extra_cmake_frameworks_pathsObject


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

def homebrew_extra_cmake_frameworks_paths
  []
end

#homebrew_extra_cmake_include_pathsObject


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

def homebrew_extra_cmake_include_paths
  []
end

#homebrew_extra_cmake_library_pathsObject


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

def homebrew_extra_cmake_library_paths
  []
end

#homebrew_extra_isystem_pathsObject


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

def homebrew_extra_isystem_paths
  []
end

#homebrew_extra_library_pathsObject


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

def homebrew_extra_library_paths
  []
end

#homebrew_extra_pathsObject


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

def homebrew_extra_paths
  []
end

#libcxxObject


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

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

#libstdcxxObject


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

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

#m32Object


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

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

#m64Object


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

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

#make_jobsObject


248
249
250
251
# File 'Library/Homebrew/extend/ENV/super.rb', line 248

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

#no_weak_importsObject


148
149
150
# File 'Library/Homebrew/extend/os/mac/extend/ENV/super.rb', line 148

def no_weak_imports
  append_to_cccfg "w" if no_weak_imports_support?
end

#permit_arch_flagsObject


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

def permit_arch_flags
  append_to_cccfg "K"
end

#resetObject


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

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


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

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

#set_x11_env_if_installedObject


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

def set_x11_env_if_installed; end

#universal_binaryObject


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

def universal_binary
  check_for_compiler_universal_support

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