diff options
author | Daniele Nicolodi <daniele@grinta.net> | 2023-02-21 20:45:12 +0100 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2023-02-27 07:03:30 -0500 |
commit | f39ccde5138aeabcbd483ca4b779954f056324e2 (patch) | |
tree | ce244ca87dc2cb903e000c6d4d96a50023ac1fb7 | |
parent | b80f8456ec754c579dfd5c1bbb4dc4be3500e7e6 (diff) | |
download | meson-f39ccde5138aeabcbd483ca4b779954f056324e2.zip meson-f39ccde5138aeabcbd483ca4b779954f056324e2.tar.gz meson-f39ccde5138aeabcbd483ca4b779954f056324e2.tar.bz2 |
mintro: Add exclude_{files, dirs} to install_subdir install_plan
These are necessary for projects outside Meson itself that want to
extend the 'meson install' functionality as meson-python does to
assemble Python package wheels from Meson projects.
Fixes #11426.
6 files changed, 30 insertions, 3 deletions
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 2312674..1fd0f3d 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -146,11 +146,19 @@ def list_install_plan(installdata: backends.InstallData) -> T.Dict[str, T.Dict[s if key == 'headers': # in the headers, install_path_name is the directory install_path_name = os.path.join(install_path_name, os.path.basename(data.path)) - plan[data_type] = plan.get(data_type, {}) - plan[data_type][data.path] = { + entry = { 'destination': install_path_name, 'tag': data.tag or None, } + + if key == 'install_subdirs': + exclude_files, exclude_dirs = data.exclude or ([], []) + entry['exclude_dirs'] = list(exclude_dirs) + entry['exclude_files'] = list(exclude_files) + + plan[data_type] = plan.get(data_type, {}) + plan[data_type][data.path] = entry + return plan def get_target_dir(coredata: cdata.CoreData, subdir: str) -> str: diff --git a/test cases/unit/98 install all targets/excludes/excluded.txt b/test cases/unit/98 install all targets/excludes/excluded.txt new file mode 100644 index 0000000..59b0644 --- /dev/null +++ b/test cases/unit/98 install all targets/excludes/excluded.txt @@ -0,0 +1 @@ +Excluded diff --git a/test cases/unit/98 install all targets/excludes/excluded/placeholder.txt b/test cases/unit/98 install all targets/excludes/excluded/placeholder.txt new file mode 100644 index 0000000..3b94f91 --- /dev/null +++ b/test cases/unit/98 install all targets/excludes/excluded/placeholder.txt @@ -0,0 +1 @@ +Placeholder diff --git a/test cases/unit/98 install all targets/excludes/installed.txt b/test cases/unit/98 install all targets/excludes/installed.txt new file mode 100644 index 0000000..8437692 --- /dev/null +++ b/test cases/unit/98 install all targets/excludes/installed.txt @@ -0,0 +1 @@ +Installed diff --git a/test cases/unit/98 install all targets/meson.build b/test cases/unit/98 install all targets/meson.build index 3065b5f..75b4590 100644 --- a/test cases/unit/98 install all targets/meson.build +++ b/test cases/unit/98 install all targets/meson.build @@ -94,6 +94,12 @@ install_subdir('custom_files', install_dir: get_option('datadir'), install_tag: 'custom', ) +install_subdir('excludes', + install_dir: get_option('datadir'), + install_tag: 'custom', + exclude_directories: 'excluded', + exclude_files: 'excluded.txt', +) # First is custom, 2nd is devel, 3rd has no tag custom_target('ct3', diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 3dd8a32..99dbf51 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -4235,6 +4235,8 @@ class AllPlatformTests(BasePlatformTests): Path(installpath, 'usr/share/out3-custom.txt'), Path(installpath, 'usr/share/custom_files'), Path(installpath, 'usr/share/custom_files/data.txt'), + Path(installpath, 'usr/share/excludes'), + Path(installpath, 'usr/share/excludes/installed.txt'), Path(installpath, 'usr/lib'), Path(installpath, 'usr/lib/libbothcustom.a'), Path(installpath, 'usr/' + shared_lib_name('bothcustom')), @@ -4442,7 +4444,15 @@ class AllPlatformTests(BasePlatformTests): 'install_subdirs': { f'{testdir}/custom_files': { 'destination': '{datadir}/custom_files', - 'tag': 'custom' + 'tag': 'custom', + 'exclude_dirs': [], + 'exclude_files': [], + }, + f'{testdir}/excludes': { + 'destination': '{datadir}/excludes', + 'tag': 'custom', + 'exclude_dirs': ['excluded'], + 'exclude_files': ['excluded.txt'], } } } |