Formula: ignore_missing_libraries DSL
This commit is contained in:
parent
e7b3b8e559
commit
c61aba4ec3
@ -7,11 +7,37 @@ class Formula
|
|||||||
"#{name}.so#{"." unless version.nil?}#{version}"
|
"#{name}.so#{"." unless version.nil?}#{version}"
|
||||||
end
|
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|
|
||||||
|
if x.is_a? Regexp
|
||||||
|
x.match? lib
|
||||||
|
elsif x.is_a? String
|
||||||
|
lib.include? x
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
undef on_linux
|
undef on_linux
|
||||||
|
|
||||||
def on_linux(&_block)
|
def on_linux(&_block)
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ignore_missing_libraries(*libs)
|
||||||
|
libs.flatten!
|
||||||
|
allowed_missing_libraries.merge(libs)
|
||||||
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
def allowed_missing_libraries
|
||||||
|
@allowed_missing_libraries ||= Set.new
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1131,10 +1131,10 @@ class Formula
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Whether this {Formula} is allowed to have broken linkage.
|
# Whether this {Formula} is allowed to have a broken linkage to specified library.
|
||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def allow_missing_libs?
|
def allowed_missing_lib?(*)
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2603,10 +2603,6 @@ class Formula
|
|||||||
@skip_clean_paths ||= Set.new
|
@skip_clean_paths ||= Set.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def allow_missing_libs
|
|
||||||
define_method(:allow_missing_libs?) { true }
|
|
||||||
end
|
|
||||||
|
|
||||||
# Software that will not be symlinked into the `brew --prefix` will only
|
# Software that will not be symlinked into the `brew --prefix` will only
|
||||||
# live in its Cellar. Other formulae can depend on it and then brew will
|
# live in its Cellar. Other formulae can depend on it and then brew will
|
||||||
# add the necessary includes and libs (etc.) during the brewing of that
|
# add the necessary includes and libs (etc.) during the brewing of that
|
||||||
|
@ -55,24 +55,35 @@ class LinkageChecker
|
|||||||
end
|
end
|
||||||
|
|
||||||
def display_test_output(puts_output: true)
|
def display_test_output(puts_output: true)
|
||||||
display_items "Missing libraries", @broken_dylibs, puts_output: puts_output
|
display_items "Missing libraries", broken_dylibs_with_expectations, puts_output: puts_output
|
||||||
display_items "Broken dependencies", @broken_deps, puts_output: puts_output
|
display_items "Broken dependencies", @broken_deps, puts_output: puts_output
|
||||||
display_items "Unwanted system libraries", @unwanted_system_dylibs, puts_output: puts_output
|
display_items "Unwanted system libraries", @unwanted_system_dylibs, puts_output: puts_output
|
||||||
display_items "Conflicting libraries", @version_conflict_deps, puts_output: puts_output
|
display_items "Conflicting libraries", @version_conflict_deps, puts_output: puts_output
|
||||||
if got_library_issues?
|
|
||||||
puts "Broken library linkage ignored" if @formula.allow_missing_libs?
|
if @broken_dylibs.empty?
|
||||||
|
puts "No broken library linkage detected"
|
||||||
|
elsif unexpected_broken_libs.empty?
|
||||||
|
puts "No unexpected broken library linkage detected."
|
||||||
else
|
else
|
||||||
puts "No broken library linkage"
|
puts "Broken library linkage detected"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def broken_library_linkage?
|
def broken_library_linkage?
|
||||||
!@formula.allow_missing_libs? && got_library_issues?
|
issues = [@broken_deps, @unwanted_system_dylibs, @version_conflict_deps]
|
||||||
|
[issues, unexpected_broken_libs].flatten.any?(&:present?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def got_library_issues?
|
def unexpected_broken_libs
|
||||||
issues = [@broken_dylibs, @broken_deps, @unwanted_system_dylibs, @version_conflict_deps]
|
@broken_dylibs.reject { |lib| @formula.allowed_missing_lib? lib }
|
||||||
issues.any?(&:present?)
|
end
|
||||||
|
|
||||||
|
def broken_dylibs_with_expectations
|
||||||
|
output = {}
|
||||||
|
@broken_dylibs.each do |lib|
|
||||||
|
output[lib] = (unexpected_broken_libs.include? lib) ? ["unexpected"] : ["expected"]
|
||||||
|
end
|
||||||
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
Loading…
x
Reference in New Issue
Block a user