Start refactoring Action module

parent 961a52fa
......@@ -21,7 +21,7 @@
import sys
import logging
import importlib
class Action(object):
def __init__(self, modules_pool):
......@@ -29,6 +29,12 @@ class Action(object):
self.options = modules_pool.env.options
self.env = modules_pool.env
if modules_pool.get_top_module().manifest_dict["action"] is "synthesis":
tool_name = modules_pool.get_top_module().manifest_dict["syn_tool"]
elif modules_pool.get_top_module().manifest_dict["action"] is "simulation":
tool_name = modules_pool.get_top_module().manifest_dict["sim_tool"]
tool_module = self._load_tool(tool_name)
self.tool = tool_module.ToolControls()
self._check_manifest()
self._check_env()
self._check_options()
......@@ -49,6 +55,15 @@ class Action(object):
def run(self):
raise NotImplementedError()
def _load_tool(self, tool_name):
try:
tool_module = importlib.import_module("hdlmake.tools.%s.%s" % (tool_name, tool_name))
except Exception as e:
logging.error(e)
quit()
return tool_module
def _check_all_fetched_or_quit(self):
pool = self.modules_pool
if not pool.is_everything_fetched():
......
......@@ -23,7 +23,6 @@
import logging
import os
import sys
import importlib
from hdlmake.srcfile import SourceFileFactory
......@@ -45,18 +44,11 @@ class GenerateRemoteSynthesisMakefile(Action):
def run(self):
self._check_all_fetched_or_quit()
self._check_manifest()
tool_name = self.modules_pool.get_top_module().manifest_dict["syn_tool"]
try:
tool_module = importlib.import_module("hdlmake.tools.%s.%s" % (tool_name, tool_name))
except Exception as e:
logging.error(e)
quit()
tool_object = tool_module.ToolControls()
self._generate_remote_synthesis_makefile(tool_object)
self._generate_remote_synthesis_makefile()
def _generate_remote_synthesis_makefile(self, tool_object):
def _generate_remote_synthesis_makefile(self):
tool_object = self.tool
logging.info("Generating makefile for remote synthesis.")
top_mod = self.modules_pool.get_top_module()
......
......@@ -23,7 +23,6 @@
from __future__ import print_function
import logging
import sys
import importlib
from hdlmake.dep_file import DepFile
import hdlmake.new_dep_solver as dep_solver
......@@ -44,18 +43,11 @@ class GenerateSimulationMakefile(Action):
def run(self):
self._check_all_fetched_or_quit()
self._check_manifest()
tool_name = self.modules_pool.get_top_module().manifest_dict["sim_tool"]
try:
tool_module = importlib.import_module("hdlmake.tools.%s.%s" % (tool_name, tool_name))
except Exception as e:
logging.error(e)
quit()
tool_object = tool_module.ToolControls()
self._generate_simulation_makefile(tool_object)
self._generate_simulation_makefile()
def _generate_simulation_makefile(self, tool_object):
def _generate_simulation_makefile(self):
tool_object = self.tool
tool_info = tool_object.get_keys()
if sys.platform == 'cygwin':
bin_name = tool_info['windows_bin']
......
......@@ -42,18 +42,12 @@ class GenerateSynthesisMakefile(Action):
def run(self):
self._check_all_fetched_or_quit()
self._check_manifest()
tool_name = self.modules_pool.get_top_module().manifest_dict["syn_tool"]
try:
tool_module = importlib.import_module("hdlmake.tools.%s.%s" % (tool_name, tool_name))
except Exception as e:
logging.error(e)
quit()
tool_object = tool_module.ToolControls()
self._generate_synthesis_makefile(tool_object)
self._generate_synthesis_makefile()
def _generate_synthesis_makefile(self, tool_object):
def _generate_synthesis_makefile(self):
tool_object = self.tool
tool_info = tool_object.get_keys()
if sys.platform == 'cygwin':
bin_name = tool_info['windows_bin']
......
......@@ -24,7 +24,6 @@ from __future__ import print_function
import logging
import sys
import os
import importlib
from hdlmake.srcfile import SourceFileFactory
from hdlmake.util import path
......@@ -54,14 +53,7 @@ class GenerateSynthesisProject(Action):
def run(self):
self._check_all_fetched_or_quit()
self._check_manifest()
tool_name = self.modules_pool.get_top_module().manifest_dict["syn_tool"]
try:
tool_module = importlib.import_module("hdlmake.tools.%s.%s" % (tool_name, tool_name))
except Exception as e:
logging.error(e)
quit()
tool_object = tool_module.ToolControls()
self._generate_synthesis_project(tool_object)
self._generate_synthesis_project()
def _write_project_vhd(self, tool, version):
......@@ -134,8 +126,8 @@ end sdb_meta_pkg;""")
def _generate_synthesis_project(self, tool_object):
def _generate_synthesis_project(self):
tool_object = self.tool
tool_info = tool_object.get_keys()
if sys.platform == 'cygwin':
bin_name = tool_info['windows_bin']
......
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