Skip to content

Commit

Permalink
backends: Try guessing install tag for all installed files
Browse files Browse the repository at this point in the history
It was only trying to guess install tag, and log missing tags, for files
installed by install_data(). Do it also for all other files, especially
custom_taget() that commonly installs generated headers.
  • Loading branch information
xclaesse authored and jpakkane committed Nov 2, 2022
1 parent 43e274c commit f5871e2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mesonbuild/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,7 @@ def generate_target_install(self, d: InstallData) -> None:
if num_outdirs == 1 and num_out > 1:
if first_outdir is not False:
for output, tag in zip(t.get_outputs(), t.install_tag):
tag = tag or self.guess_install_tag(output, first_outdir)
f = os.path.join(self.get_target_dir(t), output)
i = TargetInstallData(f, first_outdir, first_outdir_name,
False, {}, set(), None, install_mode,
Expand All @@ -1665,6 +1666,7 @@ def generate_target_install(self, d: InstallData) -> None:
# User requested that we not install this output
if outdir is False:
continue
tag = tag or self.guess_install_tag(output, outdir)
f = os.path.join(self.get_target_dir(t), output)
i = TargetInstallData(f, outdir, outdir_name,
False, {}, set(), None, install_mode,
Expand All @@ -1674,6 +1676,9 @@ def generate_target_install(self, d: InstallData) -> None:

def generate_custom_install_script(self, d: InstallData) -> None:
d.install_scripts = self.build.install_scripts
for i in d.install_scripts:
if not i.tag:
mlog.debug('Failed to guess install tag for install script:', ' '.join(i.cmd_args))

def generate_header_install(self, d: InstallData) -> None:
incroot = self.environment.get_includedir()
Expand Down Expand Up @@ -1723,7 +1728,8 @@ def generate_man_install(self, d: InstallData) -> None:
def generate_emptydir_install(self, d: InstallData) -> None:
emptydir: T.List[build.EmptyDir] = self.build.get_emptydir()
for e in emptydir:
i = InstallEmptyDir(e.path, e.install_mode, e.subproject, e.install_tag)
tag = e.install_tag or self.guess_install_tag(e.path)
i = InstallEmptyDir(e.path, e.install_mode, e.subproject, tag)
d.emptydir.append(i)

def generate_data_install(self, d: InstallData) -> None:
Expand Down Expand Up @@ -1752,7 +1758,8 @@ def generate_symlink_install(self, d: InstallData) -> None:
assert isinstance(l, build.SymlinkData)
install_dir = l.install_dir
name_abs = os.path.join(install_dir, l.name)
s = InstallSymlinkData(l.target, name_abs, install_dir, l.subproject, l.install_tag)
tag = l.install_tag or self.guess_install_tag(name_abs)
s = InstallSymlinkData(l.target, name_abs, install_dir, l.subproject, tag)
d.symlinks.append(s)

def generate_subdir_install(self, d: InstallData) -> None:
Expand All @@ -1772,7 +1779,8 @@ def generate_subdir_install(self, d: InstallData) -> None:
if not sd.strip_directory:
dst_dir = os.path.join(dst_dir, os.path.basename(src_dir))
dst_name = os.path.join(dst_name, os.path.basename(src_dir))
i = SubdirInstallData(src_dir, dst_dir, dst_name, sd.install_mode, sd.exclude, sd.subproject, sd.install_tag)
tag = sd.install_tag or self.guess_install_tag(os.path.join(sd.install_dir, 'dummy'))
i = SubdirInstallData(src_dir, dst_dir, dst_name, sd.install_mode, sd.exclude, sd.subproject, tag)
d.install_subdirs.append(i)

def get_introspection_data(self, target_id: str, target: build.Target) -> T.List['TargetIntrospectionData']:
Expand Down
16 changes: 16 additions & 0 deletions test cases/unit/98 install all targets/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ configure_file(input: 'foo.in', output: 'foo2-devel.h',
static_library('static', 'lib.c',
install: true,
)
custom_target('ct-header1',
output: ['ct-header1.h'],
command: ['script.py', '@OUTPUT@'],
install_dir: get_option('includedir'),
install: true,
)
custom_target('ct-header2',
output: ['ct-header2.h', 'ct-header3.h'],
command: ['script.py', '@OUTPUT@'],
install_dir: [false, get_option('includedir')],
install: true,
)
install_emptydir(get_option('includedir') / 'subdir-devel')
install_subdir('custom_files',
install_dir: get_option('includedir'),
)

# Those files should have 'runtime' tag
executable('app', 'main.c',
Expand Down
5 changes: 5 additions & 0 deletions unittests/allplatformstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4054,6 +4054,11 @@ def exe_name(name):
Path(installpath, 'usr/lib/libstatic.a'),
Path(installpath, 'usr/lib/libboth.a'),
Path(installpath, 'usr/lib/libboth2.a'),
Path(installpath, 'usr/include/ct-header1.h'),
Path(installpath, 'usr/include/ct-header3.h'),
Path(installpath, 'usr/include/subdir-devel'),
Path(installpath, 'usr/include/custom_files'),
Path(installpath, 'usr/include/custom_files/data.txt'),
}

if cc.get_id() in {'msvc', 'clang-cl'}:
Expand Down

0 comments on commit f5871e2

Please sign in to comment.