Move stdlib tracking postinstall

This moves stdlib tracking after the install completes, which allows
the tracking to have access to the actual stdlib in use.

This unfortunately means that builds can error out *after* a build,
resulting in wasted time; however, it reduces false positives, and the
overall user experience is still likely to be better this way.
This commit is contained in:
Misty De Meo 2013-10-22 22:21:59 -07:00
parent 71fcefc613
commit 3657393017
3 changed files with 14 additions and 28 deletions

View File

@ -141,17 +141,6 @@ class Build
end end
end end
# TODO Track user-selected stdlibs, such as boost in C++11 mode
stdlib = ENV.compiler == :clang ? MacOS.default_cxx_stdlib : :libstdcxx
stdlib_in_use = CxxStdlib.new(stdlib, ENV.compiler)
# This is a bad place for this check, but we don't have access to
# compiler selection within the formula installer, only inside the
# build instance.
# This is also awkward because we don't actually know yet if this package
# will link against a C++ stdlib, but we don't want to test after the build.
stdlib_in_use.check_dependencies(f, deps)
f.brew do f.brew do
if ARGV.flag? '--git' if ARGV.flag? '--git'
system "git init" system "git init"
@ -174,7 +163,17 @@ class Build
begin begin
f.install f.install
Tab.create(f, ENV.compiler,
stdlibs = Keg.new(f.prefix).detect_cxx_stdlibs
# It's technically possible for the same lib to link to multiple
# C++ stdlibs, but very bad news. Right now we don't track this
# woeful scenario.
stdlib_in_use = CxxStdlib.new(stdlibs.first, ENV.compiler)
# This will raise and fail the build if there's an
# incompatibility.
stdlib_in_use.check_dependencies(f, deps)
Tab.create(f, ENV.compiler, stdlibs.first,
Options.coerce(ARGV.options_only)).write Options.coerce(ARGV.options_only)).write
rescue Exception => e rescue Exception => e
if ARGV.debug? if ARGV.debug?

View File

@ -386,8 +386,6 @@ class FormulaInstaller
fix_install_names if OS.mac? fix_install_names if OS.mac?
record_cxx_stdlib
ohai "Summary" if ARGV.verbose? or show_summary_heading ohai "Summary" if ARGV.verbose? or show_summary_heading
unless ENV['HOMEBREW_NO_EMOJI'] unless ENV['HOMEBREW_NO_EMOJI']
print "\xf0\x9f\x8d\xba " if MacOS.version >= :lion print "\xf0\x9f\x8d\xba " if MacOS.version >= :lion
@ -529,18 +527,6 @@ class FormulaInstaller
@show_summary_heading = true @show_summary_heading = true
end end
def record_cxx_stdlib
stdlibs = Keg.new(f.prefix).detect_cxx_stdlibs
return if stdlibs.empty?
tab = Tab.for_keg f.prefix
tab.tabfile.delete if tab.tabfile
# It's technically possible for the same lib to link to multiple C++ stdlibs,
# but very bad news. Right now we don't track this woeful scenario.
tab.stdlib = stdlibs.first
tab.write
end
def clean def clean
ohai "Cleaning" if ARGV.verbose? ohai "Cleaning" if ARGV.verbose?
if f.class.skip_clean_all? if f.class.skip_clean_all?

View File

@ -10,7 +10,7 @@ require 'utils/json'
class Tab < OpenStruct class Tab < OpenStruct
FILENAME = 'INSTALL_RECEIPT.json' FILENAME = 'INSTALL_RECEIPT.json'
def self.create f, compiler, args def self.create f, compiler, stdlib, args
f.build.args = args f.build.args = args
sha = HOMEBREW_REPOSITORY.cd do sha = HOMEBREW_REPOSITORY.cd do
@ -25,7 +25,8 @@ class Tab < OpenStruct
:tapped_from => f.tap, :tapped_from => f.tap,
:time => Time.now.to_i, # to_s would be better but Ruby has no from_s function :P :time => Time.now.to_i, # to_s would be better but Ruby has no from_s function :P
:HEAD => sha, :HEAD => sha,
:compiler => compiler :compiler => compiler,
:stdlib => stdlib
end end
def self.from_file path def self.from_file path