Beispiel #1
0
def gen_target_config(env, build_var, pl):
    target_builds_fn = build_products_path + build_var + ".builds"

    # Change directory to the build\ms directory for the parser to work
    saved_dir = os.getcwd()
    os.chdir(build_products_path)

    # Import the legacy tcfgparser code to build the cust*.h, targ*.h, and 
    # tcfg_*.py files.
    import tcfgparser
    tcfg = tcfgparser.TargetConfigurationDb()

    # Setup the search paths for tcfgparser.
    tcfg_search_paths = [env.subst(path).rsplit('/', 1)[0] +
                         '/' for path in bld_script_name_templates]

    # Parse the *.builds files.
    gen_result = tcfg.ParseBuildFile(target_builds_fn,
                                     pl,
                                     search_paths = tcfg_search_paths)
    if not gen_result:
        # Restore the saved directory
        os.chdir(saved_dir)
        raise RuntimeError, 'ParseBuildFile failed.'
        return

    # Generate config header files.
    tcfg_bid_data  = tcfg.GenConfigData(build_var, env['PRODUCT_LINE'])

    # Generate tcfg_*.py file
    tcfg_bid_data_file = open(build_products_path +
                              tcfg_file_name_template % build_var.lower(), 'w')

    # Write header to file.
    tcfg_bid_data_file.write ('''\
#==============================================================================
# Target Build ID Config Script.
#
# Copyright (c) 2014 QUALCOMM Technologies Inc.  All Rights Reserved
#==============================================================================

def exists(env):
    return env.Detect('tcfg_%s_data')

def generate(env):
    # Save the tcfg_bid_data in the env
    env['TCFG_BID_IMAGE'] = '%s'

''' % (build_var, tcfg_bid_data.image.upper()))

    # Output the 
    for flag in sorted(tcfg_bid_data.uses_flags):
        tcfg_bid_data_file.write('''\
    env.AddUsesFlags('%s', from_builds_file = True)
''' % flag)

    # Save the file.
    tcfg_bid_data_file.close()

    # Restore the saved directory
    os.chdir(saved_dir)
Beispiel #2
0
def GenTargetConfig(env, build_id):

   env.PrintInfo("Begin Target Config: " + build_id)

   tcfgf_opt = env.GetOption('tcfgf')

   if tcfgf_opt is None:
      bld_target_file = "target.builds"
   else:
      bld_target_file = str(tcfgf_opt)

   env.PrintInfo("Target configuration file: %s" % bld_target_file)

   # Generate the names of the data files used to check if the .builds file has been
   # updated since the last build.  If they have, we'll need to rebuild the configuration
   # files.
   buildsfile_name = target_config_path + bld_target_file
   buildsfile_md5 = build_products_path + bld_target_file + ".md5"
   
   # nothing to do if clean option is enabled.
#   if env.get('MSM_ID') not in ['7x30']:
#      if env.GetOption('clean'):
#         return None
#   if env.GetOption('clean'):
#      clean_all_products(env)
#      return True

   # check if builds file exists other wise do nothing; most possibly
   # stip/pack build expect everything to be done.
   gen_result = True
   if env.PathExists(buildsfile_name):
   
      # Check to see if we need to regen the config files 
      tcfg_files_changed = not env.CompareAndUpdateMD5File(buildsfile_name, buildsfile_md5)
      for template in bld_script_name_templates + tbc_script_name_templates:
         for file in glob.glob(env.subst(template)):
            md5_file = file + ".md5"
            tcfg_files_changed |= not env.CompareAndUpdateMD5File(file, md5_file)

      if tcfg_files_changed:
         env.PrintInfo("Target Config files have changed.  Reparsing")
         clean_all_products(env)
   
      if not check_bid_products(env, build_id.lower()):
         # Build new target config product files as needed.
         env.PrintInfo("Generating Target Config Files for " + build_id)
         # Change directory to the build\ms directory for the parser to work
         saved_dir = os.getcwd()
         os.chdir(target_config_path)
         import tcfgparser
         tcfg = tcfgparser.TargetConfigurationDb()
         tcfg_search_paths = [env.subst(path).rsplit('/', 1)[0] + '/' for path in bld_script_name_templates]
         gen_result = tcfg.ParseBuildFile(target_config_path + bld_target_file,
                                          search_paths = tcfg_search_paths)
         if gen_result:
            tcfg_bid_data  = tcfg.GenConfigData(build_id)
            if tcfg_bid_data:
               WriteTcfgBidData(env, tcfg_bid_data, build_id)
            else:
               gen_result = False
         # Restore the saved directory
         os.chdir(saved_dir)

   # Header files should already be generated, but we need to read
   # in the pickled tcfg_bid_data.
   ReadTcfgBidData(env, build_id)

   # Load Target Config SCons Tools
   for template in tbc_script_name_templates:
      for tool_name in glob.glob(env.subst(template)):
         tool_dir  = os.path.dirname(tool_name)
         tool_name = os.path.basename(tool_name)[0:-3] # drop the ".py"
         env.LoadToolScript(tool_name, toolpath=[tool_dir])

   env.PrintInfo("End Target Config: " + build_id)
   return gen_result and check_bid_products(env, build_id.lower())
Beispiel #3
0
def GenTargetConfig(env, build_id):
    '''
       Function: GenTargetConfig

       This function reads the target configuration, generates the cust/targ.h
       files, and adds a list of USES_* flags specified by the target scripts
       to the construction environment.

       It also stores target incpath information in the environment, which can
       be retrieved later through the env.GetTargetIncpaths() method.
    '''

    env.PrintInfo("Begin Target Config: " + build_id)

    tcfgf_opt = env.GetOption('tcfgf')

    if tcfgf_opt is None:
        bld_target_path = TARGET_CONFIG_PATH
        bld_target_file = "target.builds"
    else:
        bld_target_path, bld_target_file = os.path.split(str(tcfgf_opt))
        if bld_target_path == '':
            bld_target_path = TARGET_CONFIG_PATH

    # Generate the names of the data files used to check if the .builds file has
    # been updated since the last build.  If they have, we'll need to rebuild
    # the configuration files.
    buildsfile_name = os.path.join(bld_target_path, bld_target_file)
    buildsfile_md5 = os.path.join(BUILD_PRODUCTS_PATH, bld_target_file + \
                        ".${SHORT_BUILDPATH}.md5")

    # nothing to do if clean option is enabled.
    #   if env.get('MSM_ID') not in ['7x30']:
    #      if env.GetOption('clean'):
    #         return None
    #   if env.GetOption('clean'):
    #      clean_all_products(env)
    #      return True

    # check if builds file exists other wise do nothing; most possibly
    # stip/pack build expect everything to be done.
    gen_result = True
    if env.PathExists(buildsfile_name):
        if env.GetOption('clean') and not env.GetOption('cleanpack'):
            atexit.register(clean_all_products, env, build_id.lower())
        env.PrintInfo("Target configuration file: %s" % bld_target_file)

        # Check to see if we need to regen the config files
        tcfg_files_changed = \
            not env.CompareAndUpdateMD5File(buildsfile_name, buildsfile_md5)
        for template in BLD_SCRIPT_NAME_TEMPLATES + TBC_SCRIPT_NAME_TEMPLATES:
            for file_name in glob.glob(env.subst(template)):
                md5_file = file_name + ".${SHORT_BUILDPATH}.md5"
                tcfg_files_changed |= \
                    not env.CompareAndUpdateMD5File(file_name, md5_file)

        if tcfg_files_changed:
            env.PrintInfo("Target Config files have changed.  Reparsing")
            clean_all_products(env, build_id.lower())

        if not check_bid_products(env, build_id.lower()):
            # Build new target config product files as needed.
            env.PrintInfo("Generating Target Config Files for " + build_id)
            # Read the PL from the environment variable
            pl = None
            if 'PRODUCT_LINE' in env:
                pl = env['PRODUCT_LINE']
            # Change directory to the build\ms directory for the parser to work
            saved_dir = os.getcwd()
            os.chdir(TARGET_CONFIG_PATH)
            import tcfgparser
            tcfg = tcfgparser.TargetConfigurationDb()
            tcfg_search_paths = [env.subst(path).rsplit('/', 1)[0] + '/' \
                                 for path in BLD_SCRIPT_NAME_TEMPLATES]
            gen_result = tcfg.ParseBuildFile(buildsfile_name,
                                             pl,
                                             search_paths=tcfg_search_paths)
            if gen_result:
                tcfg_bid_data = tcfg.GenConfigData(build_id, pl)
                if tcfg_bid_data:
                    WriteTcfgBidData(env, tcfg_bid_data, build_id)
                else:
                    gen_result = False
            # Restore the saved directory
            os.chdir(saved_dir)

    # Header files should already be generated, but we need to read
    # in the pickled tcfg_bid_data.
    ReadTcfgBidData(env, build_id)

    # Load Target Config SCons Tools
    for template in TBC_SCRIPT_NAME_TEMPLATES:
        for tool_name in glob.glob(env.subst(template)):
            tool_dir = os.path.dirname(tool_name)
            tool_name = os.path.basename(tool_name)[0:-3]  # drop the ".py"
            env.LoadToolScript(tool_name, toolpath=[tool_dir])

    env.PrintInfo("End Target Config: " + build_id)

    if env.PathExists(buildsfile_name):
        ret_val = gen_result and check_bid_products(env, build_id.lower())
    else:
        ret_val = gen_result

    return ret_val