Make compiler shim robust against missing environment variables
Fixes Homebrew/homebrew#36217.
This commit is contained in:
parent
d4e24dce0a
commit
4b91017894
@ -27,6 +27,7 @@ LOGGER = Logger.new
|
|||||||
|
|
||||||
class Cmd
|
class Cmd
|
||||||
attr_reader :config, :prefix, :cellar, :tmpdir, :sysroot
|
attr_reader :config, :prefix, :cellar, :tmpdir, :sysroot
|
||||||
|
attr_reader :archflags, :optflags
|
||||||
|
|
||||||
def initialize path, args
|
def initialize path, args
|
||||||
@arg0 = File.basename(path).freeze
|
@arg0 = File.basename(path).freeze
|
||||||
@ -36,6 +37,8 @@ class Cmd
|
|||||||
@cellar = ENV['HOMEBREW_CELLAR']
|
@cellar = ENV['HOMEBREW_CELLAR']
|
||||||
@tmpdir = ENV['HOMEBREW_TEMP']
|
@tmpdir = ENV['HOMEBREW_TEMP']
|
||||||
@sysroot = ENV['HOMEBREW_SDKROOT']
|
@sysroot = ENV['HOMEBREW_SDKROOT']
|
||||||
|
@archflags = ENV.fetch("HOMEBREW_ARCHFLAGS") { "" }.split(" ")
|
||||||
|
@optflags = ENV.fetch("HOMEBREW_OPTFLAGS") { "" }.split(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
def mode
|
def mode
|
||||||
@ -211,6 +214,7 @@ class Cmd
|
|||||||
|
|
||||||
args << '-pipe'
|
args << '-pipe'
|
||||||
args << '-w' unless configure?
|
args << '-w' unless configure?
|
||||||
|
args << "-#{ENV["HOMEBREW_OPTIMIZATION_LEVEL"]}"
|
||||||
args.concat(optflags)
|
args.concat(optflags)
|
||||||
args.concat(archflags)
|
args.concat(archflags)
|
||||||
args << "-std=#{@arg0}" if @arg0 =~ /c[89]9/
|
args << "-std=#{@arg0}" if @arg0 =~ /c[89]9/
|
||||||
@ -225,17 +229,6 @@ class Cmd
|
|||||||
args
|
args
|
||||||
end
|
end
|
||||||
|
|
||||||
def optflags
|
|
||||||
args = []
|
|
||||||
args << "-#{ENV['HOMEBREW_OPTIMIZATION_LEVEL']}"
|
|
||||||
args.concat ENV['HOMEBREW_OPTFLAGS'].split(' ') if ENV['HOMEBREW_OPTFLAGS']
|
|
||||||
args
|
|
||||||
end
|
|
||||||
|
|
||||||
def archflags
|
|
||||||
ENV["HOMEBREW_ARCHFLAGS"].split(" ")
|
|
||||||
end
|
|
||||||
|
|
||||||
def cppflags
|
def cppflags
|
||||||
path_flags("-isystem", isystem_paths) + path_flags("-I", include_paths)
|
path_flags("-isystem", isystem_paths) + path_flags("-I", include_paths)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user