Skip to content

Commit

Permalink
Merge pull request #7751 from iMichka/shared
Browse files Browse the repository at this point in the history
formulae: add generic shared_library_extension
  • Loading branch information
iMichka authored Jun 22, 2020
2 parents 550ba8b + 955bca6 commit a5025e9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Library/Homebrew/extend/os/linux/formula.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,10 @@ def std_meson_args
["--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
Expand Down
9 changes: 9 additions & 0 deletions Library/Homebrew/test/os/linux/formula_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require "test/support/fixtures/testball"
require "formula"

describe Formula do
Expand Down Expand Up @@ -101,4 +102,12 @@
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
9 changes: 9 additions & 0 deletions Library/Homebrew/test/os/mac/formula_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require "test/support/fixtures/testball"
require "formula"

describe Formula do
Expand Down Expand Up @@ -108,4 +109,12 @@
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

0 comments on commit a5025e9

Please sign in to comment.