Module: Superenv

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, #no_weak_imports_support?, #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

.shims_pathPathname

The location of Homebrew’s shims on this OS.

Returns:



9
10
11
# File 'extend/os/mac/extend/ENV/super.rb', line 9

def shims_path
  HOMEBREW_SHIMS_PATH/"mac/super"
end

Instance Method Details

#cxx11void

This method returns an undefined value.



334
335
336
337
# File 'extend/ENV/super.rb', line 334

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)


304
305
306
307
308
309
310
311
312
313
314
315
# File 'extend/ENV/super.rb', line 304

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

  old
end

#determine_dynamic_linker_pathString?

Returns:



60
61
62
63
64
65
# File 'extend/os/linux/extend/ENV/super.rb', line 60

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

  path
end

#determine_rpath_paths(formula) ⇒ Object



50
51
52
53
54
55
56
57
# File 'extend/os/linux/extend/ENV/super.rb', line 50

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

#libcxxvoid

This method returns an undefined value.



340
341
342
# File 'extend/ENV/super.rb', line 340

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

#make_jobsInteger

Returns:

  • (Integer)


318
319
320
321
# File 'extend/ENV/super.rb', line 318

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

#no_weak_importsObject



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

def no_weak_imports
  append_to_cccfg "w" if no_weak_imports_support?
end

#O0(&block) ⇒ Object



358
359
360
361
362
363
364
# File 'extend/ENV/super.rb', line 358

def O0(&block)
  if block
    with_env(HOMEBREW_OPTIMIZATION_LEVEL: "O0", &block)
  else
    self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O0"
  end
end

#O1(&block) ⇒ void

This method returns an undefined value.

Parameters:

  • block (T.proc.void, nil)


367
368
369
370
371
372
373
# File 'extend/ENV/super.rb', line 367

def O1(&block)
  if block
    with_env(HOMEBREW_OPTIMIZATION_LEVEL: "O1", &block)
  else
    self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O1"
  end
end

#permit_arch_flagsvoid

This method returns an undefined value.



324
325
326
# File 'extend/ENV/super.rb', line 324

def permit_arch_flags
  append_to_cccfg "K"
end

#resetvoid

This method returns an undefined value.



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

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

#runtime_cpu_detectionvoid

This method returns an undefined value.



329
330
331
# File 'extend/ENV/super.rb', line 329

def runtime_cpu_detection
  append_to_cccfg "d"
end

#set_debug_symbolsvoid

This method returns an undefined value.



345
346
347
# File 'extend/ENV/super.rb', line 345

def set_debug_symbols
  append_to_cccfg "D"
end