From cb28104f4a91e06c721f47d9609ad5b1095ce64a Mon Sep 17 00:00:00 2001 From: Erik Kooistra <kooistra@astron.nl> Date: Wed, 10 Jun 2015 07:21:40 +0000 Subject: [PATCH] Added get_lib_dicts_from_lib_names(). --- tools/oneclick/base/hdl_config.py | 39 +++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/tools/oneclick/base/hdl_config.py b/tools/oneclick/base/hdl_config.py index e88cef3131..044516c464 100644 --- a/tools/oneclick/base/hdl_config.py +++ b/tools/oneclick/base/hdl_config.py @@ -53,6 +53,7 @@ import sys import os import os.path import shutil +import argparse class HdlConfig: @@ -166,7 +167,7 @@ class HdlConfig: . 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_dicts = self.libs.get_dicts('hdl_lib_name', values=lib_names) # 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): @@ -186,6 +187,20 @@ class HdlConfig: return lib_order + def get_lib_dicts_from_lib_names(self, lib_names=None): + """Get list the HDL libraries lib_dicts from list of HDL libraries lib_names and preseve the library order. + """ + if lib_names==None: lib_names=self.lib_names + # Cannot use: + #lib_dicts = self.libs.get_dicts('hdl_lib_name', values=lib_names) + # because then the order of self.libs.dicts is used + lib_dicts = [] + for lib_name in cm.listify(lib_names): + lib_dict = self.libs.dicts[self.lib_names.index(lib_name)] + lib_dicts.append(lib_dict) + return lib_dicts + + def get_tool_build_dir(self, build_type): """Get the central tool build directory. @@ -239,7 +254,7 @@ class HdlConfig: The file is read by commands.do in Modelsim to avoid having to derive the library compile order in TCL. """ if lib_names==None: lib_names=self.lib_names - lib_dicts = self.libs.get_dicts('hdl_lib_name', lib_names) + lib_dicts = self.libs.get_dicts('hdl_lib_name', values=lib_names) for lib_dict in cm.listify(lib_dicts): lib_name = lib_dict['hdl_lib_name'] use_libs = self.derive_all_use_libs(build_type, lib_name) @@ -321,9 +336,25 @@ if __name__ == '__main__': mode = 0 if mode==0: + # Parse command line arguments + toolsetSelect = ['unb1', 'unb2'] + + argparser = argparse.ArgumentParser(description='Create Modelsim mpf files for all hdllib.cfg') + argparser.add_argument('-t','--toolset', help='choose toolset %s (default: %s)' % (toolsetSelect,toolsetSelect[0]), default=toolsetSelect[0], required=False) + argparser.add_argument('-v','--verbosity', help='verbosity >= 0 for more info', type=int, default=0, required=False) + args = vars(argparser.parse_args()) + + arg_toolset = args['toolset'] + if arg_toolset not in toolsetSelect: + print 'Toolset %s is not supported' % arg_toolset + print 'Hint: give argument -h for possible options' + sys.exit(1) + toolFileName = 'hdltool_' + arg_toolset + '.cfg' + + arg_verbosity = args['verbosity'] + # Read the dictionary info from all HDL tool and library configuration files in the current directory and the sub directories - hdl = HdlConfig(toolRootDir=os.path.expandvars('$RADIOHDL/tools'), libFileName='hdllib.cfg', toolFileName='hdltool_<toolset>.cfg') - + hdl = HdlConfig(toolRootDir=os.path.expandvars('$RADIOHDL/tools'), libFileName='hdllib.cfg', toolFileName=toolFileName) print '#' print '# HdlConfig:' print '#' -- GitLab