From 7fef3c52873e31e863e966b4677cc1f58c57d699 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Mon, 24 Jun 2024 22:30:30 +0200 Subject: [PATCH] Recompile if the NIF library is changed/deleted (#624) --- rustler_mix/lib/rustler.ex | 7 +++++++ rustler_mix/lib/rustler/compiler.ex | 2 ++ 2 files changed, 9 insertions(+) diff --git a/rustler_mix/lib/rustler.ex b/rustler_mix/lib/rustler.ex index 49d72f02..950dcc10 100644 --- a/rustler_mix/lib/rustler.ex +++ b/rustler_mix/lib/rustler.ex @@ -104,6 +104,13 @@ defmodule Rustler do end if config.lib do + {otp_app, path} = config.load_from + + @external_resource Application.app_dir( + otp_app, + "#{path}.#{Rustler.Compiler.get_lib_suffix()}" + ) + @load_from config.load_from @load_data config.load_data @load_data_fun config.load_data_fun diff --git a/rustler_mix/lib/rustler/compiler.ex b/rustler_mix/lib/rustler/compiler.ex index dc04df38..14f764bd 100644 --- a/rustler_mix/lib/rustler/compiler.ex +++ b/rustler_mix/lib/rustler/compiler.ex @@ -197,6 +197,8 @@ defmodule Rustler.Compiler do end end + def get_lib_suffix(), do: get_suffix(nil, :lib) + defp get_suffix(target, :lib) do case get_target_os_type(target) do {:win32, _} -> "dll"