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

BuildTarget: get_all_link_deps() to get_runtime_dependencies() #12059

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

xclaesse
Copy link
Member

@xclaesse xclaesse commented Aug 1, 2023

We already have get_dependencies() which are libs needed to link the
target. get_all_link_deps() name was thus confusing, what it actually
does is returning runtime dependencies, i.e. shared libraries that are
needed to run an executable.

This fix:
- runtime dependencies could be hidden behind link_whole targets that
  where previously ignored.
- Include CustomTarget that links_dynamically(), i.e. a DLL built by
  custom target.
- get_link_deps_mapping() and get_link_dep_subdirs() now calls
  get_runtime_dependencies() to avoid recursing multiple times. We can
  reuse the cached result in a single method.
- determine_windows_extra_paths():
  * Only add to PATH targets that links dynamically, some static
    libraries were previously included.
  * Exclude executable's build directory because Windows search there by
    default already (Fixes #12042).
  * mingw extra paths are also needed if python script has a cross built
    executable in its args.
  * External DLL paths are needed in the case a python script has a
    build targets in its args.

@xclaesse xclaesse requested a review from jpakkane as a code owner August 1, 2023 20:06
@xclaesse xclaesse force-pushed the extra-paths branch 5 times, most recently from dce3eea to 129e534 Compare August 2, 2023 20:33
The goal of that function is to collect BuildTarget this custom target
uses. E.g. if there are dll or exe passed as argument to a python
script, chances are that we need to set PATH to be able to use them.

The recursion happens already when we call get_all_link_deps() on those
BuildTarget.

Also fix its usage in test(), which was weirdly using it only if the
command first argument is a CustomTarget, but not for for other
arguments. The intended usage was to simply call
determine_windows_extra_paths() with all build targets from all command
arguments, like the backend does for custom target's command.
@xclaesse xclaesse force-pushed the extra-paths branch 5 times, most recently from c4f7250 to 64cf465 Compare August 5, 2023 14:24
We already have get_dependencies() which are libs needed to link the
target. get_all_link_deps() name was thus confusing, what it actually
does is returning runtime dependencies, i.e. shared libraries that are
needed to run an executable.

This fix:
- runtime dependencies could be hidden behind link_whole targets that
  where previously ignored.
- Include CustomTarget that links_dynamically(), i.e. a DLL built by
  custom target.
- get_link_deps_mapping() and get_link_dep_subdirs() now calls
  get_runtime_dependencies() to avoid recursing multiple times. We can
  reuse the cached result in a single method.
- determine_windows_extra_paths():
  * Only add to PATH targets that links dynamically, some static
    libraries were previously included.
  * Exclude executable's build directory because Windows search there by
    default already (Fixes mesonbuild#12042).
  * mingw extra paths are also needed if python script has a cross built
    executable in its args.
  * External DLL paths are needed in the case a python script has a
    build targets in its args.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant