You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There're three sub-keys for `make_precompiler_nif_versions`:
115
+
There're two sub-keys for `make_precompiler_nif_versions`:
117
116
118
117
-`versions`
119
118
-`fallback_version`
120
-
-`availability`
121
119
122
120
##### `versions` sub-key
123
121
124
-
The `versions` sub-key is a list of NIF versions that the precompiled artefacts are available for:
122
+
The `versions` sub-key is either a list of NIF versions of a function that returns a list of NIF versions that the precompiled artefacts are available for:
125
123
126
124
```elixir
127
125
make_precompiler_nif_versions: [
128
126
versions: ["2.15", "2.16"]
129
127
]
130
128
```
131
129
130
+
The above example tells `:elixir_make` that all targets have precompiled artefacts for NIF version `2.15` and `2.16`.
131
+
132
+
For some platforms maybe we only have precompiled artefacts after a certain NIF version, say for x86_64 Windows we have precompiled artefacts available when NIF version >= `2.16` while other platforms have precompiled artefacts available from NIF version >= `2.15`.
133
+
134
+
In such case we can inform `:elixir_make` that Windows targets don't have precompiled artefacts available except for NIF version `2.16` by passing a function to the `availability` sub-key. This function should accept two arguments, `target` and `nif_version`, and returns a boolean value indicating whether the precompiled artefacts for the target and NIF version are available.
135
+
136
+
```elixir
137
+
make_precompiler_nif_versions: [
138
+
versions:fn opts ->
139
+
target = opts.target
140
+
ifString.contains?(target, "windows") do
141
+
["2.16"]
142
+
else
143
+
["2.15", "2.16"]
144
+
end
145
+
end
146
+
]
147
+
```
148
+
132
149
The default behaviour is to use the exact NIF version that is available to the current target. If one is not available, it may fallback (see `fallback_version` next) to the highest matching major version prior to the current version. For example:
133
150
134
151
- if the current host is using Erlang/OTP 23 (NIF version `2.15`), `elixir_make` will use the precompiled artefacts for NIF version `2.15`;
@@ -139,25 +156,11 @@ If the current host is using Erlang/OTP with a new major Erlang NIF version (NIF
139
156
140
157
##### `fallback_version` sub-key
141
158
142
-
The behaviour when `elixir_make` cannot find the exact NIF version of the precompiled binary can be customized by setting the `fallback_version` sub-key. The value of the `fallback_version` sub-key should be a function that accepts three arguments, `target`, `current_nif_version` and `target_versions`. The `target` is the target triplet (or other name format, defined by the precompiler of your choice), `current_nif_version` is the NIF version on the current host, and `target_versions` is a list of NIF versions that are available to the target.
143
-
144
-
The `fallback_version` function should return either the NIF version that `elixir_make` should use from the `target_versions` list or the `current_nif_version`.
159
+
The behaviour when `elixir_make` cannot find the exact NIF version of the precompiled binary can be customized by setting the `fallback_version` sub-key.
145
160
146
-
##### `availability` sub-key
161
+
The value of the `fallback_version` sub-key should be a function that accepts one argument, `opts`, which is a map that include one key `target`. The `target` is the target triplet (or other naming format, defined by the precompiler of your choice).
147
162
148
-
For some platforms maybe we only have precompiled artefacts after a certain NIF version, say for x86_64 Windows we have precompiled artefacts available when NIF version >= `2.16` while other platforms have precompiled artefacts available from NIF version >= `2.15`.
149
-
150
-
In such case we can inform `:elixir_make` that Windows targets don't have precompiled artefacts available except for NIF version `2.16` by passing a function to the `availability` sub-key. This function should accept two arguments, `target` and `nif_version`, and returns a boolean value indicating whether the precompiled artefacts for the target and NIF version are available.
151
-
152
-
```elixir
153
-
defptarget_available_for_nif_version?(target, nif_version) do
154
-
ifString.contains?(target, "windows") do
155
-
nif_version =="2.16"
156
-
else
157
-
true
158
-
end
159
-
end
160
-
```
163
+
The `fallback_version` function should return the NIF version that is available and should be chosen for the current target.
0 commit comments