From f9445300b3015308fd6a3e0305cf8e5b7f002211 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 18 Mar 2022 10:28:38 -0700 Subject: structured_sources: fix subdir handling We currently don't handle subdirectories correctly in structured_sources, which is problematic. To make this easier to handle correctly, I've simply changed `structured_sources` to only use Files and not strings as an implementation detail. --- mesonbuild/backend/ninjabackend.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index fdd5cd3..691f844 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1669,9 +1669,7 @@ class NinjaBackend(backends.Backend): root = Path(self.get_target_private_dir(target)) / 'structured' for path, files in target.structured_sources.sources.items(): for file in files: - if isinstance(file, (str, File)): - if isinstance(file, str): - file = File.from_absolute_file(file) + if isinstance(file, File): out = root / path / Path(file.fname).name orderdeps.append(str(out)) self._generate_copy_target(file, out) @@ -1707,13 +1705,11 @@ class NinjaBackend(backends.Backend): main_rust_file = None if target.structured_sources: - if target.structured_sources.needs_copy(target): + if target.structured_sources.needs_copy(): _ods, main_rust_file = self.__generate_compile_structure(target) orderdeps.extend(_ods) else: g = target.structured_sources.first_file() - if isinstance(g, str): - g = File.from_source_file(self.environment.source_dir, target.subdir, g) if isinstance(g, File): main_rust_file = g.rel_to_builddir(self.build_to_src) -- cgit v1.1 From 9b83fc5ece8932661ea0255e5362417fef117b15 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 18 Mar 2022 19:46:47 -0700 Subject: ninja: fix handling of rust structured_sources in rare case In the even that all of the inputs are generated, and they're all generated into the same folder, and there are no subfolders, we would fail to correctly handle all of the files after the main file. Let's fix that.t --- mesonbuild/backend/ninjabackend.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 691f844..614e864 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1709,17 +1709,24 @@ class NinjaBackend(backends.Backend): _ods, main_rust_file = self.__generate_compile_structure(target) orderdeps.extend(_ods) else: + # The only way to get here is to have only files in the "root" + # positional argument, which are all generated into the same + # directory g = target.structured_sources.first_file() if isinstance(g, File): main_rust_file = g.rel_to_builddir(self.build_to_src) elif isinstance(g, GeneratedList): - main_rust_file = os.path.join(self.get_target_private_dir(target), i) + main_rust_file = os.path.join(self.get_target_private_dir(target), g.get_outputs()[0]) else: - main_rust_file = os.path.join(g.get_subdir(), i) - orderdeps.extend([os.path.join(self.build_to_src, target.subdir, s) - for s in target.structured_sources.as_list()]) + main_rust_file = os.path.join(g.get_subdir(), g.get_outputs()[0]) + for f in target.structured_sources.as_list(): + if isinstance(f, File): + orderdeps.append(f.rel_to_builddir(self.build_to_src)) + else: + orderdeps.extend([os.path.join(self.build_to_src, f.subdir, s) + for s in f.get_outputs()]) for i in target.get_sources(): if not rustc.can_compile(i): -- cgit v1.1