From ba1dc2f226df508139df01c2d95e303c52a7b6a4 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Thu, 20 Jun 2024 19:12:28 +0200 Subject: [PATCH] Recompile if the NIF library is changed/deleted --- 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"