Merge pull request #7751 from iMichka/shared

formulae: add generic shared_library_extension
This commit is contained in:
Michka Popoff 2020-06-22 18:25:35 +02:00 committed by GitHub
commit a5025e9a9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 0 deletions

View File

@ -1,6 +1,12 @@
# frozen_string_literal: true # frozen_string_literal: true
class Formula class Formula
undef shared_library
def shared_library(name, version = nil)
"#{name}.so#{"." unless version.nil?}#{version}"
end
class << self class << self
undef on_linux undef on_linux

View File

@ -1407,6 +1407,10 @@ class Formula
["--prefix=#{prefix}", "--libdir=#{lib}"] ["--prefix=#{prefix}", "--libdir=#{lib}"]
end end
def shared_library(name, version = nil)
"#{name}.#{version}#{"." unless version.nil?}dylib"
end
# an array of all core {Formula} names # an array of all core {Formula} names
# @private # @private
def self.core_names def self.core_names

View File

@ -1,5 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "test/support/fixtures/testball"
require "formula" require "formula"
describe Formula do describe Formula do
@ -101,4 +102,12 @@ describe Formula do
expect(f.resources.first.url).to eq("on_linux") expect(f.resources.first.url).to eq("on_linux")
end end
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 end

View File

@ -1,5 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "test/support/fixtures/testball"
require "formula" require "formula"
describe Formula do describe Formula do
@ -108,4 +109,12 @@ describe Formula do
expect(f.resources.first.url).to eq("resource_macos") expect(f.resources.first.url).to eq("resource_macos")
end end
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 end