diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2023-12-11 10:01:10 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2024-03-29 13:06:54 -0700 |
commit | fae1363bd3d4b6aec4b2de41f58385e277d91eca (patch) | |
tree | db8da7aa366cc4ef83a30b81809d7a46c092b698 /mesonbuild/backend | |
parent | 934c9074bdd81c31a67d87a290247007332cdbcf (diff) | |
download | meson-fae1363bd3d4b6aec4b2de41f58385e277d91eca.zip meson-fae1363bd3d4b6aec4b2de41f58385e277d91eca.tar.gz meson-fae1363bd3d4b6aec4b2de41f58385e277d91eca.tar.bz2 |
scripts/depscan: combine pickle and JSON data into a single file
We don't need to write and pass two separate files to the depscanner,
I've used the pickle because the pickle serializer/deserializer should
be faster than JSON, thought I haven't tested.
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index d729d19..77e1b04 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -144,10 +144,12 @@ class TargetDependencyScannerInfo: :param private_dir: The private scratch directory for the target. :param source2object: A mapping of source file names to the objects that will be created from them. + :param sources: A list of all the sources in this target """ private_dir: str source2object: T.Dict[str, str] + sources: T.List[str] @unique @@ -1095,25 +1097,20 @@ class NinjaBackend(backends.Backend): pickle_base = target.name + '.dat' pickle_file = os.path.join(self.get_target_private_dir(target), pickle_base).replace('\\', '/') pickle_abs = os.path.join(self.get_target_private_dir_abs(target), pickle_base).replace('\\', '/') - json_abs = os.path.join(self.get_target_private_dir_abs(target), f'{target.name}-deps.json').replace('\\', '/') rule_name = 'depscan' scan_sources = self.select_sources_to_scan(compiled_sources) - # Dump the sources as a json list. This avoids potential problems where - # the number of sources passed to depscan exceeds the limit imposed by - # the OS. - with open(json_abs, 'w', encoding='utf-8') as f: - json.dump(scan_sources, f) - elem = NinjaBuildElement(self.all_outputs, depscan_file, rule_name, json_abs) - elem.add_item('picklefile', pickle_file) + scaninfo = TargetDependencyScannerInfo( + self.get_target_private_dir(target), source2object, scan_sources) + with open(pickle_abs, 'wb') as p: + pickle.dump(scaninfo, p) + + elem = NinjaBuildElement(self.all_outputs, depscan_file, rule_name, pickle_file) # Add any generated outputs to the order deps of the scan target, so # that those sources are present for g in generated_source_files: elem.orderdeps.add(g.relative_name()) elem.orderdeps.update(object_deps) - scaninfo = TargetDependencyScannerInfo(self.get_target_private_dir(target), source2object) - with open(pickle_abs, 'wb') as p: - pickle.dump(scaninfo, p) self.add_build(elem) def select_sources_to_scan(self, compiled_sources: T.List[str]) -> T.List[str]: |