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