diff --git a/tools/oneclick/base/hdl_config.py b/tools/oneclick/base/hdl_config.py index 5f713cff48fcf76bc7a9649c6277c392a5a45c90..49c5c6caf6954918551f26dc4cfcaeafdaef8132 100644 --- a/tools/oneclick/base/hdl_config.py +++ b/tools/oneclick/base/hdl_config.py @@ -67,41 +67,46 @@ class HdlConfig: self.libs = common_dict_file.CommonDictFile(libRootDir, libFileName) # library dict files if self.libs.nof_dicts==0: sys.exit('Error : No HDL library config file found') self.lib_names = self.libs.get_key_values('hdl_lib_name') - self.MODELSIM_MPF_NAME = 'hdllib.mpf' def derive_all_use_libs(self, lib_name): """Derive a list of all HDL libraries that the specified HDL lib_name library depends on.""" if lib_name in self.lib_names: all_use_libs = [lib_name] lib_dict = self.libs.dicts[self.lib_names.index(lib_name)] + # use recursion to include all used libs if 'hdl_lib_uses' in lib_dict: use_libs = lib_dict['hdl_lib_uses'].split() for use_lib in use_libs: all_use_libs.append(use_lib) all_use_libs += self.derive_all_use_libs(use_lib) + # remove all duplicates from the list return cm.unique(all_use_libs) else: sys.exit('Error : Unknown HDL library name') def derive_lib_order(self, lib_names=None): - """Derive the dependency order for all HDL libraries in the specified list of lib_names.""" + """Derive the dependency order for all HDL libraries in the fully specified list of lib_names. + + Note: + The lib_names list must include all used libs, so if necessary first call derive_all_use_libs(). + """ if lib_names==None: lib_names=self.lib_names lib_dicts = self.libs.get_dicts('hdl_lib_name', lib_names) - lib_order = [] + # use list() to take local copy to avoid modifying list order of self.lib_names which matches self.libs.dicts list order + lib_order = list(lib_names) for lib_dict in cm.listify(lib_dicts): lib_name = lib_dict['hdl_lib_name'] - if not lib_name in lib_order: - lib_order.append(lib_name) # append this lib if 'hdl_lib_uses' in lib_dict: use_libs = lib_dict['hdl_lib_uses'].split() for use_lib in use_libs: - if not use_lib in lib_order: - lib_order.insert(lib_order.index(lib_name), use_lib) # insert used lib just before this lib - else: - if lib_order.index(use_lib) > lib_order.index(lib_name): - lib_order.remove(use_lib) - lib_order.insert(lib_order.index(lib_name), use_lib) # move used lib to just before this lib + if lib_order.index(use_lib) > lib_order.index(lib_name): + lib_order.remove(use_lib) + lib_order.insert(lib_order.index(lib_name), use_lib) # move used lib to just before this lib + # use recursion to keep on reordering the lib_order until it is stable + if lib_names != lib_order: + lib_order = self.derive_lib_order(lib_order) return lib_order + def get_lib_build_dirs(self, build_type, build_subdir=None, lib_dicts=None): """Get the tool build directory for all HDL libraries in the specified list of lib_dicts. @@ -194,10 +199,14 @@ if __name__ == '__main__': print '' if libRootDir=='RADIOHDL': - print 'derive_all_use_libs = ', hdl.derive_lib_order(hdl.derive_all_use_libs('technology_memory')) + #print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('tech_memory')) + #print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('numonyx_m25p128')) + #print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('ip_stratixiv')) + #print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('tech_flash')) + print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('epcs')) if libRootDir=='UNB': - print 'derive_all_use_libs = ', hdl.derive_lib_order(hdl.derive_all_use_libs('dp')) - print 'derive_all_use_libs = ', hdl.derive_lib_order(hdl.derive_all_use_libs('uth')) - print 'derive_all_use_libs = ', hdl.derive_lib_order(hdl.derive_all_use_libs('unb_common')) - print 'derive_all_use_libs = ', hdl.derive_lib_order(hdl.derive_all_use_libs('unb_minimal')) + print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('dp')) + print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('uth')) + print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('unb_common')) + print 'derive_lib_order = ', hdl.derive_lib_order(hdl.derive_all_use_libs('unb_minimal'))