Esempio n. 1
0
def use_cpfatfs():

    for flavor in bin_file_dests:
        fat_file_dest = os.path.join(bin_file_dests[flavor], 'NON-HLOS.bin')

        #if NON-HLOS.bin exists delete it, a new NON-HLOS.bin will be created
        #if NON-HLOS.bin already exists, fatgen.py doesn't create it
        #deleting this file so that it is created each time
        if os.path.exists(fat_file_dest):
            os.remove(fat_file_dest)
            lg.log("Existing " + fat_file_dest + " has been deleted.")
        if (fatgen_build):
            # now create NON-HLOS.bin of container size as specifief in partition.xml
            modem_partition_size = use_fatgen_toget_partitionsize()
            lg.log_exec([
                'python', fatgen_tool, '-f', '-s', modem_partition_size, '-n',
                fat_file_dest
            ],
                        verbose=0)
        else:
            # Copy fat.bin to our root directory.  Assume fat.bin is in same directory as cpfatfs.exe
            shutil.copy(cpfatfs_path + fat_file_src, fat_file_dest)

        os.chmod(
            fat_file_dest, stat.S_IREAD | stat.S_IWRITE | stat.S_IRGRP
            | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH)
        fat_dest_dir = 'image'
        for fat_file in mi.get_files(attr='fat_file', flavor=flavor):
            lg.log('update_common_info.py:' + 'cpfatfs' + ' ' + fat_file +
                   ' ' + fat_file_dest,
                   verbose=0)
            lg.log_exec([cpfatfs_tool, fat_file_dest, fat_dest_dir, fat_file],
                        verbose=0)
def create_gen_build_flavor_cmm():
    common_dir = os.path.dirname(os.path.dirname(__file__))
    destn_dir = join_paths(os.path.dirname(__file__), "../tools/cmm/gen")
    if not os.path.exists(destn_dir):
        os.makedirs(destn_dir)
    lg.log("update_common_info.py: Calling gen_cmm_data3 to create " +
           join_paths(destn_dir, "gen_buildflavor.cmm"))
    lg.log_exec([
        "python", "../tools/meta/gen_cmm_data3.py",
        os.path.dirname(common_dir),
        join_paths(destn_dir, "gen_buildflavor.cmm")
    ])
Esempio n. 3
0
            # that need to be split will have a 'pil-split' attribute set to the
            # prefix to use for that file.  When we call get_file_vars, it will
            # return a dictionary mapping the prefix to the file to be split.
            # We must then prepend any path information to the prefix.
            pil_split_bins_dir = os.path.join('bin', flavor, 'pil_split_bins')
            if not os.path.exists(pil_split_bins_dir):
                os.makedirs(pil_split_bins_dir)
            pil_splitter_files = mi.get_file_vars(attr='pil_split',
                                                  flavor=flavor)
            for prefix in pil_splitter_files.keys():
                prefix_path = os.path.join(pil_split_bins_dir, prefix)
                # There should only be one source file per prefix
                pil_split_src = pil_splitter_files[prefix][0]
                lg.log('update_common_info: Calling pil-splitter on ' +
                       pil_split_src)
                lg.log_exec(
                    ['python', pil_splitter, pil_split_src, prefix_path])
    else:
        pil_split_bins_dir = os.path.join('bin', 'pil_split_bins')
        if not os.path.exists(pil_split_bins_dir):
            os.makedirs(pil_split_bins_dir)
        pil_splitter_files = mi.get_file_vars(attr='pil_split')
        for prefix in pil_splitter_files.keys():
            prefix_path = os.path.join(pil_split_bins_dir, prefix)
            # There should only be one source file per prefix
            pil_split_src = pil_splitter_files[prefix][0]
            lg.log('update_common_info: Calling pil-splitter on ' +
                   pil_split_src)
            lg.log_exec(['python', pil_splitter, pil_split_src, prefix_path])

#---------------------------------------------------------#
# Write the FAT image                                     #
            # that need to be split will have a 'pil-split' attribute set to the
            # prefix to use for that file.  When we call get_file_vars, it will
            # return a dictionary mapping the prefix to the file to be split.
            # We must then prepend any path information to the prefix.
            pil_split_bins_dir = os.path.join('bin', flavor, 'pil_split_bins')
            if not os.path.exists(pil_split_bins_dir):
                os.makedirs(pil_split_bins_dir)
            pil_splitter_files = mi.get_file_vars(attr='pil_split',
                                                  flavor=flavor)
            for prefix in pil_splitter_files.keys():
                prefix_path = os.path.join(pil_split_bins_dir, prefix)
                # There should only be one source file per prefix
                pil_split_src = pil_splitter_files[prefix][0]
                lg.log('update_common_info: Calling pil-splitter on ' +
                       pil_split_src)
                lg.log_exec(
                    ['python', pil_splitter, pil_split_src, prefix_path])
    else:
        pil_split_bins_dir = os.path.join('bin', 'pil_split_bins')
        if not os.path.exists(pil_split_bins_dir):
            os.makedirs(pil_split_bins_dir)
        pil_splitter_files = mi.get_file_vars(attr='pil_split')
        for prefix in pil_splitter_files.keys():
            prefix_path = os.path.join(pil_split_bins_dir, prefix)
            # There should only be one source file per prefix
            pil_split_src = pil_splitter_files[prefix][0]
            lg.log('update_common_info: Calling pil-splitter on ' +
                   pil_split_src)
            lg.log_exec(['python', pil_splitter, pil_split_src, prefix_path])

#---------------------------------------------------------#
# Write the FAT image                                     #
Esempio n. 5
0
            # that need to be split will have a 'pil-split' attribute set to the
            # prefix to use for that file.  When we call get_file_vars, it will
            # return a dictionary mapping the prefix to the file to be split.
            # We must then prepend any path information to the prefix.
            pil_split_bins_dir = os.path.join('bin', flavor, 'pil_split_bins')
            if not os.path.exists(pil_split_bins_dir):
                os.makedirs(pil_split_bins_dir)
            pil_splitter_files = mi.get_file_vars(attr='pil_split',
                                                  flavor=flavor)
            for prefix in pil_splitter_files.keys():
                prefix_path = os.path.join(pil_split_bins_dir, prefix)
                # There should only be one source file per prefix
                pil_split_src = pil_splitter_files[prefix][0]
                lg.log('update_common_info: Calling pil-splitter on ' +
                       pil_split_src)
                lg.log_exec(
                    ['python', pil_splitter, pil_split_src, prefix_path])
    else:
        pil_split_bins_dir = os.path.join('bin', 'pil_split_bins')
        if not os.path.exists(pil_split_bins_dir):
            os.makedirs(pil_split_bins_dir)
        pil_splitter_files = mi.get_file_vars(attr='pil_split')
        for prefix in pil_splitter_files.keys():
            prefix_path = os.path.join(pil_split_bins_dir, prefix)
            # There should only be one source file per prefix
            pil_split_src = pil_splitter_files[prefix][0]
            lg.log('update_common_info: Calling pil-splitter on ' +
                   pil_split_src)
            lg.log_exec(['python', pil_splitter, pil_split_src, prefix_path])

#---------------------------------------------------------#
# Write the FAT image                                     #
Esempio n. 6
0
    if os.path.exists(options.container):  # check and delete existing file
        lg.log("                 Deleting existing file")
        os.remove(options.container)
    if not os.path.exists(options.fatgen):  # check for fatgen tool
        lg.log("                 fatgen tool not found in")
        lg.log("                    " + options.fatgen)
        sys.exit(1)
    lg.log("                 Using fatgen from " + options.fatgen)
    # execute fatgen
    fatgen_cmd = [
        'python', options.fatgen, '-f', '-s', options.partsize, '-n',
        options.container
    ]
    if options.secsize:
        fatgen_cmd.extend(['--sectorsize', options.secsize])
    return_code = lg.log_exec(fatgen_cmd, verbose=0)
    if (return_code != 0):
        err_msg = "                  " + fatgen_cmd + ":Failed"
        lg.log(err_msg)
        sys.exit(1)

    # change container permissions
    os.chmod(
        options.container, stat.S_IREAD | stat.S_IWRITE | stat.S_IRGRP
        | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH)

    # Add each "fat_file" from contents.xml
    #--------------------------------------
    lg.log("fat_creation.py: Adding files into fat container:")
    lg.log("                 " + options.container)
    fatFiles = mi.get_files(attr=options.attr, flavor=options.flav)
            # that need to be split will have a 'pil-split' attribute set to the
            # prefix to use for that file.  When we call get_file_vars, it will
            # return a dictionary mapping the prefix to the file to be split.
            # We must then prepend any path information to the prefix.
            pil_split_bins_dir = os.path.join('bin', flavor, 'pil_split_bins')
            if not os.path.exists(pil_split_bins_dir):
                os.makedirs(pil_split_bins_dir)
            pil_splitter_files = mi.get_file_vars(attr='pil_split',
                                                  flavor=flavor)
            for prefix in pil_splitter_files.keys():
                prefix_path = os.path.join(pil_split_bins_dir, prefix)
                # There should only be one source file per prefix
                pil_split_src = pil_splitter_files[prefix][0]
                lg.log('update_common_info: Calling pil-splitter on ' +
                       pil_split_src)
                lg.log_exec(
                    ['python', pil_splitter, pil_split_src, prefix_path])
    else:
        pil_split_bins_dir = os.path.join('bin', 'pil_split_bins')
        if not os.path.exists(pil_split_bins_dir):
            os.makedirs(pil_split_bins_dir)
        pil_splitter_files = mi.get_file_vars(attr='pil_split')
        for prefix in pil_splitter_files.keys():
            prefix_path = os.path.join(pil_split_bins_dir, prefix)
            # There should only be one source file per prefix
            pil_split_src = pil_splitter_files[prefix][0]
            lg.log('update_common_info: Calling pil-splitter on ' +
                   pil_split_src)
            lg.log_exec(['python', pil_splitter, pil_split_src, prefix_path])

#---------------------------------------------------------#
# Write the FAT image                                     #
Esempio n. 8
0
    if os.path.exists(options.container):  # check and delete existing file
        lg.log("                 Deleting existing file")
        os.remove(options.container)
    if not os.path.exists(options.fatgen):  # check for fatgen tool
        lg.log("                 fatgen tool not found in")
        lg.log("                    " + options.fatgen)
        sys.exit(1)
    lg.log("                 Using fatgen from " + options.fatgen)
    # execute fatgen
    fatgen_cmd = [
        'python', options.fatgen, '-f', '-s', options.partsize, '-n',
        options.container
    ]
    if options.secsize:
        fatgen_cmd.extend(['--sectorsize', options.secsize])
    lg.log_exec(fatgen_cmd, verbose=0)

    # change container permissions
    os.chmod(
        options.container, stat.S_IREAD | stat.S_IWRITE | stat.S_IRGRP
        | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH)

    # Add each "fat_file" from contents.xml
    #--------------------------------------
    lg.log("fat_creation.py: Adding files into fat container:")
    lg.log("                 " + options.container)
    fatFiles = mi.get_files(attr=options.attr, flavor=options.flav)
    lg.log("fat_creation.py: Found " + str(len(fatFiles)) + " files")
    # Create sub directories in NON-HLOS.bin for each "sub_dir" from contents.xml
    subDirFiles = mi.get_files(attr='sub_dir', flavor=options.flav, abs=False)
    subDirFatFiles = {}
Esempio n. 9
0
            # that need to be split will have a 'pil-split' attribute set to the
            # prefix to use for that file.  When we call get_file_vars, it will
            # return a dictionary mapping the prefix to the file to be split.
            # We must then prepend any path information to the prefix.
            pil_split_bins_dir = os.path.join('bin', flavor, 'pil_split_bins')
            if not os.path.exists(pil_split_bins_dir):
                os.makedirs(pil_split_bins_dir)
            pil_splitter_files = mi.get_file_vars(attr='pil_split',
                                                  flavor=flavor)
            for prefix in pil_splitter_files.keys():
                prefix_path = os.path.join(pil_split_bins_dir, prefix)
                # There should only be one source file per prefix
                pil_split_src = pil_splitter_files[prefix][0]
                lg.log('update_common_info: Calling pil-splitter on ' +
                       pil_split_src)
                lg.log_exec(
                    ['python', pil_splitter, pil_split_src, prefix_path])
    else:
        pil_split_bins_dir = os.path.join('bin', 'pil_split_bins')
        if not os.path.exists(pil_split_bins_dir):
            os.makedirs(pil_split_bins_dir)
        pil_splitter_files = mi.get_file_vars(attr='pil_split')
        for prefix in pil_splitter_files.keys():
            prefix_path = os.path.join(pil_split_bins_dir, prefix)
            # There should only be one source file per prefix
            pil_split_src = pil_splitter_files[prefix][0]
            lg.log('update_common_info: Calling pil-splitter on ' +
                   pil_split_src)
            lg.log_exec(['python', pil_splitter, pil_split_src, prefix_path])

#---------------------------------------------------------#
# Write the FAT image                                     #
def workflow_exec(step_dict):
    # Execution step should specify the tool name to run
    if not ('tool_name' in step_dict or 'params' in step_dict):
        lg.log(
            "update_common_info.py: Invalid exec step! Tool name or command not specified"
        )
    else:
        for flavor in flavors:
            # Make a copy of step_dict for current flavor
            (step_dict_flavor,
             flavor_flag) = create_flavor_dict(step_dict, flavor)

            # Preprocess the standard items in the step
            preprocess_step(step_dict_flavor, flavor)

            # After preprocess check if the tool is available and execute
            if step_dict_flavor['tool_name']:
                lg.log(
                    "update_common_info: --------------------------------------------------"
                )
                lg.log("update_common_info:  Calling " +
                       step_dict_flavor['tool_name'].split('/')[-1] + " " +
                       (flavor or ""))

                # Check if the step has file_vars or files and loop accordingly
                if ('src_file_vars' in step_dict_flavor.keys()) and (len(
                        step_dict_flavor['src_file_vars']) > 0):
                    src_file_vars = step_dict_flavor['src_file_vars']
                    for key in src_file_vars.keys():
                        step_dict_flavor['src_file_var'] = key
                        for file in src_file_vars[key]:
                            step_dict_flavor['src_file'] = file
                            params = evaluate_params(step_dict_flavor)
                            lg.log(
                                "update_common_info: --------------------------------------------------\n"
                            )
                            lg.log_exec(params)
                elif ('src_files' in step_dict_flavor.keys()) and (len(
                        step_dict_flavor['src_files']) > 0):
                    src_files = step_dict_flavor['src_files']
                    for src_file in src_files:
                        step_dict_flavor['src_file'] = src_file
                        params = evaluate_params(step_dict_flavor)
                        lg.log(
                            "update_common_info: --------------------------------------------------\n"
                        )
                        lg.log_exec(params)
                else:
                    params = evaluate_params(step_dict_flavor)
                    lg.log(
                        "update_common_info: --------------------------------------------------\n"
                    )
                    lg.log_exec(params)

                if ('start_dir' in step_dict_flavor.keys()):
                    # cd'd to exec_dir in preprocessing, so revert back
                    os.chdir(step_dict_flavor['start_dir'])
                    del step_dict_flavor['start_dir']

            # Don't have to repeat if the step doesn't contain flavor info
            if (len(flavors) > 0) and (not flavor_flag):
                break
def use_fat_add():
    for flavor in bin_file_dests:
        fat_file_dest = os.path.join(bin_file_dests[flavor], 'NON-HLOS.bin')

        #if NON-HLOS.bin exists delete it, a new NON-HLOS.bin will be created
        #if NON-HLOS.bin already exists, fatgen.py doesn't create it
        #deleting this file so that it is created each time
        if os.path.exists(fat_file_dest):
            os.remove(fat_file_dest)
            lg.log("Existing " + fat_file_dest + " has been deleted.")
        if (fatgen_build):
            # Create NON-HLOS.bin of container size as specified in partition.xml
            modem_partition_size = use_fatgen_toget_partitionsize()
            lg.log_exec([
                'python', fatgen_tool, '-f', '-s', modem_partition_size, '-n',
                fat_file_dest
            ],
                        verbose=0)
        else:
            # Copy fat.bin to our root directory.  Assume fat.bin is in same directory as cpfatfs.exe
            shutil.copy(fatadd_path + fat_file_src, fat_file_dest)

        os.chmod(
            fat_file_dest, stat.S_IREAD | stat.S_IWRITE | stat.S_IRGRP
            | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH)

        # Add each "fat_file" from contents.xml
        fatFiles = mi.get_files(attr='fat_file', flavor=flavor)
        # Create sub directories in NON-HLOS.bin for each "sub_dir" from contents.xml
        subDirFiles = mi.get_files(attr='sub_dir', flavor=flavor, abs=False)
        subDirFatFiles = {}
        if len(subDirFiles) > 0:
            for relfile in subDirFiles:
                for absfile in fatFiles:
                    tempabsfile = absfile
                    if on_linux == False:
                        tempabsfile = absfile.replace('/', '\\')
                    if tempabsfile.find(relfile) != -1:
                        subDirFatFiles[absfile] = os.path.dirname(relfile)

        for fat_file in fatFiles:
            fat_dest_dir = 'image'
            print fat_file
            if fat_file in subDirFatFiles:
                fat_dest_dir = os.path.join(fat_dest_dir,
                                            subDirFatFiles[fat_file])
            lg.log('update_common_info.py:' + 'fatadd' + ' ' + fat_file + ' ' +
                   fat_file_dest,
                   verbose=0)
            lg.log_exec([
                'python', fatadd_tool, '-n', fat_file_dest, '-f' + fat_file,
                '-d' + fat_dest_dir
            ],
                        verbose=0)

        # Add ver_info.txt
        fat_dest_dir = 'verinfo'
        bid_file = os.path.join(os.path.dirname(__file__), 'Ver_Info.txt')
        if os.path.exists(bid_file):
            lg.log('update_common_info.py:' + 'fatadd' + ' ' + bid_file + ' ' +
                   fat_file_dest,
                   verbose=0)
            lg.log_exec([
                'python', fatadd_tool, '-n', fat_file_dest, '-f' + bid_file,
                '-d' + fat_dest_dir
            ],
                        verbose=0)
            lg.log('Processing the flavor ' + flavor)
        lg.log('pil_split_bins_dir: ' + pil_split_bins_dir)
        if not os.path.exists(pil_split_bins_dir):
            os.makedirs(pil_split_bins_dir)
        pil_splitter_files = mi.get_file_vars(attr='pil_split', flavor=flavor)

        for prefix in pil_splitter_files.keys():
            if not pil_splitter_files[prefix]:
                lg.log('Source file for prefix ' + prefix + ' is Null')
                sys.exit('Unable to call pil-splitter on prefix ' + prefix)
            prefix_path = os.path.join(pil_split_bins_dir, prefix)
            # There should only be one source file per prefix
            pil_split_src = pil_splitter_files[prefix][0]
            lg.log('update_common_info: Calling pil-splitter on ' +
                   pil_split_src)
            lg.log_exec(['python', pil_splitter, pil_split_src, prefix_path])

#---------------------------------------------------------#
# NON-HLOS Operations                                     #
#---------------------------------------------------------#
if options.non_hlos:
    #---------------------------------------------------------#
    # Write the FAT image                                     #
    #---------------------------------------------------------#
    lg.log("update_common_info:Writing FAT images")

    fat_file_src = 'fat.bin'
    fatfiles = []
    # check for fat file exist or not.
    # if flavors exists, we pass one flavor element to mi.get_files()
    # this is done just to avoid DataIntegrity exception
        var_list.setdefault(k, list())
        var_list[k] += v

command_line_arg = " "

for var in var_list:
    for file in var_list[var]:
        file_path, file_name_w_ext = os.path.split(file)
        file_name = os.path.splitext(file_name_w_ext)[0]
        partition_name = var
        #print "partiton name:",partition_name," File path:", file
        #lg.log("partiton name:" + partition_name + " File path:"+ file)
        #file = file.replace('/','\\')
        command_line_arg += "".join(partition_name) + " " + "".join(file) + " "

version_id = mi.get_build_id('common', 'builds_flat')
command_line_arg += "-v " + version_id

#print "command_line_arg:", command_line_arg
lg.log("command_line_arg:" + command_line_arg)

#getting apps build path
build_path = mi.get_build_path("apps")
lg.log("apps build path:" + build_path)

lg.log_exec([
    'python', build_path +
    '/LINUX/android/device/qcom/msm8909w/common/meta_image/make_image_tool.py',
    command_line_arg
])