Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add macos release config and bundle external libs #373

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -157,12 +176,20 @@ 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
end

defp get_debian_arch("x86_64"), do: "amd64"
Expand Down