Skip to content

Commit 477c81f

Browse files
authored
Remove version "2.14" from the default NIF versions (#49)
That version is targeting OTP 21, which is fairly old. We can speed up the release time of libs without this version.
1 parent ef10dac commit 477c81f

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

PRECOMPILATION_GUIDE.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ For this guide our targets will be the following:
3939

4040
- OS: Linux, Windows, macOS
4141
- Architectures: `x86_64`, `aarch64` (ARM 64 bits), `arm`
42-
- NIF versions: `2.14`, `2.15`, `2.16`.
42+
- NIF versions: `2.15`, `2.16`.
4343

4444
In summary the build matrix looks like this:
4545

4646
```yaml
4747
matrix:
48-
nif: ["2.16", "2.15", "2.14"]
48+
nif: ["2.16", "2.15"]
4949
job:
5050
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , use-cross: true }
5151
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true }
@@ -58,6 +58,8 @@ matrix:
5858
```
5959
6060
A complete workflow example can be found in the [`rustler_precompilation_example`](https://github.com/philss/rustler_precompilation_example/blob/main/.github/workflows/release.yml) project.
61+
That workflow is using a GitHub Action especially made for our goal: [philss/rustler-precompiled-action](https://github.com/philss/rustler-precompiled-action).
62+
The GitHub Action will deal with the installation of `cross` and the build of the project, naming the files in the correct format.
6163

6264
Some targets are only supported by later versions of `cross`. For those, you might want to
6365
install `cross` directly from GitHub. You can see an example in [this
@@ -66,7 +68,7 @@ pipeline](https://github.com/kloeckner-i/mail_parser/blob/f4af5083aec73a47f0e41a
6668
## Additional configuration before build
6769

6870
In our build we are going to cross compile our crate project (the Rust code for our NIF) using
69-
a variety of targets as we saw in the previous section. For this to work we need to guide the Rust
71+
a variety of targets, as we saw in the previous section. For this to work we need to guide the Rust
7072
compiler in some cases by providing additional configuration in the `.cargo/config` file of our project.
7173

7274
Here is an example of that file:
@@ -150,7 +152,7 @@ With the module I used for this guide, the command would be:
150152
$ mix rustler_precompiled.download RustlerPrecompilationExample.Native --all --print
151153

152154
The file generated will be named `checksum-Elixir.RustlerPrecompilationExample.Native.exs` and
153-
it's extremely important that you include this file in your Hex package (by updating the `files:`
155+
it's **extremely important that you include this file in your Hex package** (by updating the `files:`
154156
field in your `mix.exs`). Otherwise your package **won't work**. Your `files:` key at your
155157
package configuration will look like this:
156158

lib/rustler_precompiled.ex

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,20 @@ defmodule RustlerPrecompiled do
4747
4848
#{Enum.map_join(RustlerPrecompiled.Config.default_targets(), "\n", &" - `#{&1}`")}
4949
50-
* `:nif_versions` - A list of OTP nif_versions for which precompiled assets are
51-
available. By default the following nif_versions are configured:
50+
* `:nif_versions` - A list of OTP NIF versions for which precompiled assets are
51+
available. A NIF version is usually compatible with two OTP minor versions, and an older
52+
NIF is usually compatible with newer OTPs. The available versions are the following:
5253
53-
#{Enum.map_join(RustlerPrecompiled.Config.available_nif_versions(), "\n", &" - `#{&1}`")}
54+
* `2.14` - for OTP 21.
55+
* `2.15` - for OTP 22 and 23.
56+
* `2.16` - for OTP 24 and 25.
57+
58+
By default the following NIF versions are configured:
59+
60+
#{Enum.map_join(RustlerPrecompiled.Config.default_nif_versions(), "\n", &" - `#{&1}`")}
61+
62+
Check the compatibiliy table between Elixir and OTP in:
63+
https://hexdocs.pm/elixir/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp
5464
5565
In case "force build" is used, all options except `:base_url`, `:version`,
5666
`:force_build`, `:nif_versions`, and `:targets` are going to be passed down to `Rustler`.

lib/rustler_precompiled/config.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ defmodule RustlerPrecompiled.Config do
3131
)
3232

3333
@available_nif_versions ~w(2.14 2.15 2.16)
34+
@default_nif_versions ~w(2.15 2.16)
3435

3536
def default_targets, do: @default_targets
3637

3738
def available_nif_versions, do: @available_nif_versions
39+
def default_nif_versions, do: @default_nif_versions
3840

3941
def new(opts) do
4042
version = Keyword.fetch!(opts, :version)
@@ -48,7 +50,7 @@ defmodule RustlerPrecompiled.Config do
4850

4951
nif_versions =
5052
opts
51-
|> Keyword.get(:nif_versions, @available_nif_versions)
53+
|> Keyword.get(:nif_versions, @default_nif_versions)
5254
|> validate_list!(:nif_versions, @available_nif_versions)
5355

5456
%__MODULE__{

test/rustler_precompiled/config_test.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ defmodule RustlerPrecompiled.ConfigTest do
161161
)
162162

163163
assert config.nif_versions == [
164-
"2.14",
165164
"2.15",
166165
"2.16"
167166
]

0 commit comments

Comments
 (0)