2025-06-17 16:34:59 +01:00
|
|
|
# typed: strict
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-23 16:38:06 +00:00
|
|
|
require "requirement"
|
|
|
|
|
2020-08-19 06:51:52 +02:00
|
|
|
# A requirement on Xcode.
|
2017-12-23 16:38:06 +00:00
|
|
|
class XcodeRequirement < Requirement
|
|
|
|
fatal true
|
|
|
|
|
2025-06-17 16:34:59 +01:00
|
|
|
sig { returns(T.nilable(String)) }
|
2020-03-02 16:29:49 -05:00
|
|
|
attr_reader :version
|
|
|
|
|
2023-02-14 15:39:32 -08:00
|
|
|
satisfy(build_env: false) do
|
|
|
|
T.bind(self, XcodeRequirement)
|
|
|
|
xcode_installed_version
|
|
|
|
end
|
2017-12-23 16:38:06 +00:00
|
|
|
|
2025-06-17 16:34:59 +01:00
|
|
|
sig { params(tags: T::Array[String]).void }
|
2017-12-30 18:58:30 +00:00
|
|
|
def initialize(tags = [])
|
2025-06-17 16:34:59 +01:00
|
|
|
version = tags.shift if tags.first.to_s.match?(/(\d\.)+\d/)
|
|
|
|
@version = T.let(version, T.nilable(String))
|
2024-05-23 17:08:41 +01:00
|
|
|
super
|
2017-12-23 16:38:06 +00:00
|
|
|
end
|
|
|
|
|
2020-11-25 17:03:23 +01:00
|
|
|
sig { returns(T::Boolean) }
|
2017-12-23 16:38:06 +00:00
|
|
|
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
|
|
|
|
|
2020-10-20 12:03:48 +02:00
|
|
|
sig { returns(String) }
|
2017-12-23 16:38:06 +00:00
|
|
|
def message
|
|
|
|
version = " #{@version}" if @version
|
|
|
|
message = <<~EOS
|
2019-04-04 08:34:25 +01:00
|
|
|
A full installation of Xcode.app#{version} is required to compile
|
|
|
|
this software. Installing just the Command Line Tools is not sufficient.
|
2017-12-23 16:38:06 +00:00
|
|
|
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
|
2019-04-04 08:34:25 +01:00
|
|
|
|
2018-01-28 19:08:19 +00:00
|
|
|
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-04-04 08:34:25 +01:00
|
|
|
|
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
|
|
|
|
|
2020-10-20 12:03:48 +02:00
|
|
|
sig { returns(String) }
|
2017-12-23 16:38:06 +00:00
|
|
|
def inspect
|
2020-11-01 12:22:56 -05:00
|
|
|
"#<#{self.class.name}: version>=#{@version.inspect} #{tags.inspect}>"
|
2017-12-23 16:38:06 +00:00
|
|
|
end
|
2020-11-01 12:02:13 -05:00
|
|
|
|
2025-06-17 16:34:59 +01:00
|
|
|
sig { returns(String) }
|
2020-11-01 12:02:13 -05:00
|
|
|
def display_s
|
2023-03-02 23:28:00 -05:00
|
|
|
return "#{name.capitalize} (on macOS)" unless @version
|
2020-11-01 12:02:13 -05:00
|
|
|
|
2023-03-02 23:28:00 -05:00
|
|
|
"#{name.capitalize} >= #{@version} (on macOS)"
|
2020-11-01 12:02:13 -05:00
|
|
|
end
|
2017-12-23 16:38:06 +00:00
|
|
|
end
|
2020-10-13 07:50:40 +02:00
|
|
|
|
|
|
|
require "extend/os/requirements/xcode_requirement"
|