aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2019-01-09 15:56:52 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2019-01-14 00:16:36 +0200
commitb53c982b58372901bfd9ffbbfe36831c85b465b4 (patch)
tree31ba4e2bba465a22e5e8d18724765417b9da2e51 /mesonbuild/build.py
parent95c1cdf7767d5b5bf4614651afeafa100f1de45c (diff)
downloadmeson-b53c982b58372901bfd9ffbbfe36831c85b465b4.zip
meson-b53c982b58372901bfd9ffbbfe36831c85b465b4.tar.gz
meson-b53c982b58372901bfd9ffbbfe36831c85b465b4.tar.bz2
Build class should not duplicate compiler state
Compilers should be held by coredata, so this is just here for convenience.
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r--mesonbuild/build.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 91edbb8..52af562 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -111,8 +111,9 @@ class Build:
self.environment = environment
self.projects = {}
self.targets = OrderedDict()
- self.compilers = OrderedDict()
- self.cross_compilers = OrderedDict()
+ # Coredata holds the state. This is just here for convenience.
+ self.compilers = environment.coredata.compilers
+ self.cross_compilers = environment.coredata.cross_compilers
self.global_args = {}
self.projects_args = {}
self.global_link_args = {}
@@ -145,6 +146,10 @@ class Build:
def copy(self):
other = Build(self.environment)
for k, v in self.__dict__.items():
+ if k in ['compilers', 'cross_compilers']:
+ # These alias coredata's fields of the same name, and must not
+ # become copies.
+ continue
if isinstance(v, (list, dict, set, OrderedDict)):
other.__dict__[k] = v.copy()
else:
@@ -155,19 +160,13 @@ class Build:
for k, v in other.__dict__.items():
self.__dict__[k] = v
- def add_compiler(self, compiler):
+ def ensure_static_linker(self, compiler):
if self.static_linker is None and compiler.needs_static_linker():
self.static_linker = self.environment.detect_static_linker(compiler)
- lang = compiler.get_language()
- if lang not in self.compilers:
- self.compilers[lang] = compiler
- def add_cross_compiler(self, compiler):
- if not self.cross_compilers:
+ def ensure_static_cross_linker(self, compiler):
+ if self.static_cross_linker is None and compiler.needs_static_linker():
self.static_cross_linker = self.environment.detect_static_linker(compiler)
- lang = compiler.get_language()
- if lang not in self.cross_compilers:
- self.cross_compilers[lang] = compiler
def get_project(self):
return self.projects['']