View Source RustlerPrecompiled (rustler_precompiled v0.2.0)
Download and use precompiled NIFs safely with checksums.
Rustler Precompiled is a tool for library maintainers that rely on Rustler. It helps by removing the need to have the Rust compiler installed in the user's machine.
Check the Precompilation Guide for details.
Example
defmodule MyNative do
use RustlerPrecompiled,
otp_app: :my_app,
crate: "my_app_nif",
base_url: "https://github.com/me/my_project/releases/download/v0.1.0",
version: "0.1.0"
end
Options
:otp_app
- The OTP app name that the dynamic library will be loaded from.:crate
- The name of Rust crate if different from the:otp_app
. This is optional.:base_url
- A valid URL that is used as base path for the NIF file.:version
- The version of precompiled assets (it is part of the NIF filename).:force_build
- Force the build withRustler
. This isfalse
by default, but if your:version
is a pre-release (like "2.1.0-dev"), this option will always be settrue
. You can also configure this option by setting an application env like this:config :rustler_precompiled, :force_build, your_otp_app: true
In case "force build" is used, all options except :base_url
, :version
and :force_build
are going to be passed down to Rustler
.
So if you need to configure the build, check the Rustler
options.
Link to this section Summary
Functions
Returns URLs for NIFs based on its module name.
List all default available targets.
Returns the file URL to be downloaded for current target.
Returns the target triple for download or compile and load.
Link to this section Functions
Returns URLs for NIFs based on its module name.
The module name is the one that defined the NIF and this information is stored in a metadata file.
List all default available targets.
Returns the file URL to be downloaded for current target.
It receives the NIF module.
Returns the target triple for download or compile and load.
This function is translating and adding more info to the system architecture returned by Elixir/Erlang to one used by Rust.
The returned string has the following format:
"nif-NIF_VERSION-ARCHITECTURE-VENDOR-OS-ABI"
Examples
iex> RustlerPrecompiled.target()
{:ok, "nif-2.16-x86_64-unknown-linux-gnu"}
iex> RustlerPrecompiled.target()
{:ok, "nif-2.15-aarch64-apple-darwin"}