diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-10-27 19:56:09 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-06-09 20:37:26 -0400 |
commit | c151988b397e15d67d83047a2e33d3df28353987 (patch) | |
tree | 0c57783bd8b7c9fda2d86ad8f598fa6593f70379 /mesonbuild/backend/backends.py | |
parent | e8a3f4d38c49ae7a937e0a02db06a73f5593b08f (diff) | |
download | meson-c151988b397e15d67d83047a2e33d3df28353987.zip meson-c151988b397e15d67d83047a2e33d3df28353987.tar.gz meson-c151988b397e15d67d83047a2e33d3df28353987.tar.bz2 |
intro-install_plan: fix destinations for build_targets with custom install_dir
There are a couple issues that combine to make the current handling a
bit confusing.
- we call it "install_dir_name" but it is only ever the class default
- CustomTarget always has it set to None, and then we check if it is
None then create a different variable with a safe fallback. The if is
useless -- it cannot fail, but if it did we'd get an undefined
variable error when we tried to use `dir_name`
Remove the special handling for CustomTarget. Instead, just always
accept None as a possible value of outdir_name when constructing install
data, and, if it is None, fall back to {prefix}/outdir regardless of
what type it used to be.
Diffstat (limited to 'mesonbuild/backend/backends.py')
-rw-r--r-- | mesonbuild/backend/backends.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 0ccb6cd..ff55aad 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -134,7 +134,7 @@ class InstallData: class TargetInstallData: fname: str outdir: str - outdir_name: InitVar[str] + outdir_name: InitVar[T.Optional[str]] strip: bool install_name_mappings: T.Mapping[str, str] rpath_dirs_to_remove: T.Set[bytes] @@ -146,7 +146,9 @@ class TargetInstallData: tag: T.Optional[str] = None can_strip: bool = False - def __post_init__(self, outdir_name: str) -> None: + def __post_init__(self, outdir_name: T.Optional[str]) -> None: + if outdir_name is None: + outdir_name = os.path.join('{prefix}', self.outdir) self.out_name = os.path.join(outdir_name, os.path.basename(self.fname)) @dataclass(eq=False) @@ -1534,7 +1536,7 @@ class Backend: for t in self.build.get_targets().values(): if not t.should_install(): continue - outdirs, install_dir_name, custom_install_dir = t.get_install_dir() + outdirs, default_install_dir_name, custom_install_dir = t.get_install_dir() # Sanity-check the outputs and install_dirs num_outdirs, num_out = len(outdirs), len(t.get_outputs()) if num_outdirs != 1 and num_outdirs != num_out: @@ -1570,7 +1572,7 @@ class Backend: tag = t.install_tag[0] or ('devel' if isinstance(t, build.StaticLibrary) else 'runtime') mappings = t.get_link_deps_mapping(d.prefix) i = TargetInstallData(self.get_target_filename(t), first_outdir, - install_dir_name, + default_install_dir_name, should_strip, mappings, t.rpath_dirs_to_remove, t.install_rpath, install_mode, t.subproject, tag=tag, can_strip=can_strip) @@ -1595,7 +1597,7 @@ class Backend: implib_install_dir = self.environment.get_import_lib_dir() # Install the import library; may not exist for shared modules i = TargetInstallData(self.get_target_filename_for_linking(t), - implib_install_dir, install_dir_name, + implib_install_dir, default_install_dir_name, False, {}, set(), '', install_mode, t.subproject, optional=isinstance(t, build.SharedModule), tag='devel') @@ -1604,7 +1606,7 @@ class Backend: if not should_strip and t.get_debug_filename(): debug_file = os.path.join(self.get_target_dir(t), t.get_debug_filename()) i = TargetInstallData(debug_file, first_outdir, - install_dir_name, + default_install_dir_name, False, {}, set(), '', install_mode, t.subproject, optional=True, tag='devel') @@ -1616,7 +1618,7 @@ class Backend: if outdir is False: continue f = os.path.join(self.get_target_dir(t), output) - i = TargetInstallData(f, outdir, install_dir_name, False, {}, set(), None, + i = TargetInstallData(f, outdir, default_install_dir_name, False, {}, set(), None, install_mode, t.subproject, tag=tag) d.targets.append(i) @@ -1635,9 +1637,7 @@ class Backend: if first_outdir is not False: for output, tag in zip(t.get_outputs(), t.install_tag): f = os.path.join(self.get_target_dir(t), output) - if not install_dir_name: - dir_name = os.path.join('{prefix}', first_outdir) - i = TargetInstallData(f, first_outdir, dir_name, + i = TargetInstallData(f, first_outdir, default_install_dir_name, False, {}, set(), None, install_mode, t.subproject, optional=not t.build_by_default, tag=tag) @@ -1648,9 +1648,7 @@ class Backend: if outdir is False: continue f = os.path.join(self.get_target_dir(t), output) - if not install_dir_name: - dir_name = os.path.join('{prefix}', outdir) - i = TargetInstallData(f, outdir, dir_name, + i = TargetInstallData(f, outdir, default_install_dir_name, False, {}, set(), None, install_mode, t.subproject, optional=not t.build_by_default, tag=tag) |