Skip to content

Commit 3430490

Browse files
committed
compile_crate interface change at 0.30.0
1 parent 735f41d commit 3430490

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

lib/ortex/native.ex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
defmodule Ortex.Native do
22
@moduledoc false
33

4+
@rustler_version Application.spec(:rustler, :vsn) |> to_string() |> Version.parse!()
5+
46
# We have to compile the crate before `use Rustler` compiles the crate since
57
# cargo downloads the onnxruntime shared libraries and they are not available
68
# to load or copy into Elixir's during the on_load or Elixir compile steps.
79
# In the future, this may be configurable in Rustler.
8-
Rustler.Compiler.compile_crate(__MODULE__, otp_app: :ortex, crate: :ortex)
10+
if Version.compare(@rustler_version, "0.30.0") in [:gt, :eq] do
11+
Rustler.Compiler.compile_crate(:ortex, Application.compile_env(:ortex, __MODULE__, []),
12+
otp_app: :ortex,
13+
crate: :ortex
14+
)
15+
else
16+
Rustler.Compiler.compile_crate(__MODULE__, otp_app: :ortex, crate: :ortex)
17+
end
18+
919
Ortex.Util.copy_ort_libs()
1020

1121
use Rustler,

0 commit comments

Comments
 (0)