development_tools: add installed? method. (#455)
This commit is contained in:
parent
11624b9a7d
commit
3a127e405e
@ -96,7 +96,7 @@ module Homebrew
|
||||
|
||||
# if the user's flags will prevent bottle only-installations when no
|
||||
# developer tools are available, we need to stop them early on
|
||||
FormulaInstaller.prevent_build_flags unless MacOS.has_apple_developer_tools?
|
||||
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
|
||||
|
||||
ARGV.formulae.each do |f|
|
||||
# head-only without --HEAD is an error
|
||||
|
@ -5,7 +5,7 @@ require "formula_installer"
|
||||
|
||||
module Homebrew
|
||||
def reinstall
|
||||
FormulaInstaller.prevent_build_flags unless MacOS.has_apple_developer_tools?
|
||||
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
|
||||
|
||||
ARGV.resolved_formulae.each { |f| reinstall_formula(f) }
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ require "cleanup"
|
||||
|
||||
module Homebrew
|
||||
def upgrade
|
||||
FormulaInstaller.prevent_build_flags unless MacOS.has_apple_developer_tools?
|
||||
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
|
||||
|
||||
Homebrew.perform_preinstall_checks
|
||||
|
||||
|
@ -90,5 +90,9 @@ module OS
|
||||
def clang_build_version
|
||||
DevelopmentTools.clang_build_version
|
||||
end
|
||||
|
||||
def has_apple_developer_tools?
|
||||
DevelopmentTools.installed?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
require "extend/ENV/shared"
|
||||
require "development_tools"
|
||||
|
||||
# ### Why `superenv`?
|
||||
#
|
||||
@ -26,7 +27,7 @@ module Superenv
|
||||
|
||||
# @private
|
||||
def self.bin
|
||||
return unless MacOS.has_apple_developer_tools?
|
||||
return unless DevelopmentTools.installed?
|
||||
|
||||
bin = HOMEBREW_ENV_PATH.subdirs.reject { |d| d.basename.to_s > MacOS::Xcode.version }.max
|
||||
bin.realpath unless bin.nil?
|
||||
|
@ -1,3 +1,5 @@
|
||||
require "os/mac/xcode"
|
||||
|
||||
# @private
|
||||
class DevelopmentTools
|
||||
class << self
|
||||
@ -13,6 +15,13 @@ class DevelopmentTools
|
||||
end
|
||||
end
|
||||
|
||||
# Checks if the user has any developer tools installed, either via Xcode
|
||||
# or the CLT. Convenient for guarding against formula builds when building
|
||||
# is impossible.
|
||||
def installed?
|
||||
MacOS::Xcode.installed? || MacOS::CLT.installed?
|
||||
end
|
||||
|
||||
def default_compiler
|
||||
case default_cc
|
||||
# if GCC 4.2 is installed, e.g. via Tigerbrew, prefer it
|
||||
|
@ -178,13 +178,13 @@ class FormulaInstaller
|
||||
|
||||
check_conflicts
|
||||
|
||||
if !pour_bottle? && !formula.bottle_unneeded? && !MacOS.has_apple_developer_tools?
|
||||
if !pour_bottle? && !formula.bottle_unneeded? && !DevelopmentTools.installed?
|
||||
raise BuildToolsError.new([formula])
|
||||
end
|
||||
|
||||
unless skip_deps_check?
|
||||
deps = compute_dependencies
|
||||
check_dependencies_bottled(deps) if pour_bottle? && !MacOS.has_apple_developer_tools?
|
||||
check_dependencies_bottled(deps) if pour_bottle? && !DevelopmentTools.installed?
|
||||
install_dependencies(deps)
|
||||
end
|
||||
|
||||
@ -223,7 +223,7 @@ class FormulaInstaller
|
||||
@pour_failed = true
|
||||
onoe e.message
|
||||
opoo "Bottle installation failed: building from source."
|
||||
raise BuildToolsError.new([formula]) unless MacOS.has_apple_developer_tools?
|
||||
raise BuildToolsError.new([formula]) unless DevelopmentTools.installed?
|
||||
else
|
||||
@poured_bottle = true
|
||||
end
|
||||
|
@ -61,13 +61,6 @@ module OS
|
||||
end
|
||||
end
|
||||
|
||||
# Checks if the user has any developer tools installed, either via Xcode
|
||||
# or the CLT. Convenient for guarding against formula builds when building
|
||||
# is impossible.
|
||||
def has_apple_developer_tools?
|
||||
Xcode.installed? || CLT.installed?
|
||||
end
|
||||
|
||||
def active_developer_dir
|
||||
@active_developer_dir ||= Utils.popen_read("/usr/bin/xcode-select", "-print-path").strip
|
||||
end
|
||||
|
@ -62,7 +62,7 @@ class InstallTests < Homebrew::TestCase
|
||||
end
|
||||
|
||||
def test_bottle_unneeded_formula_install
|
||||
MacOS.stubs(:has_apple_developer_tools?).returns(false)
|
||||
DevelopmentTools.stubs(:installed?).returns(false)
|
||||
|
||||
formula = Testball.new
|
||||
formula.stubs(:bottle_unneeded?).returns(true)
|
||||
|
@ -36,7 +36,7 @@ class InstallBottleTests < Homebrew::TestCase
|
||||
end
|
||||
|
||||
def test_a_basic_bottle_install
|
||||
MacOS.stubs(:has_apple_developer_tools?).returns(false)
|
||||
DevelopmentTools.stubs(:installed?).returns(false)
|
||||
|
||||
temporary_bottle_install(TestballBottle.new) do |f|
|
||||
# Copied directly from test_formula_installer.rb as we expect
|
||||
@ -59,7 +59,7 @@ class InstallBottleTests < Homebrew::TestCase
|
||||
end
|
||||
|
||||
def test_build_tools_error
|
||||
MacOS.stubs(:has_apple_developer_tools?).returns(false)
|
||||
DevelopmentTools.stubs(:installed?).returns(false)
|
||||
|
||||
# Testball doesn't have a bottle block, so use it to test this behavior
|
||||
formula = Testball.new
|
||||
|
Loading…
x
Reference in New Issue
Block a user