Class: LibarchiveBinary::LibarchiveRecipe
- Inherits:
-
MiniPortileCMake
- Object
- MiniPortileCMake
- LibarchiveBinary::LibarchiveRecipe
- Defined in:
- lib/ffi-libarchive-binary/libarchive_recipe.rb
Constant Summary collapse
- ROOT =
Pathname.new(File.("../..", __dir__))
Instance Method Summary collapse
- #activate ⇒ Object
- #checkpoint ⇒ Object
- #configure_defaults ⇒ Object
- #cook ⇒ Object
- #cook_if_not ⇒ Object
- #create_dependencies ⇒ Object
- #default_flags ⇒ Object
- #generator_flags ⇒ Object
- #include_path ⇒ Object
-
#initialize ⇒ LibarchiveRecipe
constructor
A new instance of LibarchiveRecipe.
- #install ⇒ Object
- #lib_fullpath ⇒ Object
- #lib_workpath ⇒ Object
- #library_path ⇒ Object
- #message(text) ⇒ Object
- #target_format ⇒ Object
- #verify_lib ⇒ Object
Constructor Details
#initialize ⇒ LibarchiveRecipe
Returns a new instance of LibarchiveRecipe.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 15 def initialize super("libarchive", "3.7.7") @printed = {} @files << { url: "https://www.libarchive.org/downloads/libarchive-3.7.7.tar.gz", sha256: "4cc540a3e9a1eebdefa1045d2e4184831100667e6d7d5b315bb1cbc951f8ddff", } @target = ROOT.join(@target).to_s create_dependencies end |
Instance Method Details
#activate ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 73 def activate @zlib_recipe.activate @expat_recipe.activate @openssl_recipe.activate @xz_recipe.activate super end |
#checkpoint ⇒ Object
104 105 106 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 104 def checkpoint File.join(@target, "#{name}-#{version}-#{host}.installed") end |
#configure_defaults ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 53 def configure_defaults df = generator_flags + default_flags ar = ARCHS[host] if ar.nil? df else df + ["-DCMAKE_OSX_ARCHITECTURES=#{ar}"] end end |
#cook ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 86 def cook @zlib_recipe.host = @host if @host @zlib_recipe.cook_if_not @expat_recipe.host = @host if @host @expat_recipe.cook_if_not @openssl_recipe.host = @host if @host @openssl_recipe.cook_if_not @xz_recipe.host = @host if @host @xz_recipe.cook_if_not super FileUtils.touch(checkpoint) end |
#cook_if_not ⇒ Object
82 83 84 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 82 def cook_if_not cook unless File.exist?(checkpoint) end |
#create_dependencies ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 29 def create_dependencies @zlib_recipe = ZLibRecipe.new @expat_recipe = LibexpatRecipe.new @openssl_recipe = OpensslRecipe.new @xz_recipe = XZRecipe.new end |
#default_flags ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 40 def default_flags [ "-DENABLE_OPENSSL:BOOL=ON", "-DENABLE_LIBB2:BOOL=OFF", "-DENABLE_LZ4:BOOL=OFF", "-DENABLE_LZO::BOOL=OFF", "-DENABLE_LZMA:BOOL=ON", "-DENABLE_ZSTD:BOOL=OFF", "-DENABLE_ZLIB::BOOL=ON", "-DENABLE_BZip2:BOOL=OFF", "-DENABLE_LIBXML2:BOOL=OFF", "-DENABLE_EXPAT::BOOL=ON", "-DENABLE_TAR:BOOL=OFF", "-DENABLE_ICONV::BOOL=OFF", "-DENABLE_CPIO::BOOL=OFF", "-DENABLE_CAT:BOOL=OFF", "-DENABLE_ACL:BOOL=OFF", "-DENABLE_TEST:BOOL=OFF", "-DENABLE_UNZIP:BOOL=OFF", "-DCMAKE_INCLUDE_PATH=#{include_path}", "-DCMAKE_LIBRARY_PATH=#{library_path}" ] end |
#generator_flags ⇒ Object
36 37 38 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 36 def generator_flags MiniPortile::mingw? ? ["-G", "MSYS Makefiles"] : [] end |
#include_path ⇒ Object
63 64 65 66 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 63 def include_path paths = [@zlib_recipe.path, @expat_recipe.path, @openssl_recipe.path, @xz_recipe.path] paths.map { |k| "#{k}/include" }.join(";") end |
#install ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 108 def install super libs = Dir.glob(File.join(port_path, "{lib,bin}", "*")) .grep(/\/(?:lib)?[a-zA-Z0-9\-]+\.(?:so|dylib|dll)$/) FileUtils.cp_r(libs, lib_workpath, verbose: true) if lib_fullpath.nil? ("Cannot guess libarchive library name, skipping format verification") else verify_lib end end |
#lib_fullpath ⇒ Object
125 126 127 128 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 125 def lib_fullpath lib_filename = LIBNAMES[@host] @lib_fullpath ||= lib_filename.nil? ? nil : File.join(lib_workpath, lib_filename) end |
#lib_workpath ⇒ Object
121 122 123 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 121 def lib_workpath @lib_workpath ||= ROOT.join("lib", "ffi-libarchive-binary") end |
#library_path ⇒ Object
68 69 70 71 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 68 def library_path paths = [@zlib_recipe.path, @expat_recipe.path, @openssl_recipe.path, @xz_recipe.path] paths.map { |k| "#{k}/lib" }.join(";") end |
#message(text) ⇒ Object
148 149 150 151 152 153 154 155 156 157 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 148 def (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 |
#target_format ⇒ Object
144 145 146 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 144 def target_format @target_format ||= FORMATS[@host].nil? ? "skip" : FORMATS[@host] end |
#verify_lib ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 130 def verify_lib begin out, = Open3.capture2("file #{lib_fullpath}") rescue StandardError ("failed to call file, library verification skipped.\n") return end unless out.include?(target_format) raise "Invalid file format '#{out.strip}', '#{target_format}' expected" end ("#{lib_fullpath} format has been verified (#{target_format})\n") end |