Class: LibarchiveBinary::ZLibRecipe

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

Constant Summary collapse

ROOT =
Pathname.new(File.expand_path("../..", __dir__))

Instance Method Summary collapse

Methods inherited from BaseRecipe

#apple_arch_flag, #cflags, #ldflags, #message

Constructor Details

#initializeZLibRecipe

Returns a new instance of ZLibRecipe.



10
11
12
13
14
15
16
17
18
19
# File 'lib/ffi-libarchive-binary/zlib_recipe.rb', line 10

def initialize
  super("zlib", "1.3.1")

  @files << {
    url: "http://zlib.net/fossils/zlib-1.3.1.tar.gz",
    sha256: "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23",
  }

  @target = ROOT.join(@target).to_s
end

Instance Method Details

#checkpointObject



77
78
79
# File 'lib/ffi-libarchive-binary/zlib_recipe.rb', line 77

def checkpoint
  File.join(@target, "#{name}-#{version}-#{host}.installed")
end

#compileObject



61
62
63
64
65
66
67
# File 'lib/ffi-libarchive-binary/zlib_recipe.rb', line 61

def compile
  if MiniPortile::windows?
    execute("compile", "make -f win32/Makefile.gcc libz.a")
  else
    super
  end
end

#configureObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ffi-libarchive-binary/zlib_recipe.rb', line 39

def configure
  if MiniPortile::windows?
    Dir.chdir(work_path) do
      configure_windows
    end
  else
    cmd = ["env", cflags(host), ldflags(host),
           "./configure"] + computed_options
    execute("configure", cmd)
  end
end

#configure_defaultsObject



21
22
23
24
25
# File 'lib/ffi-libarchive-binary/zlib_recipe.rb', line 21

def configure_defaults
  [
    "--static",
  ]
end

#configure_windowsObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ffi-libarchive-binary/zlib_recipe.rb', line 27

def configure_windows
  mk = File.read("win32/Makefile.gcc")
  File.open("win32/Makefile.gcc", "wb") do |f|
    f.puts "BINARY_PATH = #{path}/bin"
    f.puts "LIBRARY_PATH = #{path}/lib"
    f.puts "INCLUDE_PATH = #{path}/include"
    f.puts "SHARED_MODE = 0"
    f.puts "LOC = -fPIC"
    f.puts mk
  end
end

#configured?Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
59
# File 'lib/ffi-libarchive-binary/zlib_recipe.rb', line 51

def configured?
  if MiniPortile::windows?
    Dir.chdir(work_path) do
      !!(File.read("win32/Makefile.gcc") =~ /^BINARY_PATH/)
    end
  else
    super
  end
end

#cookObject



85
86
87
88
89
# File 'lib/ffi-libarchive-binary/zlib_recipe.rb', line 85

def cook
  super

  FileUtils.touch(checkpoint)
end

#cook_if_notObject



81
82
83
# File 'lib/ffi-libarchive-binary/zlib_recipe.rb', line 81

def cook_if_not
  cook unless File.exist?(checkpoint)
end

#installObject



69
70
71
72
73
74
75
# File 'lib/ffi-libarchive-binary/zlib_recipe.rb', line 69

def install
  if MiniPortile::windows?
    execute("install", "make -f win32/Makefile.gcc install")
  else
    super
  end
end