Пример #1
0
def _execute_pilsplit(env, pilsplitter_target_base_dir, install_file_name,
                      sectools_builder_output, build_policy, pilsplitter_path):

    util = BuilderUtil(env)

    pilsplitter_target_base_dir = os.path.realpath(
        util.envsubst(pilsplitter_target_base_dir))
    pilsplitter_path = os.path.realpath(util.envsubst(pilsplitter_path))
    install_file_name = util.envsubst(install_file_name)

    rt_list = []
    if c_path.validate_file(pilsplitter_path):
        util.loadToolScript(pilsplitter_path)
    for i, sec_image_policy in enumerate(
            build_policy.enabled_sec_image_policies):
        rtt = _execute_postprocess_policy(
            env,
            sectools_install_base_dir=pilsplitter_target_base_dir,
            install_file_name=install_file_name,
            sectools_builder_output=sectools_builder_output[i],
            install_policies=build_policy.enabled_install_policies,
            sec_image_policy=sec_image_policy,
            postprocess=POSTPROCESS_PILSPLIT)

        rt_list.append(rtt)

    return rt_list
Пример #2
0
def _execute_install(env,
                     sectools_install_base_dir,
                     install_file_name,
                     sectools_builder_output,
                     msmid_jtagid_dict,
                     build_policy
                     ):

    util = BuilderUtil(env)

    sectools_install_base_dir = os.path.realpath(util.envsubst(sectools_install_base_dir))
    install_file_name = util.envsubst(install_file_name)

    rt_list = []
    for i, sec_image_policy in enumerate(build_policy.enabled_sec_image_policies):
        rtt = _execute_postprocess_policy(env,
            sectools_install_base_dir=sectools_install_base_dir,
            install_file_name=install_file_name,
            sectools_builder_output=sectools_builder_output[i],
            msmid_jtagid_dict=msmid_jtagid_dict,
            install_policies=build_policy.enabled_install_policies,
            sec_image_policy=sec_image_policy)

        rt_list.append(rtt)

    return rt_list
Пример #3
0
def _execute_install(env, sectools_install_base_dir, install_file_name,
                     sectools_builder_output, alternate_source,
                     msmid_jtagid_dict, build_policy):

    util = BuilderUtil(env)

    sectools_install_base_dir = os.path.realpath(
        util.envsubst(sectools_install_base_dir))
    install_file_name = util.envsubst(install_file_name)

    rt_list = []
    for i, sec_image_policy in enumerate(
            build_policy.enabled_sec_image_policies):
        rtt = _execute_install_policy(
            env,
            sectools_install_base_dir=sectools_install_base_dir,
            install_file_name=install_file_name,
            sectools_builder_output=sectools_builder_output[i]
            if sectools_builder_output else None,
            alternate_source=alternate_source[i] if alternate_source else None,
            msmid_jtagid_dict=msmid_jtagid_dict,
            install_policies=build_policy.enabled_install_policies,
            sec_image_policy_id=sec_image_policy.id)

        for rt in rtt:
            rt_list.append(rt)

    return rt_list
def _execute_pilsplit(env,
                     pilsplitter_target_base_dir,
                     install_file_name,
                     sectools_builder_output,
                     msmid_jtagid_dict,
                     build_policy,
                     pilsplitter_path
                     ):

    util = BuilderUtil(env)

    pilsplitter_target_base_dir = os.path.realpath(util.envsubst(pilsplitter_target_base_dir))
    pilsplitter_path = os.path.realpath(util.envsubst(pilsplitter_path))
    install_file_name = util.envsubst(install_file_name)

    rt_list = []
    if c_path.validate_file(pilsplitter_path):
        util.loadToolScript(pilsplitter_path)
    for i, sec_image_policy in enumerate(build_policy.enabled_sec_image_policies):
        rtt = _execute_postprocess_policy(env,
            sectools_install_base_dir=pilsplitter_target_base_dir,
            install_file_name=install_file_name,
            sectools_builder_output=sectools_builder_output[i],
            msmid_jtagid_dict=msmid_jtagid_dict,
            install_policies=build_policy.enabled_install_policies,
            sec_image_policy=sec_image_policy,
            postprocess=POSTPROCESS_PILSPLIT)

        rt_list.append(rtt)

    return rt_list
Пример #5
0
def build(env,
          target_base_dir,
          source,
          sign_id,
          jtagid=None,
          sectools_install_base_dir=None,
          install_file_name=None,
          msmid=None,
          msmid_jtagid_dict=None,
          msm_jtag_mapping_file=DEFAULT_MSM_JTAG_MAPPING_FILE,
          disable_featureflags=DEFAULT_DISABLE_FEATURE_FLAGS,
          config=DEFAULT_CONFIG_FILE,
          policy_file=DEFAULT_POLICY_FILE):
    rt = []

    util = BuilderUtil(env)

    source = util.envsubst(source)
    if type(source) is not list:
        source = [source]
    source_str = os.path.realpath(str(source[0]))
    policy_file = os.path.realpath(util.envsubst(policy_file))
    target_dir_realpath = os.path.realpath(util.envsubst(target_base_dir))

    build_policy = BuildPolicy(policy_file, env)

    # don't do anything if none of the tags match.
    if _isPolicyRun(env, disable_featureflags, build_policy,
                    source_str) is True:

        if msmid_jtagid_dict is None:
            msmid_jtagid_dict = get_msm_jtag_dict_from_file(env, msmid)

        rt_signed_list = []
        rt_installed_list = []
        for sec_image_policy in build_policy.enabled_sec_image_policies:
            rtt = _execute_sec_image_policy(
                env,
                target_base_dir=target_dir_realpath,
                source=source_str,
                sign_id=sign_id,
                config=os.path.realpath(util.envsubst(config)),
                msmid_jtagid_dict=msmid_jtagid_dict,
                sec_image_policy=sec_image_policy)
            rt_signed_list.append(rtt)
        rt = rt_signed_list

        if sectools_install_base_dir is not None:
            rt_installed_list = _execute_install(
                env,
                sectools_install_base_dir=sectools_install_base_dir,
                install_file_name=install_file_name,
                sectools_builder_output=rt_signed_list,
                alternate_source=None,
                msmid_jtagid_dict=msmid_jtagid_dict,
                build_policy=build_policy)
            rt = rt_installed_list

    return rt
def _execute_postprocess_policy(env,
                                sectools_install_base_dir,
                                install_file_name,
                                sectools_builder_output,
                                msmid_jtagid_dict,
                                install_policies,
                                sec_image_policy,
                                postprocess=POSTPROCESS_INSTALL):

    rt_list = []

    if len(sectools_builder_output) == 0:
        #Empty list - the target is excluded
        return rt_list

    util = BuilderUtil(env)

    for install_policy in install_policies:
        install_directory = install_policy.getDirectory(sec_image_policy.id)
        if install_directory is None:
            continue

        install_directory_processed = signerutils.macro_replace(
            install_directory,
            "sectools_install_base_dir",
            sectools_install_base_dir,
            isMandatory=False)
        install_directory_processed = os.path.normpath(
            util.envsubst(install_directory_processed))

        if install_file_name is not None:
            target_file_path = os.path.join(install_directory_processed,
                                            install_file_name)
        else:
            path, filename = os.path.split(sectools_builder_output[0])
            target_file_path = os.path.join(install_directory_processed,
                                            filename)

        if postprocess == POSTPROCESS_INSTALL:
            rt = util.installas(target_file_path, sectools_builder_output[0])
        elif postprocess == POSTPROCESS_PILSPLIT:
            pil_split_path, ext = os.path.splitext(target_file_path)
            rt = util.pilsplit(pil_split_path + ".mdt",
                               sectools_builder_output[0])
        else:
            raise RuntimeError(
                "{0} not supported in _execute_postprocess_policy".format(
                    postprocess))

        rt_list.append(rt)

    return rt_list
Пример #7
0
def get_msm_jtag_dict_from_file(env, msmid,
    msm_jtag_mapping_file=DEFAULT_MSM_JTAG_MAPPING_FILE,
    file_type="xml"):

    if msmid is None:
        return DEFAULT_MSM_JTAG_DICT

    util = BuilderUtil(env)

    msm_jtag_mapping_file = os.path.realpath(util.envsubst(msm_jtag_mapping_file))
    util.printinfo("sectools_builder: msm_jtag_mapping_file= %s" % msm_jtag_mapping_file)
    try:
        msmid_jtagid_dict = _get_msm_jtag_dict_from_file_impl(msmid, msm_jtag_mapping_file, file_type)
    except Exception, e:
        util.returnError(str(e))
def _execute_postprocess_policy(env,
            sectools_install_base_dir,
            install_file_name,
            sectools_builder_output,
            msmid_jtagid_dict,
            install_policies,
            sec_image_policy,
            postprocess=POSTPROCESS_INSTALL):

    rt_list=[]

    if len(sectools_builder_output) == 0:
        #Empty list - the target is excluded
        return rt_list

    util = BuilderUtil(env)

    for install_policy in install_policies:
        install_directory = install_policy.getDirectory(sec_image_policy.id)
        if install_directory is None:
            continue

        install_directory_processed = signerutils.macro_replace(install_directory,
                            "sectools_install_base_dir",
                            sectools_install_base_dir,
                            isMandatory=False)
        install_directory_processed = os.path.normpath(
                                            util.envsubst(install_directory_processed))

        if install_file_name is not None:
            target_file_path = os.path.join(install_directory_processed,
                                        install_file_name)
        else:
            path, filename = os.path.split(sectools_builder_output[0])
            target_file_path = os.path.join(install_directory_processed, filename)


        if postprocess == POSTPROCESS_INSTALL:
            rt = util.installas(target_file_path, sectools_builder_output[0])
        elif postprocess == POSTPROCESS_PILSPLIT:
            pil_split_path, ext = os.path.splitext(target_file_path)
            rt = util.pilsplit(pil_split_path + ".mdt", sectools_builder_output[0])
        else:
            raise RuntimeError("{0} not supported in _execute_postprocess_policy".format(postprocess))

        rt_list.append(rt)

    return rt_list
Пример #9
0
def _execute_install_policy(env, sectools_install_base_dir, install_file_name,
                            sectools_builder_output, alternate_source,
                            msmid_jtagid_dict, install_policies,
                            sec_image_policy_id):

    rt_list = []

    util = BuilderUtil(env)

    for install_policy in install_policies:
        install_directory = install_policy.getDirectory(sec_image_policy_id)
        if install_directory is None:
            continue

        install_directory_processed = signerutils.macro_replace(
            install_directory,
            "sectools_install_base_dir",
            sectools_install_base_dir,
            isMandatory=False)
        install_directory_processed = os.path.normpath(
            util.envsubst(install_directory_processed))

        if install_file_name is not None:
            target_file_path = os.path.join(install_directory_processed,
                                            install_file_name)
        else:
            path, filename = os.path.split(sectools_builder_output[0])
            target_file_path = os.path.join(install_directory_processed,
                                            filename)

        if alternate_source is not None:
            rt = util.installas(target_file_path, alternate_source)
        else:
            rt = util.installas(target_file_path, sectools_builder_output[0])

        rt_list.append(rt)

    return rt_list
Пример #10
0
def build(env,
          target_base_dir,
          source,
          sign_id,
          signer=None,
          qc_sign=False,
          jtag_id=None,
          soc_hw_version=None,
          soc_vers=None,
          app_id=None,
          sectools_install_base_dir=None,
          install_file_name=None,
          msmid=None,
          msmid_jtagid_dict=None,
          msm_jtag_mapping_file=DEFAULT_MSM_JTAG_MAPPING_FILE,
          disable_featureflags=DEFAULT_DISABLE_FEATURE_FLAGS,
          config=DEFAULT_CONFIG_FILE,
          policy_file=DEFAULT_POLICY_FILE,
          pilsplitter_target_base_dir=None,
          pilsplitter_path=DEFAULT_PILSPLITTER_PATH,
          pilsplitter_featureflag=[],
          image_entry=None,
          relocatable=False):
    rt = []

    util = BuilderUtil(env)

    source = util.envsubst(source)
    if type(source) is not list:
        source = [source]
    source_path = os.path.realpath(str(source[0]))
    policy_file = os.path.realpath(util.envsubst(policy_file))
    target_dir_realpath = os.path.realpath(util.envsubst(target_base_dir))
    build_policy = BuildPolicy(policy_file, env)
    if msmid_jtagid_dict is None:
        msmid_jtagid_dict = get_msm_jtag_dict_from_file(env, msmid)

    # don't do anything if none of the tags match.
    if _isPolicyRun(env, disable_featureflags, build_policy,
                    source_path) is True:
        rt_signed_list = _execute_sign(env,
                                       target_base_dir=target_dir_realpath,
                                       source=source_path,
                                       signer=signer,
                                       qc_sign=qc_sign,
                                       sign_id=sign_id,
                                       jtag_id=jtag_id,
                                       soc_hw_version=soc_hw_version,
                                       soc_vers=soc_vers,
                                       app_id=app_id,
                                       config=os.path.realpath(
                                           util.envsubst(config)),
                                       msmid_jtagid_dict=msmid_jtagid_dict,
                                       build_policy=build_policy,
                                       image_entry=image_entry,
                                       relocatable=relocatable)
        rt.append(rt_signed_list)

        if sectools_install_base_dir is not None:
            rt_installed_list = _execute_install(
                env,
                sectools_install_base_dir=sectools_install_base_dir,
                install_file_name=install_file_name,
                sectools_builder_output=rt_signed_list,
                build_policy=build_policy)
            rt.append(rt_installed_list)

        if (len(pilsplitter_featureflag) == 0 or
            util.isKeyEnable(pilsplitter_featureflag)) and \
            pilsplitter_target_base_dir is not None:
            rt_pilsplit_list = _execute_pilsplit(
                env,
                pilsplitter_target_base_dir=pilsplitter_target_base_dir,
                install_file_name=install_file_name,
                sectools_builder_output=rt_signed_list,
                build_policy=build_policy,
                pilsplitter_path=pilsplitter_path)
            rt.append(rt_pilsplit_list)

    return rt
def build(env,
        target_base_dir,
        source,
        sign_id,
        jtagid=None,
        sectools_install_base_dir = None,
        install_file_name = None,
        msmid = None,
        msmid_jtagid_dict = None,
        msm_jtag_mapping_file=DEFAULT_MSM_JTAG_MAPPING_FILE,
        disable_featureflags=DEFAULT_DISABLE_FEATURE_FLAGS,
        config=DEFAULT_CONFIG_FILE,
        policy_file=DEFAULT_POLICY_FILE,
        pilsplitter_target_base_dir = None,
        pilsplitter_path = DEFAULT_PILSPLITTER_PATH,
        pilsplitter_featureflag = [],
        image_entry = None,
        relocatable = False):
    rt = []

    util = BuilderUtil(env)

    source = util.envsubst(source)
    if type(source) is not list:
        source = [source]
    source_str = os.path.realpath(str(source[0]))
    policy_file = os.path.realpath(util.envsubst(policy_file))
    target_dir_realpath = os.path.realpath(util.envsubst(target_base_dir))

    build_policy = BuildPolicy(policy_file, env)

    # don't do anything if none of the tags match.
    if _isPolicyRun(env, disable_featureflags, build_policy, source_str) is True:

        if msmid_jtagid_dict is None:
            msmid_jtagid_dict = get_msm_jtag_dict_from_file(env, msmid)


        rt_signed_list = _execute_sign(env,
                          target_base_dir=target_dir_realpath,
                          source=source_str,
                          sign_id=sign_id,
                          config=os.path.realpath(util.envsubst(config)),
                          msmid_jtagid_dict=msmid_jtagid_dict,
                          build_policy=build_policy,
                          image_entry=image_entry,
                          relocatable=relocatable)
        rt.append(rt_signed_list)

        if sectools_install_base_dir is not None:
            rt_installed_list = _execute_install(env,
                sectools_install_base_dir=sectools_install_base_dir,
                install_file_name=install_file_name,
                sectools_builder_output=rt_signed_list,
                msmid_jtagid_dict=msmid_jtagid_dict,
                build_policy=build_policy)
            rt.append(rt_installed_list)

        if (len(pilsplitter_featureflag) == 0 or
            util.isKeyEnable(pilsplitter_featureflag)) and \
            pilsplitter_target_base_dir is not None:
            rt_pilsplit_list = _execute_pilsplit(env,
                pilsplitter_target_base_dir=pilsplitter_target_base_dir,
                install_file_name=install_file_name,
                sectools_builder_output=rt_signed_list,
                msmid_jtagid_dict=msmid_jtagid_dict,
                build_policy=build_policy,
                pilsplitter_path=pilsplitter_path)
            rt.append(rt_pilsplit_list)


    return rt