Allow for custom Python code injection across the whole Manifest.py hierarchy

parent ebe3f5f6
......@@ -825,10 +825,6 @@ when ``hdlmake`` is executed:
hdlmake --py "simulate_vhdl = False" auto
.. note:: New custom variables are not allowed outside the TOP Manifest.py. In this way, despite the fact that all of the Pyhton code in the used Manifest.py files is executed when ``hdlmake`` is launched, not all of the Python constructions can be implemented.
.. note:: In order to allow the insertion of new custom variables in the child Manifests, you can try the ``--allow-unknown`` experimental feature. By specifiying this optional argument to the ``hdlmake`` command line, a warning message is raised when an unknown option or variable is defined in a child Manifest.py, but the variable itself is inserted and processed.
Remote synthesis with Xilinx ISE
--------------------------------
......
......@@ -283,9 +283,6 @@ def _get_parser():
parser.add_argument("--generate-project-vhd", help="generate project.vhd file with a meta package describing the project",
dest="generate_project_vhd", default=False, action="store_true")
parser.add_argument("--force", help="force hdlmake to generate the makefile, even if the specified tool is missing", default=False, action="store_true")
parser.add_argument("--allow-unknown", dest="allow_unknown",
default=False, help="allow unknown option insertions in the child Manifests", action="store_true")
return parser
......
......@@ -205,13 +205,8 @@ class Module(object):
manifest_parser.add_manifest(self.manifest)
if self.parent is None:
allow_unknown = True
extra_context = {}
else:
if global_mod.options.allow_unknown is True:
allow_unknown = True
else:
allow_unknown = False
extra_context = dict(global_mod.top_module.manifest_dict) # copy the dictionary
del extra_context["modules"]
del extra_context["files"]
......@@ -224,8 +219,7 @@ class Module(object):
opt_map = None
try:
opt_map = manifest_parser.parse(allow_unknown=allow_unknown,
extra_context=extra_context)
opt_map = manifest_parser.parse(extra_context=extra_context)
except NameError as ne:
logging.error("Error while parsing {0}:\n{1}: {2}.".format(self.manifest, type(ne), ne))
quit()
......
......@@ -233,7 +233,7 @@ class ConfigParser(object):
def __names(self):
return [o.name for o in self.options if o is not None]
def parse(self, allow_unknown=False, verbose=False, extra_context=None):
def parse(self, verbose=False, extra_context=None):
assert isinstance(extra_context, dict) or extra_context is None
options = {}
ret = {}
......@@ -293,14 +293,10 @@ class ConfigParser(object):
if opt_name not in self.__names():
if opt_name in arbitrary_options:
continue # finish processing of this variable here
elif allow_unknown is True:
else:
ret[opt_name] = val
logging.warning("Given variable is not recognized: %s (=%s).\nPlease double check it is not en error" % (opt_name, val))
logging.warning("New custom variable found: %s (=%s).\n" % (opt_name, val))
continue
else:
#if opt_name.startswith("global_"):
# continue
raise NameError("Unrecognized option: " + opt_name)
opt = self[opt_name]
if type(val) not in opt.types:
raise RuntimeError("Given option: %s doesn't match specified types: %s" % (str(type(val)), str(opt.types)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment