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

Release v1.4.6 and bugfix of symlink to priv/ creation #122

Merged
merged 8 commits into from
Feb 15, 2024
21 changes: 15 additions & 6 deletions lib/bundlex/toolchain/common/unix/os_deps.ex
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,28 @@ defmodule Bundlex.Toolchain.Common.Unix.OSDeps do
end
end

defp get_precompiled_libs_flags(dep_path, dep_dir_name, lib_names, native) do
defp get_precompiled_libs_flags(dep_path, logical_dep_dir_name, lib_names, native) do
lib_path = Path.join(dep_path, "lib")
output_path = Bundlex.Toolchain.output_path(native.app, native.interface)
create_relative_symlink(lib_path, output_path, dep_dir_name)
logical_output_path = Bundlex.Toolchain.output_path(native.app, native.interface)
create_relative_symlink(lib_path, logical_output_path, logical_dep_dir_name)

# We create a second ("physical") symlink to the place where the precompiled dependencies
# are stored because we need to assure that the relative link in the symlink's target
# will work properly also when the symlink is put in the location, for which the
# logical path differs from the physical path
{physical_output_path, 0} = System.shell("realpath #{logical_output_path}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a comment on why we do this and create two symlinks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

physical_output_path = String.trim_trailing(physical_output_path)
physical_dep_dir_name = logical_dep_dir_name <> "_physical"
create_relative_symlink(lib_path, physical_output_path, physical_dep_dir_name)

# TODO: pass the platform via arguments
# $ORIGIN must be escaped so that it's not treated as an ENV variable
rpath_root = if Bundlex.platform() == :macosx, do: "@loader_path", else: "\\$ORIGIN"

[
"-L#{Path.join(dep_path, "lib")}",
"-Wl,-rpath,#{rpath_root}/#{dep_dir_name}",
"-Wl,-rpath,#{rpath_root}/#{logical_dep_dir_name}",
"-Wl,-rpath,#{rpath_root}/#{physical_dep_dir_name}",
"-Wl,-rpath,/opt/homebrew/lib"
] ++ Enum.map(lib_names, &"-l#{remove_lib_prefix(&1)}")
end
Expand Down Expand Up @@ -262,8 +272,7 @@ defmodule Bundlex.Toolchain.Common.Unix.OSDeps do

unless File.exists?(symlink) do
File.mkdir_p!(dir)

File.ln_s!(path_from_to(dir, target), symlink)
File.ln_s(path_from_to(dir, target), symlink)
end

:ok
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Bundlex.Mixfile do
use Mix.Project

@version "1.4.5"
@version "1.4.6"
@github_url "https://github.com/membraneframework/bundlex"

def project do
Expand Down