-
Notifications
You must be signed in to change notification settings - Fork 23
msvc: include deps when linking #137
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -59,30 +59,34 @@ defmodule Bundlex.Toolchain.VisualStudio do | |||||||||||||
|
|
||||||||||||||
| output_path = Toolchain.output_path(native.app, native.name, interface) | ||||||||||||||
|
|
||||||||||||||
| deps = | ||||||||||||||
| native.deps | ||||||||||||||
| |> Enum.map(&(Toolchain.output_path(&1.app, &1.name, &1.interface) <> ".lib")) | ||||||||||||||
| |> paths() | ||||||||||||||
|
|
||||||||||||||
| commands = | ||||||||||||||
| case native do | ||||||||||||||
| %Native{type: :native, interface: :nif} -> | ||||||||||||||
| [ | ||||||||||||||
| "(cl #{compile_options} #{includes_part} #{sources_part})", | ||||||||||||||
| ~s[(link #{link_options} #{libs_part} /DLL /OUT:"#{PathHelper.fix_slashes(output_path)}.dll" *.obj)] | ||||||||||||||
| ~s[(link #{link_options} #{libs_part} /DLL /OUT:"#{PathHelper.fix_slashes(output_path)}.dll" *.obj #{deps})] | ||||||||||||||
| ] | ||||||||||||||
|
|
||||||||||||||
| %Native{type: :lib} -> | ||||||||||||||
| [ | ||||||||||||||
| "(cl #{compile_options} #{includes_part} #{sources_part})", | ||||||||||||||
| ~s[(lib /OUT:"#{PathHelper.fix_slashes(output_path)}.lib" *.obj)] | ||||||||||||||
| ~s[(lib /OUT:"#{PathHelper.fix_slashes(output_path)}.lib" *.obj #{deps})] | ||||||||||||||
| ] | ||||||||||||||
|
|
||||||||||||||
| %Native{type: type, interface: :nif} when type in [:cnode, :port] -> | ||||||||||||||
| [ | ||||||||||||||
| "(cl #{compile_options} #{includes_part} #{sources_part})", | ||||||||||||||
| ~s[(link /libpath:"#{:code.root_dir() |> Path.join("lib/erl_interface-5.5.2/lib") |> PathHelper.fix_slashes()}" #{link_options} #{libs_part} /OUT:"#{PathHelper.fix_slashes(output_path)}.exe" *.obj)] | ||||||||||||||
| ~s[(link /libpath:"#{:code.root_dir() |> Path.join("lib/erl_interface-5.5.2/lib") |> PathHelper.fix_slashes()}" #{link_options} #{libs_part} /OUT:"#{PathHelper.fix_slashes(output_path)}.exe" *.obj #{deps})] | ||||||||||||||
| ] | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| [ | ||||||||||||||
| "(if exist #{dir_part} rmdir /S /Q #{dir_part})", | ||||||||||||||
| "(mkdir #{dir_part})", | ||||||||||||||
| "(if not exist #{dir_part} mkdir #{dir_part})", | ||||||||||||||
| "(pushd #{dir_part})", | ||||||||||||||
| commands, | ||||||||||||||
| "(popd)" | ||||||||||||||
|
|
@@ -132,4 +136,13 @@ defmodule Bundlex.Toolchain.VisualStudio do | |||||||||||||
| ) | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| defp paths(paths, flag \\ "") do | ||||||||||||||
| Enum.map_join(paths, " ", fn p -> "#{flag}#{path(p)}" end) | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| defp path(path) do | ||||||||||||||
| path = path |> String.replace(~S("), ~S(\")) |> Path.expand() | ||||||||||||||
|
||||||||||||||
| path = path |> String.replace(~S("), ~S(\")) |> Path.expand() | |
| path = | |
| path | |
| |> String.replace(~S("), ~S(\")) | |
| |> Path.expand() | |
| |> PathHelper.fix_slashes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Static libraries (.lib files created by the lib tool) are archives of object files and typically don't link other libraries. The lib command may not properly handle the deps parameter. In the Unix implementation (common/unix.ex, line 74-76), the ar command for :lib type natives intentionally does not include deps, as dependencies are resolved when the static library is later linked into an executable or shared library. Consider removing deps from this lib command to match the Unix behavior.