def main(): parser = ArgsAndFileParser(usage) args = parser.parse_args(2) project_name = args[0] hdl_files = args[1:] destination = os.getcwd() # Find common directory of the hdl files abs_paths = [os.path.abspath(x) for x in hdl_files] folder = os.path.commonprefix(abs_paths) sigasi_project_file_creator = SigasiProjectCreator( project_name, VhdlVersion.NINETY_THREE) # Create Project File and add a link the common source folder folder_name = os.path.basename(os.path.normpath(folder)) sigasi_project_file_creator.add_link(folder_name, folder, True) # Create Library Mapping File # Unmap everything except the list of files (map those to work) sigasi_project_file_creator.unmap("/") for path in abs_paths: relative_file_path = os.path.relpath(path, folder) sigasi_project_file_creator.add_mapping( folder_name + "/" + relative_file_path, "work") sigasi_project_file_creator.write(destination)
def main(): usage = """usage: %prog project-name csv-file [destination] destination is the current directory by default example: %prog test-proj filelist.csv """ parser = OptionParser(usage=usage) (options, args) = parser.parse_args() if len(args) < 2: parser.error("incorrect number of arguments") project_name = args[0] csv_file = args[1] destination = os.getcwd() if len(args) > 2: destination = args[2] if not os.path.isdir(destination): parser.error("destination has to be a folder") entries = parse_csv_file(csv_file) creator = SigasiProjectCreator(project_name, 93) for path, library in entries.iteritems(): file_name = get_file_name(path) link_type = 2 if os.path.isdir(path) else 1 creator.add_link(file_name, os.path.abspath(path), link_type) creator.add_mapping(file_name, library) creator.write(destination)
def main(): usage = """usage: %prog project-name csv-file [destination] destination is the current directory by default example: %prog test-proj filelist.csv """ parser = OptionParser(usage=usage) (options, args) = parser.parse_args() if len (args) < 2: parser.error("incorrect number of arguments") project_name = args[0] csv_file = args[1] destination = os.getcwd() if len (args) > 2: destination = args[2] if not os.path.isdir(destination): parser.error("destination has to be a folder") entries = parse_csv_file(csv_file) creator = SigasiProjectCreator(project_name, 93) for path, library in entries.iteritems(): file_name=get_file_name(path) link_type=2 if os.path.isdir(path) else 1 creator.add_link(file_name, os.path.abspath(path), link_type) creator.add_mapping(file_name, library) creator.write(destination)
def main(): parser = ArgsAndFileParser(CsvParser.usage) (project_name, _, destination, entries) = parser.parse_args_and_file(CsvParser.parse_file) creator = SigasiProjectCreator(project_name, VhdlVersion.NINETY_THREE) for path, library in entries.iteritems(): file_name = get_file_name(path) link_type = os.path.isdir(path) creator.add_link(file_name, os.path.abspath(path), link_type) creator.add_mapping(file_name, library) creator.write(destination)
def main(): usage = """usage: %prog project-name vhdl-file vhdl-file... this scripts creates a sigasi project in the current working directory: * adds one linked folder to the project that points to the common folder of all listed vhdl-files * unmaps all vhdl-files in the common folder, except the listed files. These files are mapped to the 'work' library """ parser = OptionParser(usage=usage) (options, args) = parser.parse_args() if len(args) < 2: parser.error("incorrect number of arguments") project_name = args[0] vhdl_files = args[1:] destination = os.getcwd() #find common directory of the vhdl files abs_paths = map(lambda x: os.path.abspath(x), vhdl_files) folder = os.path.commonprefix(abs_paths) sigasProjectFileCreator = SigasiProjectCreator(project_name, 93) #Create Project File and add a link the common source folder folderName = os.path.basename(os.path.normpath(folder)) sigasProjectFileCreator.add_link(folderName, folder, 2) #Create Library Mapping File # unmap everything except the list of files (map those to work) sigasProjectFileCreator.unmap("/") for path in abs_paths: relativeFilePath = os.path.relpath(path, folder) sigasProjectFileCreator.add_mapping( folderName + "/" + relativeFilePath, "work") sigasProjectFileCreator.write(destination)
def main(): parser = ArgsAndFileParser(usage) args = parser.parse_args(2) project_name = args[0] hdl_files = args[1:] destination = os.getcwd() # Find common directory of the hdl files abs_paths = [os.path.abspath(x) for x in hdl_files] folder = os.path.dirname(os.path.commonprefix([p + os.path.sep for p in abs_paths])) sigasi_project_file_creator = SigasiProjectCreator(project_name, VhdlVersion.NINETY_THREE) # Create Project File and add a link the common source folder folder_name = os.path.basename(os.path.normpath(folder)) sigasi_project_file_creator.add_link(folder_name, folder, True) # Create Library Mapping File # Unmap everything except the list of files (map those to work) sigasi_project_file_creator.unmap("/") for path in abs_paths: relative_file_path = os.path.relpath(path, folder) sigasi_project_file_creator.add_mapping(folder_name + "/" + relative_file_path, "work") sigasi_project_file_creator.write(destination)
def main(): usage = """usage: %prog project-name vhdl-file vhdl-file... this scripts creates a sigasi project in the current working directory: * adds one linked folder to the project that points to the common folder of all listed vhdl-files * unmaps all vhdl-files in the common folder, except the listed files. These files are mapped to the 'work' library """ parser = OptionParser(usage=usage) (options, args) = parser.parse_args() if len (args) < 2: parser.error("incorrect number of arguments") project_name = args[0] vhdl_files = args[1:] destination = os.getcwd() #find common directory of the vhdl files abs_paths = map(lambda x: os.path.abspath(x), vhdl_files) folder = os.path.commonprefix(abs_paths) sigasProjectFileCreator = SigasiProjectCreator(project_name, 93) #Create Project File and add a link the common source folder folderName = os.path.basename(os.path.normpath(folder)) sigasProjectFileCreator.add_link(folderName, folder, 2) #Create Library Mapping File # unmap everything except the list of files (map those to work) sigasProjectFileCreator.unmap("/") for path in abs_paths: relativeFilePath = os.path.relpath(path, folder) sigasProjectFileCreator.add_mapping(folderName + "/" + relativeFilePath, "work") sigasProjectFileCreator.write(destination)
def parse_and_create_project(usage, parse_file): parser = ArgsAndFileParser(usage) (project_name, _, destination, entries) = parser.parse_args_and_file(parse_file) print entries sigasi_project_file_creator = SigasiProjectCreator(project_name) sigasi_project_file_creator.unmap("/") linked_folders = dict() for path, library in entries.iteritems(): abs_destination = os.path.abspath(destination) abs_path = os.path.abspath(path) relative_path = os.path.relpath(abs_path, abs_destination) if not relative_path.startswith(".."): sigasi_project_file_creator.add_mapping(relative_path, library) else: common_prefix = os.path.dirname( os.path.commonprefix( [p + os.path.sep for p in [abs_path, abs_destination]])) eclipse_path = os.path.relpath(abs_path, common_prefix) directory_name = get_parts(eclipse_path)[-1] target = os.path.join(common_prefix, directory_name) linked_folders[directory_name] = target sigasi_project_file_creator.add_mapping(eclipse_path, library) # Adding custom items to libraries. # sigasi_project_file_creator.add_unisim("C:/xilinx/14.5/ISE_DS/ISE/vhdl/src/unisims") # sigasi_project_file_creator.add_unimacro("C:/xilinx/14.5/ISE_DS/ISE/vhdl/src/unimacro") for folder, location in linked_folders.iteritems(): if running_in_cyg_win(): location = convert_cygwin_path(location) sigasi_project_file_creator.add_link(folder, location, True) sigasi_project_file_creator.write(destination)
def test_check_hdl_versions_both_wrong(self): with self.assertRaises(ValueError) as exc: sPC.check_hdl_versions(VerilogVersion.TWENTY_O_FIVE, VhdlVersion.NINETY_THREE) self.assertTrue( '''Only 93, 2002, 2008 is/are allowed as VHDL version number. Only v2005 is/are allowed as Verilog version number.''' in exc.exception)
def test_check_hdl_versions_verilog_wrong(self): with self.assertRaises(ValueError) as exc: sPC.check_hdl_versions(VhdlVersion.NINETY_THREE, VhdlVersion.NINETY_THREE) self.assertTrue("Only v2005 is/are allowed as Verilog version number." in exc.exception)
def test_check_hdl_versions_vhdl_wrong(self): with self.assertRaises(ValueError) as exc: sPC.check_hdl_versions(VerilogVersion.TWENTY_O_FIVE, VerilogVersion.TWENTY_O_FIVE) self.assertTrue("Only 93, 2002, 2008 is/are allowed as VHDL version number." in exc.exception)
def test_check_hdl_versions_both_correct(self): sPC.check_hdl_versions(VhdlVersion.NINETY_THREE, VerilogVersion.TWENTY_O_FIVE)
def test_check_hdl_versions_vhdl_none(self): sPC.check_hdl_versions(None, VerilogVersion.TWENTY_O_FIVE)
def test_check_hdl_versions_both_none(self): with self.assertRaises(ValueError) as exc: sPC.check_hdl_versions(None, None) self.assertTrue( '''Only 93, 2002, 2008 is/are allowed as VHDL version number. Only v2005 is/are allowed as Verilog version number.''' in exc.exception)
def main(): usage = """usage: %prog project-name hdp-file [destination] destination is the current directory by default example: %prog myproject.hdp """ parser = OptionParser(usage=usage) (options, args) = parser.parse_args() if len (args) < 2: parser.error("incorrect number of arguments") project_name = args[0] hdp_file = args[1] destination = os.getcwd() if len (args) > 2: destination = args[2] if not os.path.isdir(destination): parser.error("destination has to be a folder") entries = parse_hdp_file(hdp_file) print entries def getParts(pth): parts = [] while True: pth, last = os.path.split(pth) if not last: break parts.append(last) return parts sigasProjectFileCreator = SigasiProjectCreator(project_name) sigasProjectFileCreator.unmap("/") linkedFolders = dict() for path, library in entries.iteritems(): abs_destination = os.path.abspath(destination) abs_path = os.path.abspath(path) relativePath = os.path.relpath(abs_path, abs_destination) if (not relativePath.startswith("..")): sigasProjectFileCreator.add_mapping(relativePath, library) else: common_prefix = os.path.commonprefix([abs_path,abs_destination]) eclipse_path = os.path.relpath(abs_path,common_prefix) directoryName = getParts(eclipse_path)[-1] target = os.path.join(common_prefix,directoryName) linkedFolders[directoryName] = target sigasProjectFileCreator.add_mapping(eclipse_path, library) # adding custom items to libraries. # sigasProjectFileCreator.add_unisim("C:/xilinx/14.5/ISE_DS/ISE/vhdl/src/unisims") # sigasProjectFileCreator.add_unimacro("C:/xilinx/14.5/ISE_DS/ISE/vhdl/src/unimacro") def runningInCygWin(): return platform.system().startswith("CYGWIN") def convertCygwinPath(cygwinPath): cygwin_process = subprocess.Popen(['/usr/bin/cygpath', '--windows', cygwinPath], stdout=subprocess.PIPE) location = cygwin_process.communicate()[0].rstrip() location = location.replace('\\','/') return location for folder, location in linkedFolders.iteritems(): if runningInCygWin(): location = convertCygwinPath(location) sigasProjectFileCreator.add_link(folder, location, 2) sigasProjectFileCreator.write(destination)
def test_check_hdl_versions_verilog_none(self): sPC.check_hdl_versions(VhdlVersion.NINETY_THREE, None)