2020-10-10 14:16:11 +02:00
|
|
|
# typed: true
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-23 16:38:06 +00:00
|
|
|
require "requirement"
|
|
|
|
|
2020-08-18 23:15:28 +02:00
|
|
|
# A requirement on a specific architecture.
|
|
|
|
#
|
|
|
|
# @api private
|
2017-12-23 16:38:06 +00:00
|
|
|
class ArchRequirement < Requirement
|
|
|
|
fatal true
|
|
|
|
|
2020-11-01 11:57:00 -05:00
|
|
|
attr_reader :arch
|
|
|
|
|
2018-10-19 16:38:41 +01:00
|
|
|
def initialize(tags)
|
|
|
|
@arch = tags.shift
|
|
|
|
super(tags)
|
2017-12-23 16:38:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
satisfy(build_env: false) do
|
|
|
|
case @arch
|
2020-11-01 11:57:00 -05:00
|
|
|
when :x86_64 then Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
|
2020-11-07 11:00:41 -05:00
|
|
|
when :arm64 then Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
|
2020-11-01 11:57:00 -05:00
|
|
|
when :arm, :intel, :ppc then Hardware::CPU.type == @arch
|
2017-12-23 16:38:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-20 12:03:48 +02:00
|
|
|
sig { returns(String) }
|
2017-12-23 16:38:06 +00:00
|
|
|
def message
|
2020-11-01 12:26:18 -05:00
|
|
|
"The #{@arch} architecture is required for this software."
|
2017-12-23 16:38:06 +00:00
|
|
|
end
|
2019-03-11 20:30:11 +11:00
|
|
|
|
2020-11-01 12:22:56 -05:00
|
|
|
def inspect
|
|
|
|
"#<#{self.class.name}: arch=#{@arch.to_s.inspect} #{tags.inspect}>"
|
|
|
|
end
|
|
|
|
|
2020-10-20 12:03:48 +02:00
|
|
|
sig { returns(String) }
|
2019-03-11 20:30:11 +11:00
|
|
|
def display_s
|
|
|
|
"#{@arch} architecture"
|
|
|
|
end
|
2017-12-23 16:38:06 +00:00
|
|
|
end
|