Preliminary work on Feature 1326

parent 30143252
...@@ -163,7 +163,10 @@ def main(): ...@@ -163,7 +163,10 @@ def main():
logging.error("`sim_tool' manifest variable has to be specified. " logging.error("`sim_tool' manifest variable has to be specified. "
"Otherwise hdlmake doesn't know how to simulate the project.") "Otherwise hdlmake doesn't know how to simulate the project.")
quit() quit()
action = [ GenerateSimulationMakefile ] action = [
GenerateSimulationMakefile,
GenerateFetchMakefile
]
elif top_mod.action == "synthesis": elif top_mod.action == "synthesis":
if not top_mod.syn_tool: if not top_mod.syn_tool:
logging.error("`syn_tool' manifest variable has to be specified. " logging.error("`syn_tool' manifest variable has to be specified. "
...@@ -171,6 +174,7 @@ def main(): ...@@ -171,6 +174,7 @@ def main():
quit() quit()
action = [ action = [
GenerateSynthesisProject, GenerateSynthesisProject,
#GenerateFetchMakefile,
GenerateSynthesisMakefile, GenerateSynthesisMakefile,
GenerateRemoteSynthesisMakefile GenerateRemoteSynthesisMakefile
] ]
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
import logging import logging
import sys import sys
import os
from .action import Action from .action import Action
...@@ -33,7 +34,10 @@ class FetchModules(Action): ...@@ -33,7 +34,10 @@ class FetchModules(Action):
sys.exit("\nExiting") sys.exit("\nExiting")
def run(self): def run(self):
top_module = self.modules_pool.get_top_module()
logging.info("Fetching needed modules.") logging.info("Fetching needed modules.")
os.system(top_module.fetch_pre_cmd)
self.modules_pool.fetch_all(unfetched_only=not self.options.update, flatten=self.options.flatten) self.modules_pool.fetch_all(unfetched_only=not self.options.update, flatten=self.options.flatten)
logging.debug(str(self.modules_pool)) logging.debug(str(self.modules_pool))
logging.info("All modules fetched.") os.system(top_module.fetch_post_cmd)
\ No newline at end of file logging.info("All modules fetched.")
...@@ -26,6 +26,17 @@ from hdlmake.makefile_writer import MakefileWriter ...@@ -26,6 +26,17 @@ from hdlmake.makefile_writer import MakefileWriter
from .action import Action from .action import Action
class GenerateFetchMakefile(Action): class GenerateFetchMakefile(Action):
def _check_manifest(self):
if not self.top_module.action == "synthesis":
logging.error("action must be equal to \"synthesis\"")
sys.exit("Exiting")
if not self.top_module.syn_project:
logging.error("syn_project must be set in the manifest.")
sys.exit("Exiting")
def run(self): def run(self):
pool = self.modules_pool pool = self.modules_pool
logging.info("Generating makefile for fetching modules.") logging.info("Generating makefile for fetching modules.")
...@@ -35,6 +46,8 @@ class GenerateFetchMakefile(Action): ...@@ -35,6 +46,8 @@ class GenerateFetchMakefile(Action):
quit() quit()
self._check_all_fetched_or_quit() self._check_all_fetched_or_quit()
self._check_manifest()
makefile_writer = MakefileWriter() makefile_writer = MakefileWriter()
makefile_writer.generate_fetch_makefile(pool) makefile_writer.generate_fetch_makefile(pool)
del makefile_writer
logging.info("Makefile for fetching modules generated.") logging.info("Makefile for fetching modules generated.")
...@@ -81,10 +81,16 @@ class MakefileWriter(object): ...@@ -81,10 +81,16 @@ class MakefileWriter(object):
def generate_fetch_makefile(self, modules_pool): def generate_fetch_makefile(self, modules_pool):
rp = os.path.relpath rp = os.path.relpath
top_module = modules_pool.get_top_module()
self.write("#target for fetching all modules stored in repositories\n") self.write("#target for fetching all modules stored in repositories\n")
self.write("fetch: ") self.write("fetch: __fetch_pre_cmd __run_fetch __fetch_post_cmd\n\n")
self.write("__run_fetch:\\\n")
self.write(' \\\n'.join(["__"+m.basename+"_fetch" for m in modules_pool if m.source in (fetch.SVN, fetch.GIT)])) self.write(' \\\n'.join(["__"+m.basename+"_fetch" for m in modules_pool if m.source in (fetch.SVN, fetch.GIT)]))
self.write("\n\n") self.write("\n\n")
self.write("__fetch_pre_cmd:\n")
self.write("\t\t%s\n\n" % top_module.fetch_pre_cmd)
self.write("__fetch_post_cmd:\n")
self.write("\t\t%s\n\n" % top_module.fetch_post_cmd)
for module in modules_pool: for module in modules_pool:
basename = module.basename basename = module.basename
......
...@@ -50,7 +50,8 @@ class ManifestParser(ConfigParser): ...@@ -50,7 +50,8 @@ class ManifestParser(ConfigParser):
def __init__(self): def __init__(self):
ConfigParser.__init__(self, description="Configuration options description") ConfigParser.__init__(self, description="Configuration options description")
self.add_option('fetchto', default=None, help="Destination for fetched modules", type='') self.add_option('fetchto', default=None, help="Destination for fetched modules", type='')
#self.add_option('root_module', default=None, help="Path to root module for currently parsed", type='') self.add_option('fetch_pre_cmd', default='', help="Command to be executed before fetch", type='')
self.add_option('fetch_post_cmd', default='', help="Command to be executed after fetch", type='')
self.add_delimiter() self.add_delimiter()
self.add_option('syn_name', default=None, help="Name of the folder at remote synthesis machine", type='') self.add_option('syn_name', default=None, help="Name of the folder at remote synthesis machine", type='')
......
...@@ -238,11 +238,14 @@ class Module(object): ...@@ -238,11 +238,14 @@ class Module(object):
if self.manifest_dict["syn_ise_version"] is not None: if self.manifest_dict["syn_ise_version"] is not None:
version = self.manifest_dict["syn_ise_version"] version = self.manifest_dict["syn_ise_version"]
self.syn_ise_version = str(version) self.syn_ise_version = str(version)
if self.manifest_dict["fetchto"] is not None: if self.manifest_dict["fetchto"] is not None:
fetchto = path_mod.rel2abs(self.manifest_dict["fetchto"], self.path) fetchto = path_mod.rel2abs(self.manifest_dict["fetchto"], self.path)
self.fetchto = fetchto self.fetchto = fetchto
else: else:
fetchto = self.fetchto fetchto = self.fetchto
self.fetch_pre_cmd = self.manifest_dict["fetch_pre_cmd"]
self.fetch_post_cmd = self.manifest_dict["fetch_post_cmd"]
if "local" in self.manifest_dict["modules"]: if "local" in self.manifest_dict["modules"]:
local_paths = self._flatten_list(self.manifest_dict["modules"]["local"]) local_paths = self._flatten_list(self.manifest_dict["modules"]["local"])
......
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