summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmar Takhar <amar@rtems.org>2015-02-09 00:38:20 -0500
committerAmar Takhar <amar@rtems.org>2015-02-09 01:18:37 -0500
commitbe74396256e6df42ec80338c2217a30ec89aeaff (patch)
tree4d862a7fd7d0c9be81956ed61e09326fb0357313
parentf9d242ac8b2e6cc2c823cf042843f68ea421920c (diff)
Fix parsing of BSP configs.
There was a bug from an old refactor that did not set BSP configs properly from config.cfg. Now config.cfg is properly parsed with their values loaded internally within the build during 'waf configure'.
-rw-r--r--rtems_waf/config/base.py61
-rw-r--r--rtems_waf/config/options.py4
2 files changed, 49 insertions, 16 deletions
diff --git a/rtems_waf/config/base.py b/rtems_waf/config/base.py
index d7996c2c89..c4ff636815 100644
--- a/rtems_waf/config/base.py
+++ b/rtems_waf/config/base.py
@@ -219,6 +219,7 @@ class BuildConfig(object):
def __init__(self, list_bsp=[]):
self.cfg_default = [cfg_general(), cfg_host(), cfg_bsp()] #: Default BSP configuration.
self.cfg = list(self.cfg_default) #: BSP config.
+ self.list_bsp = []
if list_bsp:
self.list_bsp = sorted(list_bsp)
@@ -226,16 +227,30 @@ class BuildConfig(object):
fatal("Missing config.cfg")
else:
# Load on-disk config.
- self._cfg_user_load()
+ self.cfg_user = ConfigParser()
+ self.cfg_user.read(self.file_config)
+
+ # Set BSP list.
+ # XXX: Far too complicated due to chicken-and-egg issue.
+ # This will be refactored in the future.
+ tmp = cfg_general()
+ opt = tmp.option_build["BSP"]
+ o = self.cfg_user.get("general", "BSP")
+ if version_info < (3,) and type(o) is unicode: #2to3
+ o = str(o)
+ opt.set(o)
+ self.list_bsp = opt.value
# Parse BSPs
self._parse_bsp(self.list_bsp)
+ # Load user configuration
+ self._cfg_user_load()
+
# Make sure BSP= is always set.
self.option_set("general", "BSP", " " .join(self.list_bsp))
-
def _parse_bsp(self, list_bsp):
"""
Parse BSP config.
@@ -289,10 +304,12 @@ class BuildConfig(object):
for option in cfg.option_build:
opt = cfg.option_build[option]
+# self._set_cfg_user(cfg_name, opt)
opt.set_config_build(ctx)
for option in cfg.option_header:
opt = cfg.option_header[option]
+# self._set_cfg_user(cfg_name, opt)
opt.set_config_header(ctx)
@@ -343,38 +360,54 @@ class BuildConfig(object):
def _cfg_user_load(self):
"""Load user config from disk."""
- cfg = ConfigParser()
- cfg.read(self.file_config)
-
for cfg_bsp in self.cfg:
section = cfg_bsp.name
- if not cfg.has_section(section):
+ if not self.cfg_user.has_section(section):
fatal("Missing section: [%s]" % section)
for option in cfg_bsp.option_build:
opt = cfg_bsp.option_build[option]
- o = cfg.get(section, opt.name)
+ o = self.cfg_user.get(section, opt.name)
# configpaser does not convert values anymore.
if o in ["True", "False"]:
- o = cfg.getboolean(section, opt.name)
+ o = self.cfg_user.getboolean(section, opt.name)
# We do not support unicode internally
if version_info < (3,) and type(o) is unicode: #2to3
o = str(o)
- opt.set(o)
+ self._set_cfg_user(section, opt)
- # Set the list of bsps from the config.
- if option == "BSP" and section == "general":
- self.list_bsp = sorted(opt.value)
+# opt.set(o)
for option in cfg_bsp.option_header:
opt = cfg_bsp.option_header[option]
- o = cfg.get(section, opt.name)
- opt.set(o)
+ self._set_cfg_user(section, opt)
+# o = self.cfg_user.get(section, opt.name)
+# opt.set(o)
+
+
+ def _set_cfg_user(self, section, opt):
+ if not self.cfg_user.has_section(section):
+ fatal("Missing section: [%s]" % section)
+
+ o = self.cfg_user.get(section, opt.name)
+
+ # configpaser does not convert values anymore.
+ if o in ["True", "False"]:
+ o = self.cfg_user.getboolean(section, opt.name)
+
+ # We do not support unicode internally
+ if version_info < (3,) and type(o) is unicode: #2to3
+ o = str(o)
+
+ print section, opt
+ opt.set(o)
+
+
diff --git a/rtems_waf/config/options.py b/rtems_waf/config/options.py
index c5e6c82957..9ec02b7e37 100644
--- a/rtems_waf/config/options.py
+++ b/rtems_waf/config/options.py
@@ -266,9 +266,9 @@ class Integer(Option):
return str(self.value)
def _set(self, value):
+ value = int(value) #XXX: configparser doesn't convert this anymore, sigh.
self.validate(value)
- v = int(value) #XXX: Is this even needed? an artifact?
- self.value = v
+ self.value = value
def _set_config_header(self, ctx):
ctx.define(self.name, self.value, quote=self.quote)