Class: LibarchiveBinary::BaseRecipe

Inherits:
MiniPortile
  • Object
show all
Defined in:
lib/ffi-libarchive-binary/base_recipe.rb

Direct Known Subclasses

LibexpatRecipe, OpensslRecipe, XZRecipe, ZLibRecipe

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ BaseRecipe

Returns a new instance of BaseRecipe.



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ffi-libarchive-binary/base_recipe.rb', line 31

def initialize(name)
  library = LibarchiveBinary.library_for(name)
  version = library["version"]
  super(name, version)
  @target = ROOT.join(@target).to_s
  @files << {
    url: library["url"],
    sha256: library["sha256"],
  }
  @printed = {}
end

Instance Method Details

#apple_arch_flag(host) ⇒ Object



43
44
45
46
# File 'lib/ffi-libarchive-binary/base_recipe.rb', line 43

def apple_arch_flag(host)
  fl = ARCHS[host]
  fl.nil? ? "" : " -arch #{fl}"
end

#cflags(host) ⇒ Object



48
49
50
# File 'lib/ffi-libarchive-binary/base_recipe.rb', line 48

def cflags(host)
  "CFLAGS=-fPIC#{apple_arch_flag(host)}"
end

#ldflags(host) ⇒ Object



52
53
54
# File 'lib/ffi-libarchive-binary/base_recipe.rb', line 52

def ldflags(host)
  "LDFLAGS=-fPIC#{apple_arch_flag(host)}"
end

#message(text) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/ffi-libarchive-binary/base_recipe.rb', line 56

def message(text)
  return super unless text.start_with?("\rDownloading")

  match = text.match(/(\rDownloading .*)\((\s*)(\d+)%\)/)
  pattern = match ? match[1] : text
  return if @printed[pattern] && match[3].to_i != 100

  @printed[pattern] = true
  super
end