Commit ffc94a46 authored by Tristan Gingold's avatar Tristan Gingold

tool: factorize code.

parent fe2c8a33
...@@ -73,17 +73,9 @@ class ToolMakefile(object): ...@@ -73,17 +73,9 @@ class ToolMakefile(object):
if filename: if filename:
self._filename = filename self._filename = filename
def _get_name_bin(self):
"""Get the name and binary values"""
if shell.check_windows_tools():
bin_name = self.TOOL_INFO['windows_bin']
else:
bin_name = self.TOOL_INFO['linux_bin']
return bin_name
def _get_path(self): def _get_path(self):
"""Get the directory in which the tool binary is at Host""" """Get the directory in which the tool binary is at Host"""
bin_name = self._get_name_bin() bin_name = self.get_tool_bin()
locations = shell.which(bin_name) locations = shell.which(bin_name)
if len(locations) == 0: if len(locations) == 0:
return None return None
...@@ -93,13 +85,19 @@ class ToolMakefile(object): ...@@ -93,13 +85,19 @@ class ToolMakefile(object):
def _is_in_path(self, path_key): def _is_in_path(self, path_key):
"""Check if the directory is in the system path""" """Check if the directory is in the system path"""
path = self.manifest_dict.get(path_key) path = self.manifest_dict.get(path_key)
bin_name = self._get_name_bin() bin_name = self.get_tool_bin()
return os.path.exists(os.path.join(path, bin_name)) return os.path.exists(os.path.join(path, bin_name))
def _check_in_system_path(self): def _check_in_system_path(self):
"""Check if if in the system path exists a file named (name)""" """Check if if in the system path exists a file named (name)"""
return self._get_path() is not None return self._get_path() is not None
def get_tool_bin(self):
if shell.check_windows_tools():
return self.TOOL_INFO["windows_bin"]
else:
return self.TOOL_INFO["linux_bin"]
def makefile_check_tool(self, path_key): def makefile_check_tool(self, path_key):
"""Check if the binary is available in the O.S. environment""" """Check if the binary is available in the O.S. environment"""
name = self.TOOL_INFO['name'] name = self.TOOL_INFO['name']
......
...@@ -48,10 +48,6 @@ class MakefileSyn(ToolMakefile): ...@@ -48,10 +48,6 @@ class MakefileSyn(ToolMakefile):
def _makefile_syn_top(self): def _makefile_syn_top(self):
"""Create the top part of the synthesis Makefile""" """Create the top part of the synthesis Makefile"""
if shell.check_windows_tools():
tcl_interpreter = self.TOOL_INFO["windows_bin"]
else:
tcl_interpreter = self.TOOL_INFO["linux_bin"]
top_parameter = """\ top_parameter = """\
TOP_MODULE := {top_module} TOP_MODULE := {top_module}
PROJECT := {project_name} PROJECT := {project_name}
...@@ -68,7 +64,7 @@ SYN_PACKAGE := {syn_package} ...@@ -68,7 +64,7 @@ SYN_PACKAGE := {syn_package}
SYN_GRADE := {syn_grade} SYN_GRADE := {syn_grade}
""" """
self.writeln(top_parameter.format( self.writeln(top_parameter.format(
tcl_interpreter=tcl_interpreter, tcl_interpreter=self.get_tool_bin(),
project_name=os.path.splitext( project_name=os.path.splitext(
self.manifest_dict["syn_project"])[0], self.manifest_dict["syn_project"])[0],
project_ext=self.TOOL_INFO["project_ext"], project_ext=self.TOOL_INFO["project_ext"],
......
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