aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2019-06-12 18:08:45 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2020-04-20 23:23:15 +0300
commit278c294aa45efc3e8b068bcd7632828ed5c92523 (patch)
tree36372ef2c9a5897cca87e8c44628c8f9e00c368e /mesonbuild/build.py
parente04b0ae6b6220381b4aa493289960a3555201717 (diff)
downloadmeson-278c294aa45efc3e8b068bcd7632828ed5c92523.zip
meson-278c294aa45efc3e8b068bcd7632828ed5c92523.tar.gz
meson-278c294aa45efc3e8b068bcd7632828ed5c92523.tar.bz2
Compiler options per lang
A current rather untyped storage of options is one of the things that contributes to the options code being so complex. This takes a small step in synching down by storing the compiler options in dicts per language. Future work might be replacing the langauge strings with an enum, and defaultdict with a custom struct, just like `PerMachine` and `MachineChoice`.
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r--mesonbuild/build.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index b1bf9d4..c200261 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -13,7 +13,7 @@
# limitations under the License.
import copy, os, re
-from collections import OrderedDict
+from collections import OrderedDict, defaultdict
import itertools, pathlib
import hashlib
import pickle
@@ -28,7 +28,10 @@ from .mesonlib import (
extract_as_list, typeslistify, stringlistify, classify_unity_sources,
get_filenames_templates_dict, substitute_values, has_path_sep, unholder
)
-from .compilers import Compiler, is_object, clink_langs, sort_clink, lang_suffixes, is_known_suffix
+from .compilers import (
+ Compiler, all_languages, is_object, clink_langs, sort_clink, lang_suffixes,
+ is_known_suffix
+)
from .linkers import StaticLinker
from .interpreterbase import FeatureNew
@@ -358,7 +361,8 @@ a hard error in the future.'''.format(name))
self.for_machine = for_machine
self.install = False
self.build_always_stale = False
- self.option_overrides = {}
+ self.option_overrides_base = {}
+ self.option_overrides_compiler = defaultdict(dict)
if not hasattr(self, 'typename'):
raise RuntimeError('Target type is not set for target class "{}". This is a bug'.format(type(self).__name__))
@@ -448,7 +452,15 @@ a hard error in the future.'''.format(name))
# set, use the value of 'install' if it's enabled.
self.build_by_default = True
- self.option_overrides = self.parse_overrides(kwargs)
+ option_overrides = self.parse_overrides(kwargs)
+
+ for k, v in option_overrides.items():
+ if '_' in k:
+ lang, k2 = k.split('_', 1)
+ if lang in all_languages:
+ self.option_overrides_compiler[lang][k2] = v
+ continue
+ self.option_overrides_base[k] = v
def parse_overrides(self, kwargs) -> dict:
result = {}