diff options
author | Sam Thursfield <sam@afuera.me.uk> | 2017-04-01 20:04:53 +0100 |
---|---|---|
committer | Sam Thursfield <sam@afuera.me.uk> | 2017-04-03 17:02:41 +0100 |
commit | f5b7cfdbf0888fb99956cf2dc661c519aa08a9a4 (patch) | |
tree | 4f8f1e7c8d0a2798dd3c8c6e1360e2fb25d73328 /mesonbuild/build.py | |
parent | c7f66c3a9e4f69e0bcde8819f15c9d8b972a2f75 (diff) | |
download | meson-f5b7cfdbf0888fb99956cf2dc661c519aa08a9a4.zip meson-f5b7cfdbf0888fb99956cf2dc661c519aa08a9a4.tar.gz meson-f5b7cfdbf0888fb99956cf2dc661c519aa08a9a4.tar.bz2 |
Ensure rules in the generated build.ninja file are in a stable order
Previously, two functionally identical builds could produce different
build.ninja files. The ordering of the rules themselves doesn't affect
behaviour, but unnecessary changes in commandline arguments can cause
spurious rebuilds and if the ordering of the overall file is stable
than it's easy to use `diff` to compare different build.ninja files
and spot the differences in ordering that are triggering the unnecessary
rebuilds.
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r-- | mesonbuild/build.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index ce5638d..ed0abc4 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -82,9 +82,9 @@ class Build: self.project_version = None self.environment = environment self.projects = {} - self.targets = {} - self.compilers = {} - self.cross_compilers = {} + self.targets = OrderedDict() + self.compilers = OrderedDict() + self.cross_compilers = OrderedDict() self.global_args = {} self.projects_args = {} self.global_link_args = {} @@ -326,6 +326,9 @@ class BuildTarget(Target): self.validate_sources() self.validate_cross_install(environment) + def __lt__(self, other): + return self.get_id() < other.get_id() + def __repr__(self): repr_str = "<{0} {1}: {2}>" return repr_str.format(self.__class__.__name__, self.get_id(), self.filename) @@ -1257,6 +1260,9 @@ class CustomTarget(Target): mlog.warning('Unknown keyword arguments in target %s: %s' % (self.name, ', '.join(unknowns))) + def __lt__(self, other): + return self.get_id() < other.get_id() + def __repr__(self): repr_str = "<{0} {1}: {2}>" return repr_str.format(self.__class__.__name__, self.get_id(), self.command) @@ -1417,6 +1423,9 @@ class RunTarget(Target): self.args = args self.dependencies = dependencies + def __lt__(self, other): + return self.get_id() < other.get_id() + def __repr__(self): repr_str = "<{0} {1}: {2}>" return repr_str.format(self.__class__.__name__, self.get_id(), self.command) |