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
|
|
|
require 'superenv'
|
2010-09-11 20:22:54 +01:00
|
|
|
require 'hardware'
|
|
|
|
|
|
|
|
module Homebrew extend self
|
|
|
|
def __env
|
2012-08-22 12:40:53 -04:00
|
|
|
if superenv?
|
|
|
|
ENV.deps = ARGV.formulae.map(&:name) unless ARGV.named.empty?
|
|
|
|
end
|
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
|
2012-07-16 15:59:59 +02:00
|
|
|
%w[ CC CXX LD CFLAGS CXXFLAGS CPPFLAGS LDFLAGS SDKROOT
|
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
|
|
|
CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_FRAMEWORK_PATH MAKEFLAGS
|
2012-07-16 15:59:59 +02:00
|
|
|
MACOSX_DEPLOYMENT_TARGET PKG_CONFIG_PATH HOMEBREW_BUILD_FROM_SOURCE
|
|
|
|
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
|
2012-08-31 09:48:58 -04:00
|
|
|
HOMEBREW_SDKROOT
|
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
|
2012-07-16 15:59:59 +02:00
|
|
|
ACLOCAL_PATH OBJC PATH ].select{ |key| env[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|
|
|
|
|
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
|