Module: Superenv

Extended by:
T::Sig
Includes:
SharedEnvExtension
Defined in:
extend/os/mac/extend/ENV/super.rb,
extend/os/linux/extend/ENV/super.rb,
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 (fewer 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 formulae that just work
  8. Build-system agnostic configuration of the toolchain

Class Method 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

Class Method Details

.extended(base) ⇒ void

This method returns an undefined value.

Parameters:



26
27
28
29
30
# File 'extend/ENV/super.rb', line 26

def self.extended(base)
  base.keg_only_deps = []
  base.deps = []
  base.run_time_deps = []
end

Instance Method Details

#cxx11void

This method returns an undefined value.



302
303
304
305
# File 'extend/ENV/super.rb', line 302

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

#deparallelize(&block) ⇒ T.untyped

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)


277
278
279
280
281
282
283
284
285
286
287
288
# File 'extend/ENV/super.rb', line 277

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

  old
end

#determine_dynamic_linker_pathString?

Returns:



43
44
45
46
47
48
# File 'extend/os/linux/extend/ENV/super.rb', line 43

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

  path
end

#determine_rpath_paths(formula) ⇒ Object



34
35
36
37
38
39
40
# File 'extend/os/linux/extend/ENV/super.rb', line 34

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

#libcxxvoid

This method returns an undefined value.



308
309
310
# File 'extend/ENV/super.rb', line 308

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

#make_jobsInteger

Returns:

  • (Integer)


291
292
293
294
# File 'extend/ENV/super.rb', line 291

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

#no_weak_importsObject



150
151
152
# File 'extend/os/mac/extend/ENV/super.rb', line 150

def no_weak_imports
  append_to_cccfg "w" if no_weak_imports_support?
end

#permit_arch_flagsvoid

This method returns an undefined value.



297
298
299
# File 'extend/ENV/super.rb', line 297

def permit_arch_flags
  append_to_cccfg "K"
end

#resetvoid

This method returns an undefined value.



37
38
39
40
41
42
# File 'extend/ENV/super.rb', line 37

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