summaryrefslogtreecommitdiff
path: root/buildstream/_options/option.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-14 18:14:41 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-14 18:14:41 +0900
commitedc1f2020d78a8e0ac5b107f153adac0ed7332d3 (patch)
treed6ac9d35c64f5c28c50b6c40c441e8bbb7c14160 /buildstream/_options/option.py
parent96af5cdb25fa0272957e297a7585962f824c97a7 (diff)
downloadbuildstream-edc1f2020d78a8e0ac5b107f153adac0ed7332d3.tar.gz
_options: Options can now be exported to variables in string form
This patch adds a `variable` attribute to all option definitions, which if specified, can be used to override and declare variable at the project.conf level. A new `get_value()` method was added allowing implementations to create a string for the value of the option - main subclasses updated to support the string conversion with `get_value()`
Diffstat (limited to 'buildstream/_options/option.py')
-rw-r--r--buildstream/_options/option.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/buildstream/_options/option.py b/buildstream/_options/option.py
index 3accddccb..357eb98d3 100644
--- a/buildstream/_options/option.py
+++ b/buildstream/_options/option.py
@@ -25,7 +25,8 @@ from .. import _yaml
#
OPTION_SYMBOLS = [
'type',
- 'description'
+ 'description',
+ 'variable'
]
@@ -46,6 +47,7 @@ class Option():
def __init__(self, name, definition, pool):
self.name = name
self.description = None
+ self.variable = None
self.value = None
self.pool = pool
self.load(definition)
@@ -60,6 +62,7 @@ class Option():
# the option
def load(self, node):
self.description = _yaml.node_get(node, str, 'description')
+ self.variable = _yaml.node_get(node, str, 'variable', default_value='') or None
# load_value()
#
@@ -83,6 +86,18 @@ class Option():
def set_value(self, value):
pass # pragma: nocover
+ # get_value()
+ #
+ # Gets the value of an option in string form, this
+ # is for the purpose of exporting option values to
+ # variables which must be in string form.
+ #
+ # Returns:
+ # (str): The value in string form
+ #
+ def get_value(self):
+ pass # pragma: nocover
+
# resolve()
#
# Called on each option once, after all configuration