Skip to content

Commit 4ba9606

Browse files
committed
fix for issue #12 in rustler_mix
1 parent 66ed1eb commit 4ba9606

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

rustler_mix/lib/compiler.ex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,21 @@ defmodule Mix.Tasks.Compile.Rustler do
6262
# TODO: Make build flavor specific
6363
Enum.map(Path.wildcard("#{target_dir}/#{compile_flavor}/lib#{lib_name}.*"), fn
6464
path ->
65-
file_name = Path.basename(path)
65+
file_name = platform_library_name(Path.basename(path))
6666
File.cp!(Path.absname(path), "#{Rustler.nif_lib_dir}/#{file_name}")
6767
end)
6868
end
6969

70+
def platform_library_name(base_name) do
71+
ext = Path.extname(base_name)
72+
case ext do
73+
# For macs we need to rename the .dylib so .so for the BEAM to load it.
74+
# See issue #3.
75+
".dylib" -> Path.rootname(base_name) <> ".so"
76+
_ -> base_name
77+
end
78+
end
79+
7080
def check_crate_env(crate) do
7181
unless File.dir?(crate) do
7282
Mix.shell.error Messages.message(:no_crates_property_message)

0 commit comments

Comments
 (0)