def test_create_build_directory(self): cfg = utils.read_config(self.env) build_dir = "temp" cfg["build_dir"] = build_dir utils.create_build_directory(cfg) build_dir = os.path.join(utils.get_project_base(), build_dir) self.assertTrue(os.path.exists(build_dir)) os.rmdir(build_dir)
def test_get_xst_flags(self): """generate a define table given a file""" config_fn = os.path.join(utils.get_project_base(), "config.json") config = json.load(open(config_fn, "r")) flags = xst_utils.get_xst_flags(config) #print "Flags" #for flag in flags: # print "\t%s: %s" % (flag, flags[flag]["value"]) self.assertIn("-iob", flags.keys())
def clean_build(env): config = utils.read_config(env) base_dir = utils.get_project_base() build_dir = utils.get_build_directory(config, absolute = True) xmsgs_dir = os.path.join(base_dir, "_xmsgs") xlnx_auto = os.path.join(base_dir, "xlnx_auto_0_xdb") config_log = os.path.join(base_dir, "config.log") xdevice_details = os.path.join(base_dir, "xilinx_device_details.xml") map_report = "%s_map.xrpt" % config["top_module"] map_report = os.path.join(base_dir, map_report) par_usage = os.path.join(base_dir, "par_usage_statistics.html") par_report = "%s_par.xrpt" % config["top_module"] par_report = os.path.join(base_dir, par_report) #Coregen coregen_log = os.path.join(base_dir, "coregen.log") print "Removing Directories/Files:" if os.path.exists(build_dir): print "\t%s" % build_dir shutil.rmtree(build_dir) if os.path.exists(xmsgs_dir): print "\t%s" % xmsgs_dir shutil.rmtree(xmsgs_dir) if os.path.exists(xlnx_auto): print "\t%s" % xlnx_auto shutil.rmtree(xlnx_auto) if os.path.exists(config_log): print "\t%s" % config_log os.remove(config_log) if os.path.exists(xdevice_details): print "\t%s" % xdevice_details os.remove(xdevice_details) if os.path.exists(map_report): print "\t%s" % map_report os.remove(map_report) if os.path.exists(par_usage): print "\t%s" % par_usage os.remove(par_usage) if os.path.exists(par_report): print "\t%s" % par_report os.remove(par_report) if os.path.exists(coregen_log): print "\t%s" % coregen_log os.remove(coregen_log)
def get_new_coregen_file_list(config): """ Get a list of .xco files from for cores directory Args: config (dictionary): configuration dictionary Return: (list of strings): list of filenames Raises: Nothing """ project_dir = utils.get_project_base() core_dir = os.path.join(project_dir, "cores") search_path = os.path.join(core_dir, "*.xco") files = glob.glob(search_path) return files
def create_temp_dir(config): """ Create an xst temporary directory in the build folder Args: config (dictionary): configuration dictionary Return: Nothing Raises: Nothing """ xst_dir = os.path.join(config["build_dir"], XST_DIR) temp_dir = os.path.join(xst_dir, XST_TEMP_DIR) temp_abs_dir = os.path.join(utils.get_project_base(), xst_dir, XST_TEMP_DIR) if not os.path.exists(temp_abs_dir): os.makedirs(temp_abs_dir) return temp_dir
def CleanBuild(env, targets): import os import shutil import utils if not env.GetOption('clean'): return # normalize targets to absolute paths config = utils.read_config(env) base_dir = utils.get_project_base() build_dir = utils.get_build_directory(config) xmsgs_dir = os.path.join(base_dir, "_xmsgs") print "Directories to remove:" print "\t%s" % build_dir print "\t%s" % xmsgs_dir #shutil.rmtree(build_dir) #shutil.rmtree(xmsg_dir) return 0
def create_ucf_filename(config): """ find all UCF files assoicated with this project this function searches through the constraints directory for any UCF file. Unfortunately ngdbuild will only read in one ucf file, so in order to include all ucf files the function will aggragate all ucf file to one ucf file in the build/ngd/project.ucf file Args: config (dictionary): configuration dictionary Returns: (string): file name (absolute) of combinded ucf files Raises: Nothing """ project_dir = utils.get_project_base() #XXX: I should look at the constraints assoicated with coregened files ucf_search_path = os.path.join(project_dir, "constraints", "*.ucf") ucf_files = glob.glob(ucf_search_path) #print "ucf files: %s" % str(ucf_files) #Get all ucf files within the cores directory #XXX: Need to make an output cores directory ngd_dir = get_ngd_dir(config, absolute = True) p_ucf_fn = os.path.join(ngd_dir, NGD_PROJECT_UCF) fp = open(p_ucf_fn, "w") for f in ucf_files: ufp = open(f, "r") ucf = ufp.read() #print "ucf: %s" % ucf fp.write(ucf) fp.write(os.linesep) fp.close() return p_ucf_fn
def create_ucf_filename(config): """ find all UCF files assoicated with this project this function searches through the constraints directory for any UCF file. Unfortunately ngdbuild will only read in one ucf file, so in order to include all ucf files the function will aggragate all ucf file to one ucf file in the build/ngd/project.ucf file Args: config (dictionary): configuration dictionary Returns: (string): file name (absolute) of combinded ucf files Raises: Nothing """ project_dir = utils.get_project_base() # XXX: I should look at the constraints assoicated with coregened files ucf_search_path = os.path.join(project_dir, "constraints", "*.ucf") ucf_files = glob.glob(ucf_search_path) # print "ucf files: %s" % str(ucf_files) # Get all ucf files within the cores directory # XXX: Need to make an output cores directory ngd_dir = get_ngd_dir(config, absolute=True) p_ucf_fn = os.path.join(ngd_dir, NGD_PROJECT_UCF) fp = open(p_ucf_fn, "w") for f in ucf_files: ufp = open(f, "r") ucf = ufp.read() # print "ucf: %s" % ucf fp.write(ucf) fp.write(os.linesep) fp.close() return p_ucf_fn