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__))
- NAME =
"libarchive"
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
- #libraries ⇒ Object
- #library_for(libname) ⇒ Object
- #library_path ⇒ Object
- #message(text) ⇒ Object
- #target_format ⇒ Object
- #verify_lib ⇒ Object
Constructor Details
#initialize ⇒ LibarchiveRecipe
Returns a new instance of LibarchiveRecipe.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 17 def initialize = LibarchiveBinary.library_for(NAME) super(NAME, ["version"]) @printed = {} @files << { url: ["url"], sha256: ["sha256"], } @target = ROOT.join(@target).to_s create_dependencies end |
Instance Method Details
#activate ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 83 def activate @zlib_recipe.activate @expat_recipe.activate @openssl_recipe.activate @xz_recipe.activate super end |
#checkpoint ⇒ Object
118 119 120 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 118 def checkpoint File.join(@target, "#{name}-#{version}-#{host}.installed") end |
#configure_defaults ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 64 def configure_defaults df = generator_flags + default_flags ar = ARCHS[host] df += ["-DCMAKE_OSX_ARCHITECTURES=#{ar}"] if ar df end |
#cook ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 96 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 # Set explicit LZMA environment variables for libarchive configure ENV['LIBLZMA_CFLAGS'] = "-I#{@xz_recipe.path}/include" ENV['LIBLZMA_LIBS'] = "-L#{@xz_recipe.path}/lib -llzma" super FileUtils.touch(checkpoint) end |
#cook_if_not ⇒ Object
92 93 94 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 92 def cook_if_not cook unless File.exist?(checkpoint) end |
#create_dependencies ⇒ Object
32 33 34 35 36 37 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 32 def create_dependencies @zlib_recipe = ZLibRecipe.new @expat_recipe = LibexpatRecipe.new @openssl_recipe = OpensslRecipe.new @xz_recipe = XZRecipe.new end |
#default_flags ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 43 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_CPIO::BOOL=OFF", "-DENABLE_CAT:BOOL=OFF", "-DENABLE_ACL:BOOL=OFF", "-DENABLE_TEST:BOOL=OFF", "-DENABLE_UNZIP:BOOL=OFF", "-DOPENSSL_USE_STATIC_LIBS=ON", "-DENABLE_XAR:BOOL=ON", # Provide root directories - let CMake find libraries in lib or lib64 "-DOPENSSL_ROOT_DIR:PATH=#{@openssl_recipe.path}", # Add include paths to C flags so CMake's header detection can find them "-DCMAKE_C_FLAGS=-I#{@expat_recipe.path}/include -I#{@openssl_recipe.path}/include -I#{@xz_recipe.path}/include -I#{@zlib_recipe.path}/include", # Provide search paths for CMake to find libraries "-DCMAKE_INCLUDE_PATH:STRING=#{include_path}", "-DCMAKE_LIBRARY_PATH:STRING=#{library_path}" ] end |
#generator_flags ⇒ Object
39 40 41 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 39 def generator_flags MiniPortile::mingw? ? ["-G", "MSYS Makefiles"] : [] end |
#include_path ⇒ Object
73 74 75 76 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 73 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
122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 122 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
139 140 141 142 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 139 def lib_fullpath lib_filename = LIBNAMES[@host] @lib_fullpath ||= lib_filename.nil? ? nil : File.join(lib_workpath, lib_filename) end |
#lib_workpath ⇒ Object
135 136 137 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 135 def lib_workpath @lib_workpath ||= ROOT.join("lib", "ffi-libarchive-binary") end |
#libraries ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 144 def libraries configuration_file = File.join(File.dirname(__FILE__), "..", "..", "ext", "configuration.yml") @libraries ||= ::YAML.load_file(configuration_file)["libraries"] || {} rescue Psych::SyntaxError => e puts "Warning: The configuration file '#{configuration_file}' contains invalid YAML syntax." puts e. exit 1 rescue StandardError => e puts "An unexpected error occurred while loading the configuration file '#{configuration_file}'." puts e. exit 1 end |
#library_for(libname) ⇒ Object
157 158 159 160 161 162 163 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 157 def library_for(libname) libraries[libname][MiniPortile::windows? ? "windows" : "all"] rescue StandardError => e puts "Failed to load library configuration for '#{libname}'." puts e. exit 1 end |
#library_path ⇒ Object
78 79 80 81 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 78 def library_path paths = [@zlib_recipe.path, @expat_recipe.path, @openssl_recipe.path, @xz_recipe.path] paths.map { |k| "#{k}/lib;#{k}/lib64" }.join(";") end |
#message(text) ⇒ Object
183 184 185 186 187 188 189 190 191 192 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 183 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
179 180 181 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 179 def target_format @target_format ||= FORMATS[@host].nil? ? "skip" : FORMATS[@host] end |
#verify_lib ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/ffi-libarchive-binary/libarchive_recipe.rb', line 165 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 |