ENV.rb: Configure Objective-C++ compiler
Ensures the `OBJCXX` environment variable is correctly set. Also adds `OBJC` and `OBJCXX` to `ENV.remove_cc_etc`.
This commit is contained in:
parent
0d5a42ad89
commit
14cb8c8fce
@ -47,9 +47,8 @@ module HomebrewEnvExtension
|
|||||||
unless self['CC']
|
unless self['CC']
|
||||||
@compiler = MacOS.default_compiler
|
@compiler = MacOS.default_compiler
|
||||||
self.send @compiler
|
self.send @compiler
|
||||||
self['CC'] = MacOS.locate("cc")
|
self['CC'] = self['OBJC'] = MacOS.locate("cc")
|
||||||
self['CXX'] = MacOS.locate("c++")
|
self['CXX'] = self['OBJCXX'] = MacOS.locate("c++")
|
||||||
self['OBJC'] = self['CC']
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add lib and include etc. from the current macosxsdk to compiler flags:
|
# Add lib and include etc. from the current macosxsdk to compiler flags:
|
||||||
@ -116,9 +115,8 @@ module HomebrewEnvExtension
|
|||||||
|
|
||||||
def gcc_4_0_1
|
def gcc_4_0_1
|
||||||
# we don't use locate because gcc 4.0 has not been provided since Xcode 4
|
# we don't use locate because gcc 4.0 has not been provided since Xcode 4
|
||||||
self['CC'] = "#{MacOS.dev_tools_path}/gcc-4.0"
|
self['CC'] = self['OBJC'] = "#{MacOS.dev_tools_path}/gcc-4.0"
|
||||||
self['CXX'] = "#{MacOS.dev_tools_path}/g++-4.0"
|
self['CXX'] = self['OBJCXX'] = "#{MacOS.dev_tools_path}/g++-4.0"
|
||||||
self['OBJC'] = self['CC']
|
|
||||||
replace_in_cflags '-O4', '-O3'
|
replace_in_cflags '-O4', '-O3'
|
||||||
set_cpu_cflags 'nocona -mssse3', :core => 'prescott', :bottle => 'generic'
|
set_cpu_cflags 'nocona -mssse3', :core => 'prescott', :bottle => 'generic'
|
||||||
@compiler = :gcc
|
@compiler = :gcc
|
||||||
@ -132,6 +130,7 @@ module HomebrewEnvExtension
|
|||||||
self['CXX'] =~ %r{/usr/bin/xcrun (.*)}
|
self['CXX'] =~ %r{/usr/bin/xcrun (.*)}
|
||||||
self['CXX'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1
|
self['CXX'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1
|
||||||
self['OBJC'] = self['CC']
|
self['OBJC'] = self['CC']
|
||||||
|
self['OBJCXX'] = self['CXX']
|
||||||
end
|
end
|
||||||
|
|
||||||
def gcc
|
def gcc
|
||||||
@ -139,14 +138,12 @@ module HomebrewEnvExtension
|
|||||||
# However they still provide a gcc symlink to llvm
|
# However they still provide a gcc symlink to llvm
|
||||||
# But we don't want LLVM of course.
|
# But we don't want LLVM of course.
|
||||||
|
|
||||||
self['CC'] = MacOS.locate "gcc-4.2"
|
self['CC'] = self['OBJC'] = MacOS.locate("gcc-4.2")
|
||||||
self['CXX'] = MacOS.locate "g++-4.2"
|
self['CXX'] = self['OBJCXX'] = MacOS.locate("g++-4.2")
|
||||||
self['OBJC'] = self['CC']
|
|
||||||
|
|
||||||
unless self['CC']
|
unless self['CC']
|
||||||
self['CC'] = "#{HOMEBREW_PREFIX}/bin/gcc-4.2"
|
self['CC'] = self['OBJC'] = "#{HOMEBREW_PREFIX}/bin/gcc-4.2"
|
||||||
self['CXX'] = "#{HOMEBREW_PREFIX}/bin/g++-4.2"
|
self['CXX'] = self['OBJCXX'] = "#{HOMEBREW_PREFIX}/bin/g++-4.2"
|
||||||
self['OBJC'] = self['CC']
|
|
||||||
raise "GCC could not be found" unless File.exist? self['CC']
|
raise "GCC could not be found" unless File.exist? self['CC']
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -161,17 +158,15 @@ module HomebrewEnvExtension
|
|||||||
alias_method :gcc_4_2, :gcc
|
alias_method :gcc_4_2, :gcc
|
||||||
|
|
||||||
def llvm
|
def llvm
|
||||||
self['CC'] = MacOS.locate "llvm-gcc"
|
self['CC'] = self['OBJC'] = MacOS.locate("llvm-gcc")
|
||||||
self['CXX'] = MacOS.locate "llvm-g++"
|
self['CXX'] = self['OBJCXX'] = MacOS.locate("llvm-g++")
|
||||||
self['OBJC'] = self['CC']
|
|
||||||
set_cpu_cflags 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott'
|
set_cpu_cflags 'core2 -msse4', :penryn => 'core2 -msse4.1', :core2 => 'core2', :core => 'prescott'
|
||||||
@compiler = :llvm
|
@compiler = :llvm
|
||||||
end
|
end
|
||||||
|
|
||||||
def clang
|
def clang
|
||||||
self['CC'] = MacOS.locate "clang"
|
self['CC'] = self['OBJC'] = MacOS.locate("clang")
|
||||||
self['CXX'] = MacOS.locate "clang++"
|
self['CXX'] = self['OBJCXX'] = MacOS.locate("clang++")
|
||||||
self['OBJC'] = self['CC']
|
|
||||||
replace_in_cflags(/-Xarch_i386 (-march=\S*)/, '\1')
|
replace_in_cflags(/-Xarch_i386 (-march=\S*)/, '\1')
|
||||||
# Clang mistakenly enables AES-NI on plain Nehalem
|
# Clang mistakenly enables AES-NI on plain Nehalem
|
||||||
set_cpu_cflags 'native', :nehalem => 'native -Xclang -target-feature -Xclang -aes'
|
set_cpu_cflags 'native', :nehalem => 'native -Xclang -target-feature -Xclang -aes'
|
||||||
@ -377,7 +372,7 @@ end
|
|||||||
|
|
||||||
class << ENV
|
class << ENV
|
||||||
def remove_cc_etc
|
def remove_cc_etc
|
||||||
keys = %w{CC CXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS}
|
keys = %w{CC CXX OBJC OBJCXX LD CPP CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS}
|
||||||
removed = Hash[*keys.map{ |key| [key, self[key]] }.flatten]
|
removed = Hash[*keys.map{ |key| [key, self[key]] }.flatten]
|
||||||
keys.each do |key|
|
keys.each do |key|
|
||||||
delete(key)
|
delete(key)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user