A little bit of refactoring focused on module core

parent f1d7e053
"""Provides the core functionality for the HDLMake module"""
import os
import logging
......@@ -6,6 +8,7 @@ from hdlmake.util import path as path_mod
from hdlmake import fetch
class ModuleCore(ModulePlugin):
"""This is the class providing the module core functionality"""
def __init__(self):
# Universal Manifest Properties
self.library = "work"
......@@ -16,23 +19,54 @@ class ModuleCore(ModulePlugin):
# Manifest Force tool Property
self.force_tool = None
# Origin attributes
self.isfetched = False
# raw_url is the full url, including: branch, revision, commit, tag
self.raw_url = None
# url is stripped down web url, not including any other parameter
self.url = None
self.parent = None
self.source = None
self.branch = None
self.path = None
self.fetchto = None
self.revision = None
def __str__(self):
return self.raw_url
@property
def basename(self):
"""Get the basename for a module instance"""
if self.source == fetch.SVN:
return path_mod.svn_basename(self.url)
else:
return path_mod.url_basename(self.url)
def process_manifest(self):
"""Method that process the core manifest section"""
self._process_manifest_force_tool()
self._process_manifest_universal()
super(ModuleCore, self).process_manifest()
def _process_manifest_force_tool(self):
"""Method processing the force_tool manifest directive"""
if self.manifest_dict["force_tool"]:
ft = self.manifest_dict["force_tool"]
self.force_tool = ft.split(' ')
force_tool = self.manifest_dict["force_tool"]
self.force_tool = force_tool.split(' ')
if len(self.force_tool) != 3:
logging.warning("Incorrect force_tool format %s. Ignoring" % self.force_tool)
logging.warning("Incorrect force_tool format %s. Ignoring",
self.force_tool)
self.force_tool = None
def _process_manifest_universal(self):
if "top_module" in self.manifest_dict:
self.top_module = self.manifest_dict["top_module"]
"""Method processing the universal manifest directives"""
#if "top_module" in self.manifest_dict:
# self.top_module = self.manifest_dict["top_module"]
# Libraries
self.library = self.manifest_dict["library"]
self.target = self.manifest_dict["target"].lower()
......
......@@ -34,7 +34,6 @@ import logging
from hdlmake.manifest_parser import Manifest, ManifestParser
from hdlmake.util import path as path_mod
from hdlmake import fetch
from hdlmake.module import (ModuleCore, ModuleSynthesis,
ModuleSimulation, ModuleContent, ModuleAltera)
......@@ -46,14 +45,6 @@ class Module(ModuleCore, ModuleSynthesis,
providing the modular behavior allowing for structured designs.
"""
@property
def basename(self):
"""Get the basename for a module instance"""
if self.source == fetch.SVN:
return path_mod.svn_basename(self.url)
else:
return path_mod.url_basename(self.url)
def set_pool(self, pool):
"""Set the associated pool for the module instance"""
self.pool = pool
......@@ -66,9 +57,6 @@ class Module(ModuleCore, ModuleSynthesis,
super(Module, self).__init__()
self.manifest = None
self.manifest_dict = None
self.pool = None
self.top_module = None
......@@ -78,10 +66,6 @@ class Module(ModuleCore, ModuleSynthesis,
self._set_origin(parent, url, source, fetchto)
def __str__(self):
return self.raw_url
@property
def is_fetched_to(self):
"""Get the path where the module instance resides"""
......
class ModulePlugin(object):
def __init__(self):
self.manifest = None
self.manifest_dict = None
def process_manifest(self):
pass
......
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