2017-12-23 16:38:06 +00:00
|
|
|
require "requirement"
|
|
|
|
|
|
|
|
class XcodeRequirement < Requirement
|
|
|
|
fatal true
|
|
|
|
|
|
|
|
satisfy(build_env: false) { xcode_installed_version }
|
|
|
|
|
2017-12-30 18:58:30 +00:00
|
|
|
def initialize(tags = [])
|
2018-10-19 16:38:41 +01:00
|
|
|
@version = tags.shift if tags.first.to_s.match?(/(\d\.)+\d/)
|
|
|
|
super(tags)
|
2017-12-23 16:38:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def xcode_installed_version
|
|
|
|
return false unless MacOS::Xcode.installed?
|
|
|
|
return true unless @version
|
2018-09-17 02:45:00 +02:00
|
|
|
|
2017-12-23 16:38:06 +00:00
|
|
|
MacOS::Xcode.version >= @version
|
|
|
|
end
|
|
|
|
|
|
|
|
def message
|
|
|
|
version = " #{@version}" if @version
|
|
|
|
message = <<~EOS
|
|
|
|
A full installation of Xcode.app#{version} is required to compile this software.
|
|
|
|
Installing just the Command Line Tools is not sufficient.
|
|
|
|
EOS
|
2018-02-09 19:37:15 +00:00
|
|
|
if @version && Version.new(MacOS::Xcode.latest_version) < Version.new(@version)
|
2018-01-28 19:08:19 +00:00
|
|
|
message + <<~EOS
|
|
|
|
Xcode#{version} cannot be installed on macOS #{MacOS.version}.
|
|
|
|
You must upgrade your version of macOS.
|
|
|
|
EOS
|
2017-12-23 16:38:06 +00:00
|
|
|
else
|
|
|
|
message + <<~EOS
|
2019-01-26 17:13:14 +00:00
|
|
|
Xcode can be installed from the App Store.
|
2017-12-23 16:38:06 +00:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def inspect
|
2018-10-19 16:38:41 +01:00
|
|
|
"#<#{self.class.name}: #{tags.inspect} version=#{@version.inspect}>"
|
2017-12-23 16:38:06 +00:00
|
|
|
end
|
|
|
|
end
|