formule: add generic shared-lib methods
We have strings containing hardcoded ".dylib" extensions in homebrew-core. To be able to bring linuxbrew-core and homebrew-core closer together, I am introducing a new generic attribute that can be used in formulae.
This commit is contained in:
parent
6b368304e3
commit
955bca6574
@ -1,6 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Formula
|
||||
undef shared_library
|
||||
|
||||
def shared_library(name, version = nil)
|
||||
"#{name}.so#{"." unless version.nil?}#{version}"
|
||||
end
|
||||
|
||||
class << self
|
||||
undef on_linux
|
||||
|
||||
|
@ -1402,6 +1402,10 @@ class Formula
|
||||
["--prefix=#{prefix}", "--libdir=#{lib}"]
|
||||
end
|
||||
|
||||
def shared_library(name, version = nil)
|
||||
"#{name}.#{version}#{"." unless version.nil?}dylib"
|
||||
end
|
||||
|
||||
# an array of all core {Formula} names
|
||||
# @private
|
||||
def self.core_names
|
||||
|
@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "test/support/fixtures/testball"
|
||||
require "formula"
|
||||
|
||||
describe Formula do
|
||||
@ -101,4 +102,12 @@ describe Formula do
|
||||
expect(f.resources.first.url).to eq("on_linux")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#shared_library" do
|
||||
it "generates a shared library string" do
|
||||
f = Testball.new
|
||||
expect(f.shared_library("foobar")).to eq("foobar.so")
|
||||
expect(f.shared_library("foobar", 2)).to eq("foobar.so.2")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "test/support/fixtures/testball"
|
||||
require "formula"
|
||||
|
||||
describe Formula do
|
||||
@ -108,4 +109,12 @@ describe Formula do
|
||||
expect(f.resources.first.url).to eq("resource_macos")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#shared_library" do
|
||||
it "generates a shared library string" do
|
||||
f = Testball.new
|
||||
expect(f.shared_library("foobar")).to eq("foobar.dylib")
|
||||
expect(f.shared_library("foobar", 2)).to eq("foobar.2.dylib")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user