From 979eaa804aaced2823f446242eaecd043d33521a Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Sat, 10 Mar 2018 20:58:06 -0800 Subject: [PATCH] Make the generated pkgconfig files reproducible. Whilst working on the Reproducible Builds effort [0], we noticed that meson creates non-reproducible pkgconfig files as it relies on Python set ordering. This was originally filed in Debian as #892515 [1]. [0] https://reproducible-builds.org/ [1] https://bugs.debian.org/892515 --- mesonbuild/modules/pkgconfig.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index c89f657de..79a4423b5 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -124,11 +124,18 @@ class DependenciesHelper: return processed_libs, processed_reqs, processed_cflags def remove_dups(self): - self.pub_libs = list(set(self.pub_libs)) - self.pub_reqs = list(set(self.pub_reqs)) - self.priv_libs = list(set(self.priv_libs)) - self.priv_reqs = list(set(self.priv_reqs)) - self.cflags = list(set(self.cflags)) + def _fn(xs): + # Remove duplicates whilst preserving original order + result = [] + for x in xs: + if x not in result: + result.append(x) + return result + self.pub_libs = _fn(self.pub_libs) + self.pub_reqs = _fn(self.pub_reqs) + self.priv_libs = _fn(self.priv_libs) + self.priv_reqs = _fn(self.priv_reqs) + self.cflags = _fn(self.cflags) # Remove from private libs/reqs if they are in public already self.priv_libs = [i for i in self.priv_libs if i not in self.pub_libs]