From 581d62e589088689679391a900e94585a8a318c2 Mon Sep 17 00:00:00 2001 From: Mebareksaf Date: Wed, 14 Feb 2024 04:45:56 +0100 Subject: [PATCH 1/2] add macos release config and bundle external libs --- mix.exs | 49 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/mix.exs b/mix.exs index e3006df4..5b692a17 100644 --- a/mix.exs +++ b/mix.exs @@ -58,6 +58,12 @@ defmodule ExNVR.Umbrella.MixProject do copy_libs(arch, libs_dest) release + {arch, "apple", "darwin22.4.0"} -> + libs_dest = Path.join(release.path, "external_lib") + File.mkdir_p!(libs_dest) + copy_libs(arch, libs_dest) + release + _other -> release end @@ -66,14 +72,27 @@ defmodule ExNVR.Umbrella.MixProject do defp copy_libs(arch, dest_dir) do # Tried to use `File.cp` to copy dependencies however links are not copied correctly # which made the size of the destination folder 3 times the original size. - libs = [ - "/usr/lib/#{arch}-linux-gnu/libsrtp2.so*", - "/usr/lib/#{arch}-linux-gnu/libturbojpeg.so*", - "/usr/lib/#{arch}-linux-gnu/libssl.so*", - "/usr/lib/#{arch}-linux-gnu/libcrypto.so*" - ] - - System.shell("cp -P #{Enum.join(libs, " ")} #{dest_dir}") + case arch do + "aarch64" -> + libs = [ + "/opt/homebrew/lib/libsrtp2.dylib*", + "/opt/homebrew/lib/libturbojpeg.dylib*", + "/opt/homebrew/lib/libssl.dylib*", + "/opt/homebrew/lib/libcrypto*.dylib*" + ] + + System.shell("cp -P #{Enum.join(libs, " ")} #{dest_dir}") + + _ -> + libs = [ + "/usr/lib/#{arch}-linux-gnu/libsrtp2.so*", + "/usr/lib/#{arch}-linux-gnu/libturbojpeg.so*", + "/usr/lib/#{arch}-linux-gnu/libssl.so*", + "/usr/lib/#{arch}-linux-gnu/libcrypto.so*" + ] + + System.shell("cp -P #{Enum.join(libs, " ")} #{dest_dir}") + end end defp archive(release) do @@ -157,12 +176,22 @@ defmodule ExNVR.Umbrella.MixProject do end defp get_target() do - [architecture, _vendor, os, abi] = + specs = :erlang.system_info(:system_architecture) |> List.to_string() |> String.split("-") - {architecture, os, abi} + case length(specs) do + 3 -> + [architecture, os, abi] = specs + {architecture, os, abi} + + _ -> + [architecture, _vendor, os, abi] = specs + {architecture, os, abi} + end + + # {architecture, os, abi} end defp get_debian_arch("x86_64"), do: "amd64" From 98beb5a3b637e2958c41e555a338683ede2a4ecf Mon Sep 17 00:00:00 2001 From: Mebareksaf Date: Wed, 14 Feb 2024 04:47:09 +0100 Subject: [PATCH 2/2] clean comment --- mix.exs | 2 -- 1 file changed, 2 deletions(-) diff --git a/mix.exs b/mix.exs index 5b692a17..48dd94cc 100644 --- a/mix.exs +++ b/mix.exs @@ -190,8 +190,6 @@ defmodule ExNVR.Umbrella.MixProject do [architecture, _vendor, os, abi] = specs {architecture, os, abi} end - - # {architecture, os, abi} end defp get_debian_arch("x86_64"), do: "amd64"