aboutsummaryrefslogtreecommitdiff
path: root/mesonconf.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2014-01-05 23:03:52 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2014-01-05 23:03:52 +0200
commitf31bf4636ac245c71ed88d5990c2b6d6484e37e8 (patch)
tree9010ced34bb0e98554f5af4df0660f6b59009073 /mesonconf.py
parent671141fb369435202352652876662946849eab89 (diff)
downloadmeson-f31bf4636ac245c71ed88d5990c2b6d6484e37e8.zip
meson-f31bf4636ac245c71ed88d5990c2b6d6484e37e8.tar.gz
meson-f31bf4636ac245c71ed88d5990c2b6d6484e37e8.tar.bz2
Can set core options.
Diffstat (limited to 'mesonconf.py')
-rwxr-xr-xmesonconf.py42
1 files changed, 40 insertions, 2 deletions
diff --git a/mesonconf.py b/mesonconf.py
index 37aaede..02e9702 100755
--- a/mesonconf.py
+++ b/mesonconf.py
@@ -18,11 +18,15 @@ import sys, os
import pickle
from optparse import OptionParser
import coredata
+from meson import build_types
-usage_info = '%prog [build dir]'
+usage_info = '%prog [build dir] [set commands]'
parser = OptionParser(usage=usage_info, version=coredata.version)
+parser.add_option('-D', action='append', default=[], dest='sets',
+ help='Set an option to the given value.')
+
class ConfException(Exception):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -40,6 +44,10 @@ class Conf:
raise ConfException('Version mismatch (%s vs %s)' %
(coredata.version, self.coredata.version))
+ def save(self):
+ # Only called if something has changed so overwrite unconditionally.
+ pickle.dump(self.coredata, open(self.coredata_file, 'wb'))
+
def print_aligned(self, arr):
longest = max((len(x[0]) for x in arr))
for i in arr:
@@ -49,6 +57,32 @@ class Conf:
f = '%s:%s' % (name, padding)
print(f, value)
+ def tobool(self, thing):
+ if thing.lower() == 'true':
+ return True
+ if thing.lower() == 'false':
+ return False
+ raise ConfException('Value %s is not boolean (true or false)' % thing)
+
+ def set_options(self, options):
+ for o in options:
+ if '=' not in o:
+ raise ConfException('Value "%s" not of type "a=b"' % o)
+ (k, v) = o.split('=', 1)
+ if k == 'type':
+ if v not in build_types:
+ raise ConfException('Invalid build type %s' % v)
+ self.coredata.buildtype = v
+ elif k == 'strip':
+ self.coredata.strip = self.tobool(v)
+ elif k == 'coverage':
+ v = self.tobool(v)
+ self.coredata.coverage = self.tobool(v)
+ elif k == 'pch':
+ self.coredata.use_pch = self.tobool(v)
+ elif k == 'unity':
+ self.coredata.unity = self.tobool(v)
+
def print_conf(self):
print('Core properties\n')
print('Source dir:', self.build.environment.source_dir)
@@ -86,7 +120,11 @@ if __name__ == '__main__':
builddir = args[-1]
try:
c = Conf(builddir)
- c.print_conf()
+ if len(options.sets) > 0:
+ c.set_options(options.sets)
+ c.save()
+ else:
+ c.print_conf()
except ConfException as e:
print('Meson configurator encountered an error:\n')
print(e)