aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorNicolas Schneider <nioncode+git@gmail.com>2019-01-05 22:12:02 +0100
committerXavier Claessens <xclaesse@gmail.com>2019-01-06 19:41:24 -0500
commit3232f780d8c3baba0cbca3f9fea18d1a722bf957 (patch)
tree105cd5ec72000d7ed4d1dfe02e4d137bcbdc2648 /mesonbuild
parentf658107a0e424ad3a9659a4b53f310dec9fae690 (diff)
downloadmeson-3232f780d8c3baba0cbca3f9fea18d1a722bf957.zip
meson-3232f780d8c3baba0cbca3f9fea18d1a722bf957.tar.gz
meson-3232f780d8c3baba0cbca3f9fea18d1a722bf957.tar.bz2
use same code for printing options in mconf and msetup
Also, options are now responsible for providing a suitable printable representation of their value instead of handling this at the caller.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/coredata.py8
-rw-r--r--mesonbuild/interpreter.py2
-rw-r--r--mesonbuild/mconf.py21
-rw-r--r--mesonbuild/msetup.py5
4 files changed, 22 insertions, 14 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 6262011..8c9d513 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -43,6 +43,9 @@ class UserOption:
raise MesonException('Value of "yielding" must be a boolean.')
self.yielding = yielding
+ def printable_value(self):
+ return self.value
+
# Check that the input is a valid value and return the
# "cleaned" or "native" version. For example the Boolean
# option could take the string "true" and return True.
@@ -114,6 +117,11 @@ class UserUmaskOption(UserIntegerOption):
super().__init__(name, description, 0, 0o777, value, yielding)
self.choices = ['preserve', '0000-0777']
+ def printable_value(self):
+ if self.value == 'preserve':
+ return self.value
+ return format(self.value, '04o')
+
def validate_value(self, value):
if value is None or value == 'preserve':
return 'preserve'
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 07af41d..9ebce70 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2034,7 +2034,7 @@ class Interpreter(InterpreterBase):
for cur_opt_name, cur_opt_value in option_type.items():
if (def_opt_name == cur_opt_name and
def_opt_value != cur_opt_value.value):
- yield (def_opt_name, def_opt_value, cur_opt_value.value)
+ yield (def_opt_name, def_opt_value, cur_opt_value)
def build_func_dict(self):
self.funcs.update({'add_global_arguments': self.func_add_global_arguments,
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py
index 61bb74b..2863b0c 100644
--- a/mesonbuild/mconf.py
+++ b/mesonbuild/mconf.py
@@ -23,6 +23,15 @@ def add_arguments(parser):
help='Clear cached state (e.g. found dependencies)')
+def make_lower_case(val):
+ if isinstance(val, bool):
+ return str(val).lower()
+ elif isinstance(val, list):
+ return [make_lower_case(i) for i in val]
+ else:
+ return str(val)
+
+
class ConfException(mesonlib.MesonException):
pass
@@ -50,14 +59,6 @@ class Conf:
@staticmethod
def print_aligned(arr):
- def make_lower_case(val):
- if isinstance(val, bool):
- return str(val).lower()
- elif isinstance(val, list):
- return [make_lower_case(i) for i in val]
- else:
- return str(val)
-
if not arr:
return
@@ -104,10 +105,8 @@ class Conf:
for k in sorted(options):
o = options[k]
d = o.description
- v = o.value
+ v = o.printable_value()
c = o.choices
- if isinstance(o, coredata.UserUmaskOption):
- v = v if isinstance(v, str) else format(v, '04o')
arr.append({'name': k, 'descr': d, 'value': v, 'choices': c})
self.print_aligned(arr)
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py
index 402f756..67559a1 100644
--- a/mesonbuild/msetup.py
+++ b/mesonbuild/msetup.py
@@ -24,6 +24,7 @@ from . import environment, interpreter, mesonlib
from . import build
from . import mlog, coredata
from . import mintro
+from .mconf import make_lower_case
from .mesonlib import MesonException
def add_arguments(parser):
@@ -192,8 +193,8 @@ class MesonApp:
# Print all default option values that don't match the current value
for def_opt_name, def_opt_value, cur_opt_value in intr.get_non_matching_default_options():
mlog.log('Option', mlog.bold(def_opt_name), 'is:',
- mlog.bold(str(cur_opt_value)),
- '[default: {}]'.format(str(def_opt_value)))
+ mlog.bold(make_lower_case(cur_opt_value.printable_value())),
+ '[default: {}]'.format(make_lower_case(def_opt_value)))
try:
dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat')
# We would like to write coredata as late as possible since we use the existence of