mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

This method takes an optional array of `Pathnames`s or `Strings`s and extracts the native slice from the specified universal binary. If no parameter is supplied, this is done on all compatible universal binaries in a formula's keg. `deuniversalize_machos` is a no-op on Linux. I still need to look into a) error handling, and b) whether using this method requires codesigning on ARM. I've also added signatures to the methods in `extend/os/linux/formula`.
40 lines
982 B
Ruby
40 lines
982 B
Ruby
# typed: true
|
|
# frozen_string_literal: true
|
|
|
|
class Formula
|
|
undef shared_library
|
|
undef rpath
|
|
undef deuniversalize_machos
|
|
|
|
sig { params(name: String, version: T.nilable(T.any(String, Integer))).returns(String) }
|
|
def shared_library(name, version = nil)
|
|
suffix = if version == "*" || (name == "*" && version.blank?)
|
|
"{,.*}"
|
|
elsif version.present?
|
|
".#{version}"
|
|
end
|
|
"#{name}.so#{suffix}"
|
|
end
|
|
|
|
sig { returns(String) }
|
|
def rpath
|
|
"'$ORIGIN/../lib'"
|
|
end
|
|
|
|
sig { params(targets: T.nilable(T.any(Pathname, String))).void }
|
|
def deuniversalize_machos(*targets); end
|
|
|
|
class << self
|
|
undef ignore_missing_libraries
|
|
|
|
def ignore_missing_libraries(*libs)
|
|
libraries = libs.flatten
|
|
if libraries.any? { |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
|
|
end
|
|
end
|