コード例 #1
0
 def __init__(self, path = None, url = None):
     if not isinstance(path, str):
         raise ValueError("Path must be an instance of str")
     if path == None and url == None:
         raise ValueError("When creating a manifest a path or an URL must be given")
     if path != None and url == None:
         self.url = path
     if path_mod.is_abs_path(path):
         self.path = path
     else:
         raise ValueError("When creating a Manifest, path must be absolute path")
コード例 #2
0
ファイル: manifest_parser.py プロジェクト: lerwys/hdl-make2
 def __init__(self, path=None, url=None):
     if not isinstance(path, str):
         raise ValueError("Path must be an instance of str")
     if path == None and url == None:
         raise ValueError(
             "When creating a manifest a path or an URL must be given")
     if path != None and url == None:
         self.url = path
     if path_mod.is_abs_path(path):
         self.path = path
     else:
         raise ValueError(
             "When creating a Manifest, path must be absolute path")
コード例 #3
0
ファイル: module.py プロジェクト: JamesHyunKim/hdl-make2
    def parse_manifest(self):
        if self.isparsed == True or self.isfetched == False:
            return
        if self.manifest == None:
            self.manifest = self.__search_for_manifest()
        if self.path == None:
            raise RuntimeError()
        manifest_parser = ManifestParser()

		# For non-top modules
        if(self.parent != None):
            manifest_parser.add_arbitrary_code("target=\""+str(global_mod.top_module.target)+"\"")
            manifest_parser.add_arbitrary_code("action=\""+str(global_mod.top_module.action)+"\"")
			# syn_device and sim_tool will be set for non-top modules
            manifest_parser.add_arbitrary_code("syn_device=\""+str(global_mod.top_module.syn_device)+"\"")

        manifest_parser.add_arbitrary_code("__manifest=\""+self.path+"\"")
        manifest_parser.add_arbitrary_code(global_mod.options.arbitrary_code)

        if self.manifest == None:
            p.vprint("No manifest found in module "+str(self))
        else:
            manifest_parser.add_manifest(self.manifest)
            p.vprint("Parsing manifest file: " + str(self.manifest))

        opt_map = None
        try:
            opt_map = manifest_parser.parse()
        except NameError as ne:
            p.echo("Error while parsing {0}:\n{1}: {2}.".format(self.manifest, type(ne), ne))
            quit()

        if(opt_map["fetchto"] != None):
            fetchto = path_mod.rel2abs(opt_map["fetchto"], self.path)
            self.fetchto = fetchto
        else:
            fetchto = self.fetchto

        if self.ise == None:
            self.ise = "13.1"

        if "local" in opt_map["modules"]:
            local_paths = self.__make_list(opt_map["modules"]["local"])
            local_mods = []
            for path in local_paths:
                if path_mod.is_abs_path(path):
                    p.error("Found an absolute path (" + path + ") in a manifest")
                    p.rawprint("(" + self.path + ")")
                    quit()
                path = path_mod.rel2abs(path, self.path)
                local_mods.append(self.pool.new_module(parent=self, url=path, source="local", fetchto=fetchto))
            self.local = local_mods
        else:
            self.local = []

        self.vmap_opt = opt_map["vmap_opt"]
        self.vcom_opt = opt_map["vcom_opt"]
        self.vsim_opt = opt_map["vsim_opt"]
        self.vlog_opt = opt_map["vlog_opt"]

        #if self.vlog_opt == "":
        #    self.vlog_opt = global_mod.top_module.vlog_opt
        #if self.vcom_opt == "":
        #    self.vcom_opt = global_mod.top_module.vcom_opt
        #if self.vsim_opt == "":
        #    self.vsim_opt = global_mod.top_module.vsim_opt
       # if self.vmap_opt == "":
        #    self.vmap_opt = global_mod.top_module.vmap_opt

        self.library = opt_map["library"]
        self.include_dirs = []
        if opt_map["include_dirs"] != None:
            if isinstance(opt_map["include_dirs"], basestring):
                self.include_dirs.append(opt_map["include_dirs"])
            else:
                self.include_dirs.extend(opt_map["include_dirs"])

        for dir in self.include_dirs:
            if path_mod.is_abs_path(dir):
                p.warning(self.path + " contains absolute path to an include directory: " +
                dir)
            if not os.path.exists(dir):
                p.warning(self.path + " has an unexisting include directory: " + dir)

        if opt_map["files"] == []:
            self.files = SourceFileSet()
        else:
            opt_map["files"] = self.__make_list(opt_map["files"])
            paths = []
            for path in opt_map["files"]:
                if not path_mod.is_abs_path(path):
                    path = path_mod.rel2abs(path, self.path)
                    paths.append(path)
                else:
                    p.warning(path + " is an absolute path. Omitting.")
                if not os.path.exists(path):
                    p.error("File listed in " + self.manifest.path + " doesn't exist: "
                    + path +".\nExiting.")
                    quit()

            from srcfile import VerilogFile, VHDLFile
            self.files = self.__create_file_list_from_paths(paths=paths);
            for f in self.files:
                if isinstance(f, VerilogFile):
                    f.vsim_opt = self.vsim_opt
                elif isinstance(f, VHDLFile):
                    f.vcom_opt = self.vcom_opt

        if "svn" in opt_map["modules"]:
            opt_map["modules"]["svn"] = self.__make_list(opt_map["modules"]["svn"])
            svn_mods = []
            for url in opt_map["modules"]["svn"]:
                svn_mods.append(self.pool.new_module(parent=self, url=url, source="svn", fetchto=fetchto))
            self.svn = svn_mods
        else:
            self.svn = []

        if "git" in opt_map["modules"]:
            opt_map["modules"]["git"] = self.__make_list(opt_map["modules"]["git"])
            git_mods = []
            for url in opt_map["modules"]["git"]:
                git_mods.append(self.pool.new_module(parent=self, url=url, source="git", fetchto=fetchto))
            self.git = git_mods
        else:
            self.git = []

        self.target = opt_map["target"]
        self.action = opt_map["action"]

        if opt_map["syn_name"] == None and opt_map["syn_project"] != None:
            self.syn_name = opt_map["syn_project"][:-5] #cut out .xise from the end
        else:
            self.syn_name = opt_map["syn_name"]
        self.syn_device = opt_map["syn_device"];
        self.syn_grade = opt_map["syn_grade"];
        self.syn_package= opt_map["syn_package"];
        self.syn_project = opt_map["syn_project"];
        self.syn_top = opt_map["syn_top"];

        self.isparsed = True

        for m in self.submodules():
            m.parse_manifest()
コード例 #4
0
    def parse_manifest(self):
        if self.isparsed == True or self.isfetched == False:
            return
        if self.manifest == None:
            self.manifest = self.__search_for_manifest()
        if self.path == None:
            raise RuntimeError()
        manifest_parser = ManifestParser()

        # For non-top modules
        if (self.parent != None):
            manifest_parser.add_arbitrary_code(
                "target=\"" + str(global_mod.top_module.target) + "\"")
            manifest_parser.add_arbitrary_code(
                "action=\"" + str(global_mod.top_module.action) + "\"")
            # syn_device and sim_tool will be set for non-top modules
            manifest_parser.add_arbitrary_code(
                "syn_device=\"" + str(global_mod.top_module.syn_device) + "\"")

        manifest_parser.add_arbitrary_code("__manifest=\"" + self.path + "\"")
        manifest_parser.add_arbitrary_code(global_mod.options.arbitrary_code)

        if self.manifest == None:
            p.vprint("No manifest found in module " + str(self))
        else:
            manifest_parser.add_manifest(self.manifest)
            p.vprint("Parsing manifest file: " + str(self.manifest))

        opt_map = None
        try:
            opt_map = manifest_parser.parse()
        except NameError as ne:
            p.echo("Error while parsing {0}:\n{1}: {2}.".format(
                self.manifest, type(ne), ne))
            quit()

        if (opt_map["fetchto"] != None):
            fetchto = path_mod.rel2abs(opt_map["fetchto"], self.path)
            self.fetchto = fetchto
        else:
            fetchto = self.fetchto

        if self.ise == None:
            self.ise = "13.1"

        if "local" in opt_map["modules"]:
            local_paths = self.__make_list(opt_map["modules"]["local"])
            local_mods = []
            for path in local_paths:
                if path_mod.is_abs_path(path):
                    p.error("Found an absolute path (" + path +
                            ") in a manifest")
                    p.rawprint("(" + self.path + ")")
                    quit()
                path = path_mod.rel2abs(path, self.path)
                local_mods.append(
                    self.pool.new_module(parent=self,
                                         url=path,
                                         source="local",
                                         fetchto=fetchto))
            self.local = local_mods
        else:
            self.local = []

        self.vmap_opt = opt_map["vmap_opt"]
        self.vcom_opt = opt_map["vcom_opt"]
        self.vsim_opt = opt_map["vsim_opt"]
        self.vlog_opt = opt_map["vlog_opt"]

        #if self.vlog_opt == "":
        #    self.vlog_opt = global_mod.top_module.vlog_opt
        #if self.vcom_opt == "":
        #    self.vcom_opt = global_mod.top_module.vcom_opt
        #if self.vsim_opt == "":
        #    self.vsim_opt = global_mod.top_module.vsim_opt
        # if self.vmap_opt == "":
        #    self.vmap_opt = global_mod.top_module.vmap_opt

        self.library = opt_map["library"]
        self.include_dirs = []
        if opt_map["include_dirs"] != None:
            if isinstance(opt_map["include_dirs"], basestring):
                self.include_dirs.append(opt_map["include_dirs"])
            else:
                self.include_dirs.extend(opt_map["include_dirs"])

        for dir in self.include_dirs:
            if path_mod.is_abs_path(dir):
                p.warning(self.path +
                          " contains absolute path to an include directory: " +
                          dir)
            if not os.path.exists(dir):
                p.warning(self.path +
                          " has an unexisting include directory: " + dir)

        if opt_map["files"] == []:
            self.files = SourceFileSet()
        else:
            opt_map["files"] = self.__make_list(opt_map["files"])
            paths = []
            for path in opt_map["files"]:
                if not path_mod.is_abs_path(path):
                    path = path_mod.rel2abs(path, self.path)
                    paths.append(path)
                else:
                    p.warning(path + " is an absolute path. Omitting.")
                if not os.path.exists(path):
                    p.error("File listed in " + self.manifest.path +
                            " doesn't exist: " + path + ".\nExiting.")
                    quit()

            from srcfile import VerilogFile, VHDLFile
            self.files = self.__create_file_list_from_paths(paths=paths)
            for f in self.files:
                if isinstance(f, VerilogFile):
                    f.vsim_opt = self.vsim_opt
                elif isinstance(f, VHDLFile):
                    f.vcom_opt = self.vcom_opt

        if "svn" in opt_map["modules"]:
            opt_map["modules"]["svn"] = self.__make_list(
                opt_map["modules"]["svn"])
            svn_mods = []
            for url in opt_map["modules"]["svn"]:
                svn_mods.append(
                    self.pool.new_module(parent=self,
                                         url=url,
                                         source="svn",
                                         fetchto=fetchto))
            self.svn = svn_mods
        else:
            self.svn = []

        if "git" in opt_map["modules"]:
            opt_map["modules"]["git"] = self.__make_list(
                opt_map["modules"]["git"])
            git_mods = []
            for url in opt_map["modules"]["git"]:
                git_mods.append(
                    self.pool.new_module(parent=self,
                                         url=url,
                                         source="git",
                                         fetchto=fetchto))
            self.git = git_mods
        else:
            self.git = []

        self.target = opt_map["target"]
        self.action = opt_map["action"]

        if opt_map["syn_name"] == None and opt_map["syn_project"] != None:
            self.syn_name = opt_map[
                "syn_project"][:-5]  #cut out .xise from the end
        else:
            self.syn_name = opt_map["syn_name"]
        self.syn_device = opt_map["syn_device"]
        self.syn_grade = opt_map["syn_grade"]
        self.syn_package = opt_map["syn_package"]
        self.syn_project = opt_map["syn_project"]
        self.syn_top = opt_map["syn_top"]

        self.isparsed = True

        for m in self.submodules():
            m.parse_manifest()