Module: LibarchiveBinary

Defined in:
lib/ffi-libarchive-binary.rb,
lib/ffi-libarchive-binary/version.rb,
lib/ffi-libarchive-binary/xz_recipe.rb,
lib/ffi-libarchive-binary/base_recipe.rb,
lib/ffi-libarchive-binary/zlib_recipe.rb,
lib/ffi-libarchive-binary/configuration.rb,
lib/ffi-libarchive-binary/openssl_recipe.rb,
lib/ffi-libarchive-binary/libexpat_recipe.rb,
lib/ffi-libarchive-binary/libarchive_recipe.rb

Defined Under Namespace

Classes: BaseRecipe, Error, LibarchiveRecipe, LibexpatRecipe, OpensslRecipe, XZRecipe, ZLibRecipe

Constant Summary collapse

LIBRARY_PATH =
Pathname.new(File.join(__dir__, "ffi-libarchive-binary"))
VERSION =
"0.4.0"
FORMATS =
{
  "arm64-apple-darwin" => "Mach-O 64-bit dynamically linked shared library arm64",
  "x86_64-apple-darwin" => "Mach-O 64-bit dynamically linked shared library x86_64",
  "aarch64-linux-gnu" => "ELF 64-bit LSB shared object, ARM aarch64",
  "x86_64-linux-gnu" => "ELF 64-bit LSB shared object, x86-64",
  "x86_64-w64-mingw32" => "PE32+ executable",
}.freeze
ARCHS =
{
  "arm64-apple-darwin" => "arm64",
  "x86_64-apple-darwin" => "x86_64",
}.freeze
LIBNAMES =
{
  "x86_64-w64-mingw32" => "libarchive.dll",
  "x86_64-linux-gnu" => "libarchive.so",
  "aarch64-linux-gnu" => "libarchive.so",
  "x86_64-apple-darwin" => "libarchive.dylib",
  "arm64-apple-darwin" => "libarchive.dylib",
}.freeze
ROOT =
Pathname.new(File.expand_path("../..", __dir__))
OS_COMPILERS =
{
  "arm64-apple-darwin" => "darwin64-arm64-cc",
  "x86_64-apple-darwin" => "darwin64-x86_64-cc",
  "aarch64-linux-gnu" => nil,
  "x86_64-linux-gnu" => nil,
  "x86_64-w64-mingw32" => "mingw64",
}.freeze
ENV_CMD =
["env", "CFLAGS=-fPIC", "LDFLAGS=-fPIC"].freeze

Class Method Summary collapse

Class Method Details

.lib_filenameObject



15
16
17
18
19
20
21
22
23
# File 'lib/ffi-libarchive-binary.rb', line 15

def self.lib_filename
  if FFI::Platform.windows?
    "libarchive.dll"
  elsif FFI::Platform.mac?
    "libarchive.dylib"
  else
    "libarchive.so"
  end
end

.lib_pathObject



11
12
13
# File 'lib/ffi-libarchive-binary.rb', line 11

def self.lib_path
  LIBRARY_PATH.join(lib_filename).to_s
end

.librariesObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ffi-libarchive-binary/configuration.rb', line 7

def self.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.message
  exit 1
rescue StandardError => e
  puts "An unexpected error occurred while loading the configuration file '#{configuration_file}'."
  puts e.message
  exit 1
end

.library_for(libname) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ffi-libarchive-binary/configuration.rb', line 20

def self.library_for(libname)
  if MiniPortile::windows?
    libraries[libname]["windows"] || libraries[libname]["all"]
  else
    libraries[libname]["all"]
  end
rescue StandardError => e
  puts "Failed to load library configuration for '#{libname}'."
  puts e.message
  exit 1
end