Commit 1eaee5c2 authored by Istvan Kiss's avatar Istvan Kiss

Option to include .mk at end of generated Makefile

This allows for Makefile .mk includes that can access and use
the top level Makefile variables defined/generated by HDLMake,
like TOP_MODULE, detected TOOL_PATH, etc.

This feature can be used for e.g. adding make targets/recipes
to genete or convert flash ROM files.
parent 9fa7d06c
......@@ -1451,15 +1451,17 @@ Manifest variables description
Top Manifest variables
----------------------
+----------------+--------------+-----------------------------------------------------------------+-----------+
| Name | Type | Description | Default |
+================+==============+=================================================================+===========+
| action | str | What is the action that should be taken (simulation/synthesis) | "" |
+----------------+--------------+-----------------------------------------------------------------+-----------+
| incl_makefiles | list | List of .mk files included in the generated makefile | [] |
+----------------+--------------+-----------------------------------------------------------------+-----------+
| language | str | Select the default HDL language if required (verilog, vhdl) | "vhdl" |
+----------------+--------------+-----------------------------------------------------------------+-----------+
+---------------------+--------------+-----------------------------------------------------------------------+-----------+
| Name | Type | Description | Default |
+=====================+==============+=======================================================================+===========+
| action | str | What is the action that should be taken (simulation/synthesis) | "" |
+---------------------+--------------+-----------------------------------------------------------------------+-----------+
| incl_makefiles | list | List of .mk files included at the beginning of the generated makefile | [] |
+---------------------+--------------+-----------------------------------------------------------------------+-----------+
| incl_post_makefiles | list | List of .mk files included at the end of the generated makefile | [] |
+---------------------+--------------+-----------------------------------------------------------------------+-----------+
| language | str | Select the default HDL language if required (verilog, vhdl) | "vhdl" |
+---------------------+--------------+-----------------------------------------------------------------------+-----------+
Universal variables
......
......@@ -66,6 +66,10 @@ class ManifestParser(ConfigParser):
'default': [],
'help': "List of .mk files appended to toplevel makefile",
'type': []},
{'name': 'incl_post_makefiles',
'default': [],
'help': "List of .mk files appended to the end of toplevel makefile, since they might use variables from toplevel makefile",
'type': []},
{'name': 'files',
'default': [],
'help': "List of files from the current module",
......@@ -82,6 +86,7 @@ class ManifestParser(ConfigParser):
self.add_delimiter()
self.add_type('include_dirs', type_new="")
self.add_type('incl_makefiles', type_new='')
self.add_type('incl_post_makefiles', type_new='')
self.add_type('files', type_new=[])
self.add_allowed_key('modules', key="svn")
self.add_allowed_key('modules', key="git")
......
......@@ -76,6 +76,7 @@ class Module(object):
# Manifest Modules Properties
self.modules = {'local': [], 'git': [], 'gitsm': [], 'svn': []}
self.incl_makefiles = [] # List of paths of makefile files to include.
self.incl_post_makefiles = [] # List of paths of makefile files to include at the end of top makefile.
self.library = None
self.action = action
self.top_manifest = action.get_top_manifest()
......@@ -141,6 +142,7 @@ class Module(object):
self._process_manifest_files()
self._process_manifest_modules()
self._process_manifest_makefiles()
self._process_manifest_post_makefiles()
def _process_manifest_library(self):
"""Method processing the universal manifest directives;
......@@ -324,6 +326,20 @@ class Module(object):
makefiles_paths = self._make_list_of_paths(included_makefiles_aux)
self.incl_makefiles.extend(makefiles_paths)
def _process_manifest_post_makefiles(self):
"""Get the extra post-makefiles defined in the HDLMake module"""
# Included Makefiles
included_post_makefiles_aux = []
if "incl_post_makefiles" in self.manifest_dict:
if isinstance(self.manifest_dict["incl_post_makefiles"],
six.string_types):
included_post_makefiles_aux.append(
self.manifest_dict["incl_post_makefiles"])
else: # list
included_post_makefiles_aux = self.manifest_dict["incl_post_makefiles"][:]
post_makefiles_paths = self._make_list_of_paths(included_post_makefiles_aux)
self.incl_post_makefiles.extend(post_makefiles_paths)
def submodules(self):
"""Get a list with all the submodules this module instance requires"""
res = []
......
......@@ -151,6 +151,17 @@ class ToolMakefile(object):
logging.warning("Included Makefile %s NOT found.", file_aux)
self.writeln()
def makefile_post_includes(self):
"""Add the included makefiles that need to be placed at the end of the main
Makefile, since they might rely on variables defined in the main Makefile"""
if self.manifest_dict.get("incl_post_makefiles") is not None:
for file_aux in self.manifest_dict["incl_post_makefiles"]:
if os.path.exists(file_aux):
self.writeln("include %s" % file_aux)
else:
logging.warning("Included Makefile %s NOT found.", file_aux)
self.writeln()
def makefile_clean(self):
"""Print the Makefile target for cleaning intermediate files"""
self.writeln("CLEAN_TARGETS := $(LIBS) " +
......
......@@ -59,6 +59,7 @@ class MakefileSyn(ToolMakefile):
self._makefile_syn_build()
self._makefile_syn_clean()
self._makefile_syn_phony()
self.makefile_post_includes()
self.makefile_open_write_close()
logging.info(self.TOOL_INFO['name'] + " synthesis makefile generated.")
......
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