Maxim Belkin 7080ad5ebc formula.rb: update missing libs feature
1. Raise an exception on macOS.
2. Verify that the missing libraries are specified either as Strings or
   Regular Expressions.

Signed-off-by: Maxim Belkin <maxim.belkin@gmail.com>
2020-07-21 13:16:56 +00:00

51 lines
1.2 KiB
Ruby

# frozen_string_literal: true
class Formula
undef shared_library
def shared_library(name, version = nil)
"#{name}.so#{"." unless version.nil?}#{version}"
end
undef allowed_missing_lib?
def allowed_missing_lib?(lib)
# lib: Full path to the missing library
# Ex.: /home/linuxbrew/.linuxbrew/lib/libsomething.so.1
# x - Name of or a pattern for a library, linkage to which is allowed to be missing.
# Ex. 1: "libONE.so.1"
# Ex. 2: %r{(libONE|libTWO)\.so}
self.class.allowed_missing_libraries.any? do |x|
case x
when Regexp
x.match? lib
when String
lib.to_s.include? x
end
end
end
class << self
undef on_linux
def on_linux(&_block)
yield
end
undef ignore_missing_libraries
def ignore_missing_libraries(*libs)
libraries = libs.flatten
unless libraries.all? { |x| x.is_a?(String) || x.is_a?(Regexp) }
raise FormulaSpecificationError, "#{__method__} can handle Strings and Regular Expressions only"
end
allowed_missing_libraries.merge(libraries)
end
# @private
def allowed_missing_libraries
@allowed_missing_libraries ||= Set.new
end
end
end