Add no-Xcode documentation for all classes, methods

This commit is contained in:
William Woodruff 2015-08-12 14:57:54 -04:00 committed by Misty De Meo
parent 1face808f5
commit 8793a68ee4
5 changed files with 28 additions and 2 deletions

View File

@ -200,7 +200,8 @@ module HomebrewArgvExtension
value "env" value "env"
end end
# collect any supplied build flags into an array for reporting # If the user passes any flags that trigger building over installing from
# a bottle, they are collected here and returned as an Array for checking.
def collect_build_flags def collect_build_flags
build_flags = [] build_flags = []

View File

@ -56,7 +56,9 @@ class FormulaInstaller
@pour_failed = false @pour_failed = false
end end
# called by install/reinstall/upgrade when no build tools are available # When no build tools are available and build flags are passed through ARGV,
# it's necessary to interrupt the user before any sort of installation
# can proceed. Only invoked when the user has no developer tools.
def self.prevent_build_flags def self.prevent_build_flags
build_flags = ARGV.collect_build_flags build_flags = ARGV.collect_build_flags
@ -232,6 +234,8 @@ class FormulaInstaller
raise FormulaConflictError.new(formula, conflicts) unless conflicts.empty? raise FormulaConflictError.new(formula, conflicts) unless conflicts.empty?
end end
# Compute and collect the dependencies needed by the formula currently
# being installed.
def compute_dependencies def compute_dependencies
req_map, req_deps = expand_requirements req_map, req_deps = expand_requirements
check_requirements(req_map) check_requirements(req_map)
@ -240,6 +244,9 @@ class FormulaInstaller
deps deps
end end
# Check that each dependency in deps has a bottle available, terminating
# abnormally with a BuildToolsError if one or more don't.
# Only invoked when the user has no developer tools.
def check_dependencies_bottled(deps) def check_dependencies_bottled(deps)
unbottled = deps.select do |dep, _| unbottled = deps.select do |dep, _|
formula = dep.to_formula formula = dep.to_formula
@ -352,6 +359,10 @@ class FormulaInstaller
@show_header = true unless deps.empty? @show_header = true unless deps.empty?
end end
# Installs the relocation tools (as provided by the cctools formula) as a hard
# dependency for every formula installed from a bottle when the user has no
# developer tools. Invoked unless the formula explicitly sets
# :any_skip_relocation in its bottle DSL.
def install_relocation_tools def install_relocation_tools
cctools = CctoolsRequirement.new cctools = CctoolsRequirement.new
dependency = cctools.to_dependency dependency = cctools.to_dependency

View File

@ -36,6 +36,8 @@ module OS
end end
end end
# Locates a (working) copy of install_name_tool, guaranteed to function
# whether the user has developer tools installed or not.
def install_name_tool def install_name_tool
if File.executable?(path = "#{HOMEBREW_PREFIX}/opt/cctools/bin/install_name_tool") if File.executable?(path = "#{HOMEBREW_PREFIX}/opt/cctools/bin/install_name_tool")
Pathname.new(path) Pathname.new(path)
@ -44,6 +46,8 @@ module OS
end end
end end
# Locates a (working) copy of otool, guaranteed to function whether the user
# has developer tools installed or not.
def otool def otool
if File.executable?(path = "#{HOMEBREW_PREFIX}/opt/cctools/bin/otool") if File.executable?(path = "#{HOMEBREW_PREFIX}/opt/cctools/bin/otool")
Pathname.new(path) Pathname.new(path)
@ -52,6 +56,9 @@ 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? def has_apple_developer_tools?
Xcode.installed? || CLT.installed? Xcode.installed? || CLT.installed?
end end

View File

@ -1,3 +1,8 @@
# Represents a general requirement for utilities normally installed by Xcode,
# the CLT, or provided by the cctools formula. In particular, this requirement
# allows Homebrew to pull in the cctools formula and use its utilities to
# perform relocation operations on systems that do not have either Xcode or the
# CLT installed (but still want to install bottled formulae).
class CctoolsRequirement < Requirement class CctoolsRequirement < Requirement
fatal true fatal true
default_formula 'cctools' default_formula 'cctools'

View File

@ -245,6 +245,7 @@ class Bottle
@spec.compatible_cellar? @spec.compatible_cellar?
end end
# Does the bottle need to be relocated?
def skip_relocation? def skip_relocation?
@spec.skip_relocation? @spec.skip_relocation?
end end
@ -288,6 +289,7 @@ class BottleSpecification
cellar == :any || cellar == :any_skip_relocation || cellar == HOMEBREW_CELLAR.to_s cellar == :any || cellar == :any_skip_relocation || cellar == HOMEBREW_CELLAR.to_s
end end
# Does the Bottle this BottleSpecification belongs to need to be relocated?
def skip_relocation? def skip_relocation?
cellar == :any_skip_relocation cellar == :any_skip_relocation
end end