コード例 #1
0
def process_project(build_runner, parsed_args, project, filespec, nowstring):
    """
    Process a project supplied as an x2p xml file. Find all configurations in
    the x2p file given. Look for makefile_project project types.
    If a makefile_project is found, get the list of source files.
    If the file we are looking for is found in the makefile_project, rename
    and replace the file found with that in the filespec, returning whatever
    the rename_and_replace_file method returns. If not a makefile_project, or
    the file we are looking for is not found in the makefile_project, return 0.
    """
    import maker.parse_proj_file as pproj
    proj_parser = pproj.Project(project, parsed_args.devkit_root,
                                parsed_args.workspace)
    config_list = proj_parser.get_configurations()
    test_string = "rsa_pss_constants" + os.sep + \
        os.path.basename(filespec)
    list_file = ""
    for config in config_list:
        if config == "makefile_project":
            file_list = proj_parser.get_source_files()
            for list_file in file_list:
                if list_file.endswith(test_string):
                    return rename_and_replace_file(list_file, filespec,
                                                   nowstring)

    return 0
コード例 #2
0
 def _search_project_for_flash_config_file(self, project):
     """
     Look through the configurations in a project for what may be the
     app/p1 and, if found, process the configuration keys.
     """
     import maker.parse_proj_file as pproj
     proj_parser = pproj.Project(project, self._devkit_root, self._workspace_file)
     config_list = proj_parser.get_configurations()
     for config in config_list:
         if config not in self._excludedConfigs and self._apps1_project_is_default(project, config):
             # Could be the apps/p1 project
             config_keys = proj_parser.get_properties_from_config(config)
             flash_config_file = self._search_config_keys_for_flash_config_file(config_keys)
             if flash_config_file:
                 return flash_config_file
     return None
コード例 #3
0
def search_project_for_chip_type(devkit_root, project, workspace_file):
    """
    Look through the configurations in a project for what may be the
    app/p1 and, if found, process the configuration keys.
    """
    import maker.parse_proj_file as pproj
    proj_parser = pproj.Project(project, devkit_root, workspace_file)
    config_list = proj_parser.get_configurations()
    for config in config_list:
        # Could be the apps/p1 project
        config_keys = \
            proj_parser.get_properties_from_config(config)
        chip_type = \
            search_config_keys_for_chip_type(config_keys)
        if chip_type:
            return chip_type
    return None
コード例 #4
0
def main(args):
    """ main entry point.
        - Processes cmd line args.
        - Finds and parses devkit sdk.xml and project file.
        - Calls builder with the target configuration. """

    parsed_args = parse_args(args)
    bdex.Logger(parsed_args)
    sys.path.append(os.path.join(parsed_args.devkit_root,
                                 r'tools\pythontools'))
    sys.path.append(os.path.join(parsed_args.devkit_root, r'tools\trbtrans'))
    import maker.deploy as dep

    try:
        os.environ['PATH'] = os.environ['SystemRoot'] + ';' + os.environ[
            'SystemRoot'] + '\system32'

        dk_xml_file = util.get_sdk_xml_file(parsed_args.devkit_root)

        proj_parser = pproj.Project(parsed_args.project_file,
                                    parsed_args.devkit_root,
                                    parsed_args.workspace_file)
        dk_parser = pdk.Devkit(dk_xml_file)

        if parsed_args.deploy_target:
            return dep.deploy(proj_parser, dk_parser, parsed_args)
        else:
            if parsed_args.verbose:
                bld.print_info(proj_parser, dk_parser, parsed_args)

            return bld.build_configs(proj_parser, dk_parser, parsed_args)

    except bdex.BDError as excep:
        bdex.err_handler(excep)
        return False
    except BaseException:
        bdex.err_handler(None)
        return False
    else:
        bdex.trace("+++ EXIT BUILD %s ++++" % os.path.abspath(sys.argv[0]))
        return True
コード例 #5
0
    def process_project(self, project, outpath, build_output_folder=None):
        """
        Process a project supplied as an x2p xml file. Find all configurations in
        the x2p file given. Look for the project types that are of interest.
        If the configuration is not for a project type we are interested in, or if
        we have already processed a project of that type, then ignore the
        configuration. If a configuration is for a project thype that is of interest
        and we don't already have a project of that type, then process the project
        and, if processed successfully, add its project type and target filename to
        the dictionary of projects. If a project cannot be processed successfully,
        print an error message and exit.
        """
        print("Processing project %s" % project)
        build_output_folder = self._build_output_folder

        import maker.parse_proj_file as pproj
        chip_type = None
        proj_parser = pproj.Project(project, self._devkit_root,
                                    self._workspace_file)
        config_list = proj_parser.get_configurations()
        for config in config_list:
            project_type = None
            config_keys = proj_parser.get_properties_from_config(config)
            proj_name = proj_parser.proj_projname
            if config == "prebuilt_image":
                try:
                    project_type = config_keys["SUBSYSTEM_NAME"]
                except KeyError as excep:
                    print("ERROR! Build Setting %s missing." % excep)
                    return False, chip_type
            elif config == "filesystem":
                try:
                    project_type = config_keys["TYPE"]
                except KeyError as excep:
                    print("ERROR! Build Setting %s missing." % excep)
                    return False, chip_type
            elif config in ("makefile_project", "deploy"):
                continue
            else:
                # User defined configuration (should be the P1 application project)
                try:
                    project_type = config_keys["DBG_CORE"]
                except KeyError as excep:
                    print("ERROR! Build Setting %s missing." % excep)
                    return False, chip_type

            # Make sure we only handle one of each project_type supported
            if project_type is not None:
                if project_type not in self._projects.keys():

                    if build_output_folder and os.path.isdir(
                            build_output_folder
                    ) and not build_output_folder.endswith(proj_name):
                        possible_outputfolder = os.path.join(
                            build_output_folder, proj_name)
                        if os.path.isdir(possible_outputfolder):
                            self._build_output_folder = possible_outputfolder
                        else:
                            self._build_output_folder = build_output_folder

                    xuv_filename = None
                    if project_type == "apps0":
                        xuv_filename = self._find_and_copy_xuv_file(
                            proj_parser, outpath)
                    elif project_type == "curator_config":
                        xuv_filename = self._process_curator_config_project(
                            proj_parser, outpath)
                    elif project_type in ("firmware_config", "device_config",
                                          "customer_ro", "user_ps"):
                        xuv_filename = self._process_apps_filesystem_project(
                            proj_parser, project_type, outpath)
                    elif project_type == "app/p1":
                        try:
                            output = config_keys["OUTPUT"]
                            chip_type = config_keys["CHIP_TYPE"].split(
                                '_')[0].upper()
                        except KeyError as excep:
                            print("ERROR! Build Setting %s missing." % excep)
                            return False, chip_type
                        # Make sure this is the default project to build
                        if self._apps1_project_is_default(project, config):
                            xuv_filename = self._process_apps1_project(
                                proj_parser, output, outpath, config)
                        else:
                            # Not the default build we are interested in
                            continue
                    elif project_type in ("btss", "curator", "audio"):
                        try:
                            if self._project_is_deployable(
                                    proj_parser, "prebuilt_image"):
                                xuv_filename = self._find_and_copy_xuv_file(
                                    proj_parser, outpath)
                        except (IOError, RuntimeError) as error:
                            print(error)
                            return False, chip_type
                    else:
                        # Not a project_type we are interested in
                        continue

                    if xuv_filename:
                        self._projects[project_type] = xuv_filename
                    elif project_type not in ("btss", "curator", "audio"):
                        print("failed to process %s; exiting" % project_type)
                        return False, chip_type

                else:
                    print("Already have a %s" % project_type)

            sys.stdout.flush()

        self._build_output_folder = build_output_folder
        return True, chip_type
コード例 #6
0
def zip_it(root_dir, workspace, out_dir, base_name):
    """ Archive the xcd file and any elf and lst files found below the root_dir
        - the root directory of the devkit
        - the output directory containing the xcd and log files, and to contain
            the zip file containing those and any elf and lst files found
        - the base string used for the name of the xcd, log and zip files
    """
    zip_filename = base_name + ".zip"
    zip_filespec = os.path.join(out_dir, zip_filename)
    # Create the archive for writing "deflated" (compressed) files to
    try:
        with zipfile.ZipFile(zip_filespec,
                             mode="w",
                             compression=zipfile.ZIP_DEFLATED) as zip:
            # So put the xcd file in it...
            xcd_arcname = base_name + ".xcd"
            xcd_filespec = os.path.join(out_dir, xcd_arcname)
            assert os.path.isfile(xcd_filespec)
            print("Adding {} to archive {}\n".format(xcd_arcname,
                                                     zip_filespec))
            zip.write(xcd_filespec, xcd_arcname)
            # ... and put the log file in it ...
            log_arcname = base_name + ".log"
            log_filespec = os.path.join(out_dir, log_arcname)
            if os.path.isfile(log_filespec):
                print("Adding {} to archive {}\n".format(
                    log_arcname, zip_filespec))
                zip.write(log_filespec, log_arcname)
            else:
                print("{} not found\n".format(log_filespec))
            # ... and put any *.elf/*.lst files found in the workspace in it
            print(
                "Looking in {} project locations for *.elf and *.lst files\n".
                format(workspace))
            sys.stdout.flush()
            ws_projects = Workspace(workspace).parse()
            for proj in ws_projects.keys():
                project = ws_projects[proj].filename
                import maker.parse_proj_file as pproj
                proj_parser = pproj.Project(project, root_dir, workspace)
                print("Processing project %s\n" % project)
                elffile, lstfile = process_project(project, proj_parser)

                if elffile is not None:
                    _, elffilename = os.path.split(elffile)
                    print("Adding %s to archive %s\n" %
                          (elffile, zip_filespec))
                    sys.stdout.flush()
                    zip.write(elffile, elffilename)
                    if lstfile is not None:
                        _, lstfilename = os.path.split(lstfile)
                        print("Adding %s to archive %s\n" %
                              (lstfile, zip_filespec))
                        sys.stdout.flush()
                        zip.write(lstfile, lstfilename)
                else:
                    print("No elf file found for this project\n")

            print("Please send the {} file to your".format(zip_filespec))
            print(
                "Qualcomm Technologies International, Ltd. representative.\n")
    except OSError as exception:
        print("Error with zip file {} failed; error {}, {}\n" \
            .format(zip_filespec, exception.errno, os.strerror(exception.errno)))

    sys.stdout.flush()