fortian / rust-magic-sys

Rust declarations for `libmagic`

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rust-magic-sys Build Status

Rust declarations for libmagic.


This cargo -sys package provides libmagic declarations for e.g. the magic binding.

Usage

magic-sys is available on crates.io so you can use it like this (in your Cargo.toml):

[dependencies]
magic-sys = "0.2.0"

The rustdoc is available on GitHub Pages.

Requirements

libmagic needs to be installed in a standard location (also see issue #1).

On a Debian based Linux system this can be achieved like this:

sudo apt-get install libmagic1 libmagic-dev

On RHEL/Cent OS, Gentoo and others you will need to install the file package.

On Mac OS X you can use Homebrew:

brew install libmagic

Feedback for Windows (issue #2) support is appreciated!

Building

By default libmagic will be searched in the system library paths. If you need to use a different library or are cross-compiling, you can set the MAGIC_DIR and MAGIC_STATIC environment variables.

MAGIC_DIR, <TARGET>_MAGIC_DIR

Tells rustc where to find libmagic.so / libmagic.a. Can have a target-specific prefix like X86_64_UNKNOWN_LINUX_MUSL_MAGIC_DIR

MAGIC_STATIC, <TARGET>_MAGIC_STATIC

Controls static linking with libmagic. Enabled automatically if there's only a libmagic.a in the (provided) search path or if explicitly enabled like MAGIC_STATIC=true. Can have a target-specific prefix like X86_64_UNKNOWN_LINUX_MUSL_MAGIC_STATIC

Similarly MAGIC_STATIC=false can be used to choose to link libmagic dynamically. If unset but both libraries are available, the build will bail out with an error and you have to set one option explicitly.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Rust declarations for `libmagic`

License:Apache License 2.0


Languages

Language:Rust 100.0%