def build_global_file_list(self): f_set = SourceFileSet() modules = self.make_list_of_modules() for m in modules: f_set.add(m.files); return f_set
def build_global_file_list(self): f_set = SourceFileSet() modules = self.make_list_of_modules() for m in modules: f_set.add(m.files) return f_set
def build_file_set(self): """Build set of all files listed in the manifests""" from srcfile import SourceFileSet all_manifested_files = SourceFileSet() for module in self: all_manifested_files.add(module.files) return all_manifested_files
def __create_file_list_from_paths(self, paths): sff = SourceFileFactory() srcs = SourceFileSet() for p in paths: if os.path.isdir(p): dir = os.listdir(p) for f_dir in dir: f_dir = os.path.join(self.path, p, f_dir) if not os.path.isdir(f_dir): srcs.add(sff.new(f_dir, self.library, self.vcom_opt, self.vlog_opt, self.include_dirs)) else: srcs.add(sff.new(p, self.library, self.vcom_opt, self.vlog_opt, self.include_dirs)) return srcs
def _create_file_list_from_paths(self, paths): from srcfile import SourceFileFactory, SourceFileSet sff = SourceFileFactory() srcs = SourceFileSet() for p in paths: if os.path.isdir(p): dir_ = os.listdir(p) for f_dir in dir_: f_dir = os.path.join(self.path, p, f_dir) if not os.path.isdir(f_dir): srcs.add(sff.new(path=f_dir, module=self, library=self.library, vcom_opt=self.vcom_opt, vlog_opt=self.vlog_opt, include_dirs=self.include_dirs)) else: srcs.add(sff.new(path=p, module=self, library=self.library, vcom_opt=self.vcom_opt, vlog_opt=self.vlog_opt, include_dirs=self.include_dirs)) return srcs
def __update_existing_ise_project(self, ise): top_mod = self.modules_pool.get_top_module() fileset = self.modules_pool.build_global_file_list() solver = DependencySolver() non_dependable = fileset.inversed_filter(IDependable) dependable = solver.solve(fileset) all_files = SourceFileSet() all_files.add(non_dependable) all_files.add(dependable) prj = ISEProject(ise=ise, top_mod=self.modules_pool.get_top_module()) prj.add_files(all_files) prj.add_libs(all_files.get_libs()) prj.load_xml(top_mod.syn_project) prj.emit_xml(top_mod.syn_project)
def __create_file_list_from_paths(self, paths): sff = SourceFileFactory() srcs = SourceFileSet() for p in paths: if os.path.isdir(p): dir = os.listdir(p) for f_dir in dir: f_dir = os.path.join(self.path, p, f_dir) if not os.path.isdir(f_dir): srcs.add( sff.new(f_dir, self.library, self.vcom_opt, self.vlog_opt, self.include_dirs)) else: srcs.add( sff.new(p, self.library, self.vcom_opt, self.vlog_opt, self.include_dirs)) return srcs
def build_global_file_list(self): from srcfile import SourceFileSet ret = SourceFileSet() for module in self: ret.add(module.files) return ret
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()
def process_manifest(self): from srcfile import TCLFile, VerilogFile, VHDLFile, SourceFileSet if self.isprocessed is True: return if self.manifest_dict is None: logging.debug("There is no manifest to be processed in: %s" % self.url) return logging.debug("Process manifest in: %s" % self.path) if self.manifest_dict["syn_ise_version"] is not None: version = self.manifest_dict["syn_ise_version"] self.syn_ise_version = str(version) if self.manifest_dict["fetchto"] is not None: fetchto = path_mod.rel2abs(self.manifest_dict["fetchto"], self.path) self.fetchto = fetchto else: fetchto = self.fetchto if "local" in self.manifest_dict["modules"]: local_paths = self._flatten_list(self.manifest_dict["modules"]["local"]) local_mods = [] for path in local_paths: if path_mod.is_abs_path(path): logging.error("Found an absolute path (" + path + ") in a manifest" "(" + self.path + ")") quit() path = path_mod.rel2abs(path, self.path) local_mods.append(self.pool.new_module(parent=self, url=path, source=fetch.LOCAL, fetchto=fetchto)) self.local = local_mods else: self.local = [] self.vmap_opt = self.manifest_dict["vmap_opt"] self.vcom_opt = self.manifest_dict["vcom_opt"] self.vsim_opt = self.manifest_dict["vsim_opt"] self.vlog_opt = self.manifest_dict["vlog_opt"] self.iverilog_opt = self.manifest_dict["iverilog_opt"] self.sim_tool = self.manifest_dict["sim_tool"] if self.manifest_dict["force_tool"]: ft = self.manifest_dict["force_tool"] self.force_tool = ft.split(' ') if len(self.force_tool) != 3: logging.warning("Incorrect force_tool format %s. Ignoring" % self.force_tool) self.force_tool = None if "top_module" in self.manifest_dict: self.top_module = self.manifest_dict["top_module"] mkFileList = [] if isinstance(self.manifest_dict["incl_makefiles"], basestring): mkFileList.append(self.manifest_dict["incl_makefiles"]) else: # list mkFileList = self.manifest_dict["incl_makefiles"][:] makefiles_paths = self._make_list_of_paths(mkFileList) self.incl_makefiles.extend(makefiles_paths) #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 = self.manifest_dict["library"] self.include_dirs = [] if self.manifest_dict["include_dirs"] is not None: if isinstance(self.manifest_dict["include_dirs"], basestring): # self.include_dirs.append(self.manifest_dict["include_dirs"]) ll = os.path.relpath(os.path.abspath(os.path.join(self.path, self.manifest_dict["include_dirs"]))) self.include_dirs.append(ll) else: # self.include_dirs.extend(self.manifest_dict["include_dirs"]) ll = map(lambda x: os.path.relpath(os.path.abspath(os.path.join(self.path, x))), self.manifest_dict["include_dirs"]) self.include_dirs.extend(ll) for dir_ in self.include_dirs: if path_mod.is_abs_path(dir_): logging.warning("%s contains absolute path to an include directory: %s" % (self.path, dir_)) if not os.path.exists(dir_): logging.warning(self.path + " has an unexisting include directory: " + dir_) if self.manifest_dict["files"] == []: self.files = SourceFileSet() try: logging.debug("No files in the manifest %s" % self.manifest.path) except AttributeError: pass else: self.manifest_dict["files"] = self._flatten_list(self.manifest_dict["files"]) logging.debug("Files in %s: %s" % (self.path, str(self.manifest_dict["files"]))) paths = self._make_list_of_paths(self.manifest_dict["files"]) 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 len(self.manifest_dict["sim_only_files"]) == 0: self.sim_only_files = SourceFileSet() else: self.manifest_dict["sim_only_files"] = self._flatten_list(self.manifest_dict["sim_only_files"]) paths = self._make_list_of_paths(self.manifest_dict["sim_only_files"]) self.sim_only_files = self._create_file_list_from_paths(paths=paths) self.syn_pre_cmd = self.manifest_dict["syn_pre_cmd"] self.syn_post_cmd = self.manifest_dict["syn_post_cmd"] self.sim_pre_cmd = self.manifest_dict["sim_pre_cmd"] self.sim_post_cmd = self.manifest_dict["sim_post_cmd"] self.bit_file_targets = SourceFileSet() if len(self.manifest_dict["bit_file_targets"]) != 0: paths = self._make_list_of_paths(self.manifest_dict["bit_file_targets"]) self.bit_file_targets = self._create_file_list_from_paths(paths=paths) if "svn" in self.manifest_dict["modules"]: self.manifest_dict["modules"]["svn"] = self._flatten_list(self.manifest_dict["modules"]["svn"]) svn_mods = [] for url in self.manifest_dict["modules"]["svn"]: svn_mods.append(self.pool.new_module(parent=self, url=url, source=fetch.SVN, fetchto=fetchto)) self.svn = svn_mods else: self.svn = [] if "git" in self.manifest_dict["modules"]: self.manifest_dict["modules"]["git"] = self._flatten_list(self.manifest_dict["modules"]["git"]) git_mods = [] for url in self.manifest_dict["modules"]["git"]: git_mods.append(self.pool.new_module(parent=self, url=url, source=fetch.GIT, fetchto=fetchto)) self.git = git_mods else: self.git = [] git_submodule_dict = fetch.Git.get_git_submodules(self) git_toplevel = fetch.Git.get_git_toplevel(self) for submodule_key in git_submodule_dict.keys(): url = git_submodule_dict[submodule_key]["url"] path = git_submodule_dict[submodule_key]["path"] path = os.path.join(git_toplevel, path) fetchto = os.path.sep.join(path.split(os.path.sep)[:-1]) self.git_submodules.append(self.pool.new_module(parent=self, url=url, fetchto=fetchto, source=fetch.GITSUBMODULE)) self.target = self.manifest_dict["target"].lower() self.action = self.manifest_dict["action"].lower() if self.manifest_dict["syn_name"] is None and self.manifest_dict["syn_project"] is not None: self.syn_name = self.manifest_dict["syn_project"][:-5] # cut out .xise from the end else: self.syn_name = self.manifest_dict["syn_name"] self.syn_tool = self.manifest_dict["syn_tool"] self.syn_device = self.manifest_dict["syn_device"] self.syn_grade = self.manifest_dict["syn_grade"] self.syn_package = self.manifest_dict["syn_package"] self.syn_project = self.manifest_dict["syn_project"] self.syn_top = self.manifest_dict["syn_top"] if self.manifest_dict["quartus_preflow"] != None: path = path_mod.rel2abs(self.manifest_dict["quartus_preflow"], self.path); if not os.path.exists(path): p.error("quartus_preflow file listed in " + self.manifest.path + " doesn't exist: " + path + ".\nExiting.") quit() self.quartus_preflow = TCLFile(path) if self.manifest_dict["quartus_postmodule"] != None: path = path_mod.rel2abs(self.manifest_dict["quartus_postmodule"], self.path); if not os.path.exists(path): p.error("quartus_postmodule file listed in " + self.manifest.path + " doesn't exist: " + path + ".\nExiting.") quit() self.quartus_postmodule = TCLFile(path) if self.manifest_dict["quartus_postflow"] != None: path = path_mod.rel2abs(self.manifest_dict["quartus_postflow"], self.path); if not os.path.exists(path): p.error("quartus_postflow file listed in " + self.manifest.path + " doesn't exist: " + path + ".\nExiting.") quit() self.quartus_postflow = TCLFile(path) self.isparsed = True self.isprocessed = True for m in self.submodules(): m.parse_manifest() m.process_manifest() if self == global_mod.top_module: revision = fetch.Svn.check_revision_number(self.path) if revision is None: commit = fetch.Git.check_commit_id(self.path) self.revision = commit else: self.revision = revision else: if self.source == fetch.SVN: self.revision = fetch.Svn.check_revision_number(self.path) elif self.source == fetch.GIT: self.revision = fetch.Git.check_commit_id(self.path)