aboutsummaryrefslogtreecommitdiffstats
path: root/android/tools
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2012-03-21 08:37:48 -0700
committerVladimir Chtchetkine <vchtchetkine@google.com>2012-03-21 09:23:37 -0700
commit541a7b25951ed30c7411eda50cce3ff9fa0289e4 (patch)
tree37bb2f26c31ea5125ac513b63357c8c14381b945 /android/tools
parent62caadba077a31c08552fe23c0e0a0b70b2f6636 (diff)
downloadexternal_qemu-541a7b25951ed30c7411eda50cce3ff9fa0289e4.zip
external_qemu-541a7b25951ed30c7411eda50cce3ff9fa0289e4.tar.gz
external_qemu-541a7b25951ed30c7411eda50cce3ff9fa0289e4.tar.bz2
Add 'enum' entry type to hw.ini file
'entry' type enumerates values that are allowed for the given type name. Change-Id: Ic0f4021f761dfd78ff4dd9d2b58a2d811109b3c6
Diffstat (limited to 'android/tools')
-rwxr-xr-xandroid/tools/gen-hw-config.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/android/tools/gen-hw-config.py b/android/tools/gen-hw-config.py
index 3822485..201ef04 100755
--- a/android/tools/gen-hw-config.py
+++ b/android/tools/gen-hw-config.py
@@ -28,7 +28,7 @@ def quoteStringForC(str):
# a dictionary that maps item types as they appear in the .ini
# file into macro names in the generated C header
#
-typesToMacros = {
+typesToMacros = {
'integer': 'HWCFG_INT',
'string': 'HWCFG_STRING',
'boolean': 'HWCFG_BOOL',
@@ -69,12 +69,27 @@ class Item:
self.default = None
self.abstract = ""
self.description = ""
+ self.enum_values = []
def add(self,key,val):
if key == 'type':
self.type = val
+ elif key == 'enum':
+ # Build list of enumerated values
+ self.enum_values = [ s.strip() for s in val.split(',') ]
+ # If default value has been already set, make sure it's in the list
+ if self.default and not self.default in self.enum_values:
+ print "Property '" + self.name + "': Default value '" + self.default + "' is missing in enum: ",
+ print self.enum_values,
+ sys.exit(1)
elif key == 'default':
- self.default = val
+ # If this is an enum, make sure that default value is in the list.
+ if val and self.enum_values and not val in self.enum_values:
+ print "Property '" + self.name + "': Default value '" + val + "' is missing in enum: ",
+ print self.enum_values,
+ sys.exit(1)
+ else:
+ self.default = val
elif key == 'abstract':
self.abstract = val
elif key == 'description':