2013-08-19 12:32:57 -05:00
|
|
|
require 'extend/ENV'
|
2010-09-11 20:22:54 +01:00
|
|
|
require 'hardware'
|
|
|
|
|
|
|
|
module Homebrew extend self
|
|
|
|
def __env
|
2013-08-19 12:32:56 -05:00
|
|
|
ENV.activate_extensions!
|
|
|
|
|
2012-08-22 12:40:53 -04:00
|
|
|
if superenv?
|
|
|
|
ENV.deps = ARGV.formulae.map(&:name) unless ARGV.named.empty?
|
|
|
|
end
|
2013-08-19 13:03:41 -05:00
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
ENV.setup_build_environment
|
2011-12-31 21:22:22 -06:00
|
|
|
ENV.universal_binary if ARGV.build_universal?
|
2012-03-02 00:59:22 +00:00
|
|
|
if $stdout.tty?
|
|
|
|
dump_build_env ENV
|
|
|
|
else
|
2012-08-22 12:40:53 -04:00
|
|
|
keys = build_env_keys(ENV) << 'HOMEBREW_BREW_FILE' << 'HOMEBREW_SDKROOT'
|
|
|
|
keys.each do |key|
|
2012-03-02 00:59:22 +00:00
|
|
|
puts "export #{key}=\"#{ENV[key]}\""
|
|
|
|
end
|
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
|
2012-03-02 00:59:22 +00:00
|
|
|
def build_env_keys env
|
2013-05-02 11:36:30 -07:00
|
|
|
%w[
|
2013-11-07 14:35:56 -06:00
|
|
|
CC CXX LD OBJC OBJCXX
|
|
|
|
HOMEBREW_CC HOMEBREW_CXX
|
2013-05-02 11:36:30 -07:00
|
|
|
CFLAGS CXXFLAGS CPPFLAGS LDFLAGS SDKROOT MAKEFLAGS
|
2012-08-31 14:12:03 -04:00
|
|
|
CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_LIBRARY_PATH CMAKE_FRAMEWORK_PATH
|
2013-03-08 18:14:00 -06:00
|
|
|
MACOSX_DEPLOYMENT_TARGET PKG_CONFIG_PATH PKG_CONFIG_LIBDIR
|
2012-07-16 15:59:59 +02:00
|
|
|
HOMEBREW_DEBUG HOMEBREW_MAKE_JOBS HOMEBREW_VERBOSE HOMEBREW_USE_CLANG
|
2012-08-28 09:50:03 -04:00
|
|
|
HOMEBREW_USE_GCC HOMEBREW_USE_LLVM HOMEBREW_SVN HOMEBREW_GIT
|
2013-03-08 18:14:00 -06:00
|
|
|
HOMEBREW_SDKROOT HOMEBREW_BUILD_FROM_SOURCE
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
MAKE GIT CPP
|
2013-11-07 14:35:56 -06:00
|
|
|
ACLOCAL_PATH PATH CPATH].select{ |key| env.fetch(key) if env.key? key }
|
2012-03-02 00:59:22 +00:00
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
|
2012-03-02 00:59:22 +00:00
|
|
|
def dump_build_env env
|
|
|
|
build_env_keys(env).each do |key|
|
2013-11-07 14:35:56 -06:00
|
|
|
next if superenv? and %w{CC CXX OBJC OBJCXX}.include? key
|
2013-05-02 11:36:30 -07:00
|
|
|
|
2012-03-02 00:59:22 +00:00
|
|
|
value = env[key]
|
|
|
|
print "#{key}: #{value}"
|
|
|
|
case key when 'CC', 'CXX', 'LD'
|
2012-02-21 10:32:48 +00:00
|
|
|
if value =~ %r{/usr/bin/xcrun (.*)}
|
2012-02-19 20:31:25 -06:00
|
|
|
path = `/usr/bin/xcrun -find #{$1}`
|
2012-03-02 00:59:22 +00:00
|
|
|
print " => #{path}"
|
|
|
|
elsif File.symlink? value
|
|
|
|
print " => #{Pathname.new(value).realpath}"
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
2012-03-01 14:07:40 +00:00
|
|
|
end
|
2012-03-02 00:59:22 +00:00
|
|
|
puts
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|