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
?
- Only specify the environment we need (NO LDFLAGS for cmake)
- Only apply compiler-specific options when we are calling that compiler
- Force all incpaths and libpaths into the cc instantiation (fewer bugs)
- Cater toolchain usage to specific Xcode versions
- Remove flags that we don’t want or that will break builds
- Simpler code
- Simpler formulae that just work
- Build-system agnostic configuration of the toolchain
Class Method Summary
collapse
Instance Method Summary
collapse
#append, #append_path, #append_to_cccfg, #append_to_cflags, #cc, #cflags, #compiler, #cppflags, #cxx, #cxxflags, #fc, #fcflags, #fflags, #fortran, #ldflags, #no_fixup_chains_support?, #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.
24
25
26
27
28
|
# File 'extend/ENV/super.rb', line 24
def self.extended(base)
base.keg_only_deps = []
base.deps = []
base.run_time_deps = []
end
|
The location of Homebrew’s shims on this OS.
7
8
9
|
# File 'extend/os/mac/extend/ENV/super.rb', line 7
def shims_path
HOMEBREW_SHIMS_PATH/"mac/super"
end
|
Instance Method Details
#cxx11 ⇒ void
This method returns an undefined value.
338
339
340
341
|
# File 'extend/ENV/super.rb', line 338
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.
308
309
310
311
312
313
314
315
316
317
318
319
|
# File 'extend/ENV/super.rb', line 308
def deparallelize(&block)
old = delete("MAKEFLAGS")
if block
begin
yield
ensure
self["MAKEFLAGS"] = old
end
end
old
end
|
#determine_cccfg ⇒ String
78
79
80
81
82
83
|
# File 'extend/os/mac/extend/ENV/super.rb', line 78
def determine_cccfg
s = +""
s << "a"
s.freeze
end
|
#determine_dynamic_linker_path ⇒ String?
58
59
60
61
62
63
|
# File 'extend/os/linux/extend/ENV/super.rb', line 58
def determine_dynamic_linker_path
path = "#{HOMEBREW_PREFIX}/lib/ld.so"
return unless File.readable? path
path
end
|
#determine_rpath_paths(formula) ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'extend/os/linux/extend/ENV/super.rb', line 48
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
|
72
73
74
75
76
|
# File 'extend/os/mac/extend/ENV/super.rb', line 72
def
paths = []
paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks" if MacOS::Xcode.without_clt?
paths
end
|
60
61
62
63
64
65
66
|
# File 'extend/os/mac/extend/ENV/super.rb', line 60
def
paths = []
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt?
paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
paths
end
|
68
69
70
|
# File 'extend/os/mac/extend/ENV/super.rb', line 68
def
[Pathname("#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries")]
end
|
42
43
44
45
46
47
48
|
# File 'extend/os/mac/extend/ENV/super.rb', line 42
def
paths = []
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt?
paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
paths
end
|
50
51
52
53
54
55
56
57
58
|
# File 'extend/os/mac/extend/ENV/super.rb', line 50
def
paths = []
if compiler == :llvm_clang
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/lib"
paths << Formula["llvm"].opt_lib.to_s
end
paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
paths
end
|
26
27
28
29
30
31
32
33
34
35
|
# File 'extend/os/linux/extend/ENV/super.rb', line 26
def
paths =
paths += %w[binutils make].map do |f|
bin = Formulary.factory(f).opt_bin
bin if bin.directory?
rescue FormulaUnavailableError
nil
end.compact
paths
end
|
#libcxx ⇒ void
This method returns an undefined value.
344
345
346
|
# File 'extend/ENV/super.rb', line 344
def libcxx
append_to_cccfg "g" if compiler == :clang
end
|
#make_jobs ⇒ Integer
322
323
324
325
|
# File 'extend/ENV/super.rb', line 322
def make_jobs
self["MAKEFLAGS"] =~ /-\w*j(\d+)/
[Regexp.last_match(1).to_i, 1].max
end
|
#no_fixup_chains ⇒ Object
149
150
151
|
# File 'extend/os/mac/extend/ENV/super.rb', line 149
def no_fixup_chains
append_to_cccfg "f" if no_fixup_chains_support?
end
|
#no_weak_imports ⇒ Object
145
146
147
|
# File 'extend/os/mac/extend/ENV/super.rb', line 145
def no_weak_imports
append_to_cccfg "w" if no_weak_imports_support?
end
|
#O0(&block) ⇒ Object
362
363
364
365
366
367
368
|
# File 'extend/ENV/super.rb', line 362
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.
371
372
373
374
375
376
377
|
# File 'extend/ENV/super.rb', line 371
def O1(&block)
if block
with_env(HOMEBREW_OPTIMIZATION_LEVEL: "O1", &block)
else
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O1"
end
end
|
#O3(&block) ⇒ void
This method returns an undefined value.
380
381
382
383
384
385
386
|
# File 'extend/ENV/super.rb', line 380
def O3(&block)
if block
with_env(HOMEBREW_OPTIMIZATION_LEVEL: "O3", &block)
else
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O3"
end
end
|
#permit_arch_flags ⇒ void
This method returns an undefined value.
328
329
330
|
# File 'extend/ENV/super.rb', line 328
def permit_arch_flags
append_to_cccfg "K"
end
|
#reset ⇒ void
This method returns an undefined value.
41
42
43
44
45
46
|
# File 'extend/ENV/super.rb', line 41
def reset
super
delete("as_nl")
end
|
#runtime_cpu_detection ⇒ void
This method returns an undefined value.
333
334
335
|
# File 'extend/ENV/super.rb', line 333
def runtime_cpu_detection
append_to_cccfg "d"
end
|
#set_debug_symbols ⇒ void
This method returns an undefined value.
349
350
351
|
# File 'extend/ENV/super.rb', line 349
def set_debug_symbols
append_to_cccfg "D"
end
|