ninjabackend: track all outputs using a set

We need to verify that we don't produce multiple rules for the same
file. This uniqueness check is easy to do with a set, but the original
old implementation used a dict with True as the value. This isn't a
terrible way to implement a set -- we do it for our own internal
OrderedSet implementation, even, and back in prehistory (python 2.3) the
standard library's set type was one. But it was deleted and replaced
with a fast native implementation, and we should too.
pull/12027/head
Eli Schwartz 1 year ago
parent 22d842a97d
commit 4d3432daa3
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 6
      mesonbuild/backend/ninjabackend.py

@ -299,7 +299,7 @@ class NinjaRule:
return estimate
class NinjaBuildElement:
def __init__(self, all_outputs, outfilenames, rulename, infilenames, implicit_outs=None):
def __init__(self, all_outputs: T.Set[str], outfilenames, rulename, infilenames, implicit_outs=None):
self.implicit_outfilenames = implicit_outs or []
if isinstance(outfilenames, str):
self.outfilenames = [outfilenames]
@ -426,7 +426,7 @@ class NinjaBuildElement:
for n in self.outfilenames:
if n in self.all_outputs:
self.output_errors = f'Multiple producers for Ninja target "{n}". Please rename your targets.'
self.all_outputs[n] = True
self.all_outputs.add(n)
@dataclass
class RustDep:
@ -485,7 +485,7 @@ class NinjaBackend(backends.Backend):
self.name = 'ninja'
self.ninja_filename = 'build.ninja'
self.fortran_deps = {}
self.all_outputs = {}
self.all_outputs: T.Set[str] = set()
self.introspection_data = {}
self.created_llvm_ir_rule = PerMachine(False, False)
self.rust_crates: T.Dict[str, RustCrate] = {}

Loading…
Cancel
Save