Add superenv for Linux
This commit is contained in:
parent
16e5799f86
commit
76bfd0cecb
@ -68,6 +68,7 @@ class Build
|
||||
def install
|
||||
formula_deps = deps.map(&:to_formula)
|
||||
keg_only_deps = formula_deps.select(&:keg_only?)
|
||||
run_time_deps = deps.reject(&:build?).map(&:to_formula)
|
||||
|
||||
formula_deps.each do |dep|
|
||||
fixopt(dep) unless dep.opt_prefix.directory?
|
||||
@ -78,6 +79,7 @@ class Build
|
||||
if superenv?
|
||||
ENV.keg_only_deps = keg_only_deps
|
||||
ENV.deps = formula_deps
|
||||
ENV.run_time_deps = run_time_deps
|
||||
ENV.x11 = reqs.any? { |rq| rq.is_a?(X11Requirement) }
|
||||
ENV.setup_build_environment(formula)
|
||||
post_superenv_hacks
|
||||
|
@ -15,12 +15,13 @@ module Superenv
|
||||
include SharedEnvExtension
|
||||
|
||||
# @private
|
||||
attr_accessor :keg_only_deps, :deps
|
||||
attr_accessor :keg_only_deps, :deps, :run_time_deps
|
||||
attr_accessor :x11
|
||||
|
||||
def self.extended(base)
|
||||
base.keg_only_deps = []
|
||||
base.deps = []
|
||||
base.run_time_deps = []
|
||||
end
|
||||
|
||||
# @private
|
||||
@ -61,6 +62,8 @@ module Superenv
|
||||
self["HOMEBREW_ISYSTEM_PATHS"] = determine_isystem_paths
|
||||
self["HOMEBREW_INCLUDE_PATHS"] = determine_include_paths
|
||||
self["HOMEBREW_LIBRARY_PATHS"] = determine_library_paths
|
||||
self["HOMEBREW_RPATH_PATHS"] = determine_rpath_paths(formula)
|
||||
self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
|
||||
self["HOMEBREW_DEPENDENCIES"] = determine_dependencies
|
||||
self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix unless formula.nil?
|
||||
|
||||
@ -178,20 +181,22 @@ module Superenv
|
||||
keg_only_deps.map(&:opt_lib),
|
||||
HOMEBREW_PREFIX/"lib",
|
||||
]
|
||||
|
||||
if compiler == :llvm_clang
|
||||
if MacOS::CLT.installed?
|
||||
paths << "/usr/lib"
|
||||
else
|
||||
paths << "#{MacOS.sdk_path}/usr/lib"
|
||||
end
|
||||
paths << Formula["llvm"].opt_lib.to_s
|
||||
end
|
||||
|
||||
paths += homebrew_extra_library_paths
|
||||
PATH.new(paths).existing
|
||||
end
|
||||
|
||||
def determine_extra_rpath_paths(_formula)
|
||||
[]
|
||||
end
|
||||
|
||||
def determine_rpath_paths(formula)
|
||||
PATH.new(determine_extra_rpath_paths(formula))
|
||||
end
|
||||
|
||||
def determine_dynamic_linker_path
|
||||
nil
|
||||
end
|
||||
|
||||
def determine_dependencies
|
||||
deps.map(&:name).join(",")
|
||||
end
|
||||
|
@ -1 +1,5 @@
|
||||
require "extend/os/mac/extend/ENV/super" if OS.mac?
|
||||
if OS.mac?
|
||||
require "extend/os/mac/extend/ENV/super"
|
||||
elsif OS.linux?
|
||||
require "extend/os/linux/extend/ENV/super"
|
||||
end
|
||||
|
33
Library/Homebrew/extend/os/linux/extend/ENV/super.rb
Normal file
33
Library/Homebrew/extend/os/linux/extend/ENV/super.rb
Normal file
@ -0,0 +1,33 @@
|
||||
module Superenv
|
||||
# @private
|
||||
def self.bin
|
||||
(HOMEBREW_SHIMS_PATH/"linux/super").realpath
|
||||
end
|
||||
|
||||
def homebrew_extra_paths
|
||||
paths = []
|
||||
paths += %w[binutils make].map do |f|
|
||||
begin
|
||||
bin = Formula[f].opt_bin
|
||||
bin if bin.directory?
|
||||
rescue FormulaUnavailableError
|
||||
nil
|
||||
end
|
||||
end.compact
|
||||
paths
|
||||
end
|
||||
|
||||
def determine_extra_rpath_paths(formula)
|
||||
PATH.new(
|
||||
formula&.lib,
|
||||
"#{HOMEBREW_PREFIX}/lib",
|
||||
PATH.new(run_time_deps.map { |dep| dep.opt_lib.to_s }).existing,
|
||||
)
|
||||
end
|
||||
|
||||
def determine_dynamic_linker_path
|
||||
path = "#{HOMEBREW_PREFIX}/lib/ld.so"
|
||||
return unless File.readable? path
|
||||
path
|
||||
end
|
||||
end
|
@ -58,6 +58,14 @@ module Superenv
|
||||
|
||||
def homebrew_extra_library_paths
|
||||
paths = []
|
||||
if compiler == :llvm_clang
|
||||
if MacOS::CLT.installed?
|
||||
paths << "/usr/lib"
|
||||
else
|
||||
paths << "#{MacOS.sdk_path}/usr/lib"
|
||||
end
|
||||
paths << Formula["llvm"].opt_lib.to_s
|
||||
end
|
||||
paths << MacOS::X11.lib.to_s if x11?
|
||||
paths << "#{effective_sysroot}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
|
||||
paths
|
||||
|
Loading…
x
Reference in New Issue
Block a user