Skip to content

Commit

Permalink
Change defaults for upcoming v0.7 (#58)
Browse files Browse the repository at this point in the history
* Change defaults for upcoming v0.7

Normally users need to build only for the lowest NIF version,
unless they need specific features from newer versions.

* Fix test case

* Use default nif versions to avoid failure in OTP 26

* Fix documentation
  • Loading branch information
philss authored Sep 22, 2023
1 parent 5edcbc6 commit 7faa10b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions lib/rustler_precompiled.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ defmodule RustlerPrecompiled do
restrict CPU features, like AVX on x86_64.
The order of variants matters, because the first one that returns `true` is going to be
selected. Example:
selected. Example:
%{"x86_64-unknown-linux-gnu" => [old_glibc: fn _config -> has_old_glibc?() end]}
In case "force build" is used, all options except `:base_url`, `:version`,
`:force_build`, `:nif_versions`, and `:targets` are going to be passed down to `Rustler`.
In case "force build" is used, all options except the ones use by RustlerPrecompiled
are going to be passed down to `Rustler`.
So if you need to configure the build, check the `Rustler` options.
## Environment variables
Expand Down
4 changes: 2 additions & 2 deletions lib/rustler_precompiled/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ defmodule RustlerPrecompiled.Config do
x86_64-unknown-linux-musl
)

@available_nif_versions ~w(2.14 2.15 2.16)
@default_nif_versions ~w(2.15 2.16)
@available_nif_versions ~w(2.14 2.15 2.16 2.17)
@default_nif_versions ~w(2.15)

def default_targets, do: @default_targets
def available_targets, do: RustlerPrecompiled.Config.AvailableTargets.list()
Expand Down
3 changes: 1 addition & 2 deletions test/rustler_precompiled/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ defmodule RustlerPrecompiled.ConfigTest do
)

assert config.nif_versions == [
"2.15",
"2.16"
"2.15"
]
end

Expand Down
15 changes: 8 additions & 7 deletions test/rustler_precompiled_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule RustlerPrecompiledTest do

@available_targets RustlerPrecompiled.Config.default_targets()
@available_nif_versions RustlerPrecompiled.Config.available_nif_versions()
@default_nif_versions RustlerPrecompiled.Config.default_nif_versions()

describe "target/1" do
test "arm 64 bits in an Apple with Darwin-based OS" do
Expand Down Expand Up @@ -229,7 +230,7 @@ defmodule RustlerPrecompiledTest do
}

error_message =
"precompiled NIF is not available for this NIF version: \"2.10\".\nThe available NIF versions are:\n - 2.14\n - 2.15\n - 2.16"
"precompiled NIF is not available for this NIF version: \"2.10\".\nThe available NIF versions are:\n - 2.14\n - 2.15\n - 2.16\n - 2.17"

assert {:error, ^error_message} =
RustlerPrecompiled.target(config, @available_targets, @available_nif_versions)
Expand Down Expand Up @@ -369,7 +370,7 @@ defmodule RustlerPrecompiledTest do
version: "0.2.0",
crate: "example",
targets: @available_targets,
nif_versions: @available_nif_versions
nif_versions: @default_nif_versions
}

{:ok, metadata} = RustlerPrecompiled.build_metadata(config)
Expand Down Expand Up @@ -417,7 +418,7 @@ defmodule RustlerPrecompiledTest do
version: "0.2.0",
crate: "example",
targets: @available_targets,
nif_versions: @available_nif_versions
nif_versions: @default_nif_versions
}

{:ok, metadata} = RustlerPrecompiled.build_metadata(config)
Expand Down Expand Up @@ -474,7 +475,7 @@ defmodule RustlerPrecompiledTest do
version: "0.2.0",
crate: "example",
targets: @available_targets,
nif_versions: @available_nif_versions
nif_versions: @default_nif_versions
}

{:ok, metadata} = RustlerPrecompiled.build_metadata(config)
Expand Down Expand Up @@ -526,7 +527,7 @@ defmodule RustlerPrecompiledTest do
crate: "example",
max_retries: 0,
targets: @available_targets,
nif_versions: @available_nif_versions
nif_versions: @default_nif_versions
}

{:ok, metadata} = RustlerPrecompiled.build_metadata(config)
Expand Down Expand Up @@ -564,7 +565,7 @@ defmodule RustlerPrecompiledTest do
version: "0.2.0",
crate: "example",
targets: @available_targets,
nif_versions: @available_nif_versions
nif_versions: @default_nif_versions
}

{:ok, metadata} = RustlerPrecompiled.build_metadata(config)
Expand Down Expand Up @@ -819,7 +820,7 @@ defmodule RustlerPrecompiledTest do
assert {:ok, nif_urls} = RustlerPrecompiled.nif_urls_from_metadata(metadata)

# NIF versions multiplied by 2 new variants.
variants_count = 6
variants_count = 8

assert length(nif_urls) ==
length(@available_targets) * length(@available_nif_versions) + variants_count
Expand Down

0 comments on commit 7faa10b

Please sign in to comment.