summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmar Takhar <amar@rtems.org>2015-06-02 10:25:30 -0400
committerAmar Takhar <amar@rtems.org>2015-06-02 10:25:30 -0400
commit072a2149a32512d1efcd3a376a8e5849bdb98576 (patch)
tree787237f15b524b58e56d62736abb8ea04f98695a
parent2304811f219e8199bb077a77ab962b1b05dc9364 (diff)
Add support for tags in options.
For now not having a tag is non-fatal. Eventually it will be an exception. I've only added one tag at the moment the rest will be added in a GSoC project.
-rw-r--r--rtems_waf/config/options.py25
-rw-r--r--rtems_waf/defaults/options.py1
2 files changed, 26 insertions, 0 deletions
diff --git a/rtems_waf/config/options.py b/rtems_waf/config/options.py
index 9ec02b7e37..7933fc3b95 100644
--- a/rtems_waf/config/options.py
+++ b/rtems_waf/config/options.py
@@ -8,6 +8,12 @@ wrapper.initial_indent = "# "
wrapper.subsequent_indent = "# "
+tag_map = {
+ "general": "General settings",
+ "build": "Build options",
+ "network": "Network option",
+ "storage": "Storage option"
+}
class OptionMeta(type):
"""Self register options."""
@@ -36,6 +42,10 @@ class Option(object):
.. py:attribute:: quote=False
Whether to quote the value in the header.
+
+ .. py:attribute:: tag=list
+
+ List of tags for this option. At least one is required.
"""
def __init__(self, value=None):
@@ -50,6 +60,21 @@ class Option(object):
if not hasattr(self, "quote"):
self.quote = False
+ # Tag sanity check.
+ if not hasattr(self, "tag"):
+# raise Exception("At least one tag is required") # XXX: enable when all options have been set
+ print "%s: Missing tag! At least one is required." % self.name
+ elif type(self.tag) is not list:
+ raise Exception("%s.tag: must be a list()." % self.name)
+ elif not set(self.tag).issubset(tag_map):
+ missing = [x for x in self.tag if x not in tag_map]
+ raise Exception("Tag(s) %s do not exist." % missing)
+ else:
+ duplicates = set([x for x in self.tag if self.tag.count(x) > 1])
+ if duplicates:
+ raise Exception("%s: duplicate tags: %s" % (self.name, duplicates))
+
+
# Value limit
if not hasattr(self, "limit"):
self.limit = None
diff --git a/rtems_waf/defaults/options.py b/rtems_waf/defaults/options.py
index 2cf1af7a72..7e536fe049 100644
--- a/rtems_waf/defaults/options.py
+++ b/rtems_waf/defaults/options.py
@@ -28,6 +28,7 @@ If defined, disable features which are not supported on skyeye.
class BSP(StringList):
+ tag = ["general"]
value = []
undef = True
descr = "List of bsps to build, comma delimited."