parameters: (ctx, kw)
docstring: Helper function to apply default configurations and to set platform/configuration dependent settings
docstring_summary: Helper function to apply default configurations and to set platform/configuration dependent settings
docstring_tokens: Helper function to apply default configurations and to set platform / configuration dependent settings
function: def ConfigureTaskGenerator(ctx, kw):
      """
      Helper function to apply default configurations and to set platform/configuration dependent settings
      """
  
      target = kw['target']
  
      # Ensure we have a name for lookup purposes
      if 'name' not in kw:
          kw['name'] = target
  
      # Retrieve any platform roots or Gem module platform roots
      is_gem_module_platform_root = False
      platform_roots = kw.get('platform_roots', [])
      if not platform_roots:
          platform_roots = kw.get('platform_gem_module_roots', [])
          if platform_roots:
              is_gem_module_platform_root = True
              if not kw.get('is_gem', False):
                  raise Errors.WafError("Invalid use of 'platform_gem_module_roots' on non-gem target '{}'. Use 'platform_roots' instead".format(target))
  
      # Process any platform roots
      if platform_roots:
          if not isinstance(platform_roots, list):
              platform_roots = [platform_roots]
          for platform_root_param in platform_roots:
              if not isinstance(platform_root_param,dict):
                  raise Errors.WafError("Invalid keyword value for 'platform_roots' for target '{}'. Expecting a list of "
                                        "dictionary entries for 'root' (path) and 'export_includes' (boolean)".format(target))
              platform_root = platform_root_param['root']
              export_platform_includes = platform_root_param['export_includes']
              ctx.add_platform_root(kw=kw,
                                    root=platform_root,
                                    export=export_platform_includes,
                                    is_gem_module_platform_root=is_gem_module_platform_root)
  
      # Deal with restricted platforms
      ctx.process_restricted_settings(kw)
  
      # Determine if this is a build command (vs a platform generator)
      is_configure_cmd = isinstance(ctx, ConfigurationContext)
      is_build_platform_cmd = getattr(ctx, 'is_build_cmd', False)
  
  
      # Lookup the PlatformConfiguration for the current platform/configuration (if this is a build command)
      current_platform_configuration = None
      target_platform = []
      target_configuration = []
  
      if is_build_platform_cmd:
  
          target_platform = ctx.target_platform
          target_configuration = ctx.target_configuration
          current_platform_configuration = ctx.get_platform_configuration(target_platform, target_configuration)
  
          # Provide the module name to the test framework.
          if current_platform_configuration.is_test and not ctx.is_mac_platform(target_platform) and not ctx.is_linux_platform(target_platform) and not ctx.is_android_platform(target_platform):
              module_define = 'AZ_MODULE_NAME="{}"'.format(target.upper())
              append_kw_entry(kw, 'defines', module_define)
  
          # If this is a linux target, then add 'linux_rpath' to the kw
          if ctx.is_linux_platform(target_platform):
              append_to_unique_list(kw.setdefault('linux_rpath', []), '$ORIGIN')
  
      # Special case:  Only non-android launchers can use required gems
      apply_required_gems = kw.get('use_required_gems', False)
      if kw.get('is_launcher', False):
          if apply_required_gems and not ctx.is_android_platform(target_platform):
              ctx.apply_required_gems_to_context(target, kw)
      else:
          if apply_required_gems:
              ctx.apply_required_gems_to_context(target, kw)
  
      # Apply all settings, based on current platform and configuration
      ApplyConfigOverwrite(ctx, kw)
  
      ApplyPlatformSpecificSettings(ctx, kw, target)
      ApplyBuildOptionSettings(ctx, kw)
  
      platform = ctx.env['PLATFORM']
  
      is_engine_project = ctx.path.is_child_of(ctx.engine_node)
  
      # Load all file lists (including additional settings)
      file_list = kw['file_list']
      for setting in kw['additional_settings']:
          file_list += setting.get('file_list', [])
          file_list += ctx.GetPlatformSpecificSettings(setting, 'file_list', platform, get_configuration(ctx, kw['target']) )
      # Load all configuration specific files when generating projects
      if platform == 'project_generator':
          for configuration in ctx.get_all_configuration_names():
              file_list += ctx.GetPlatformSpecificSettings(kw, 'file_list', platform, configuration)
          for alias in LUMBERYARD_SETTINGS.get_configuration_aliases():
              file_list += ctx.GetPlatformSpecificSettings(kw, 'file_list', platform, alias)
  
      LoadFileLists(ctx, kw, file_list)
      LoadAdditionalFileSettings(ctx, kw)
  
      # If uselib is set, validate them
      uselib_names = kw.get('uselib', None)
      if uselib_names is not None:
          processed_dependencies = []
          for uselib_name in uselib_names:
              if not is_third_party_uselib_configured(ctx, uselib_name):
                  Logs.warn("[WARN] Invalid uselib '{}' declared in project {}.  This may cause compilation or linker errors".format(uselib_name,target))
              else:
                  if not uselib_name in processed_dependencies and not uselib_name in kw.get('no_inherit_config', []):
                      ctx.append_dependency_configuration_settings(uselib_name, kw)
                      processed_dependencies.append(uselib_name)
  
      # Make sure we have a 'use' list
      if not kw.get('use', None):
          kw['use'] = []
  
      if platform != 'project_generator':
          # Check if we are applying external file copies
          if 'copy_external' in kw and len(kw['copy_external'])>0:
              for copy_external_key in kw['copy_external']:
                  copy_external_env_key = 'COPY_EXTERNAL_FILES_{}'.format(copy_external_key)
                  if 'COPY_EXTERNAL_FILES' not in ctx.env:
                      ctx.env['COPY_EXTERNAL_FILES'] = []
                  append_kw_entry(kw,'features','copy_external_files')
                  if copy_external_env_key in ctx.env:
                      for copy_external_value in ctx.env[copy_external_env_key]:
                          ctx.env['COPY_EXTERNAL_FILES'].append(copy_external_value)
  
          # Check if we are applying external file copies to specific files
          copy_dependent_files = kw.get('copy_dependent_files',[])
          if len(copy_dependent_files)>0:
              append_kw_entry(kw,'features','copy_module_dependent_files')
              copy_dependent_env_key = 'COPY_DEPENDENT_FILES_{}'.format(target.upper())
              if copy_dependent_env_key not in ctx.env:
                  ctx.env[copy_dependent_env_key] = []
              for copy_dependent_file in copy_dependent_files:
                  if is_engine_project:
                      copy_dependent_file_abs = os.path.normpath(os.path.join(ctx.engine_path,copy_dependent_file))
                  else:
                      copy_dependent_file_abs = os.path.normpath(os.path.join(ctx.path.abspath(),copy_dependent_file))
                  ctx.env[copy_dependent_env_key].append(copy_dependent_file_abs)
  
      if ctx.is_windows_platform(platform):
          # Handle meta includes for WinRT
          for meta_include in kw.get('meta_includes', []):
              append_kw_entry(kw,'cxxflags',[ '/AI' + meta_include ])
  
      # Handle export definitions file
      append_kw_entry(kw,'linkflags',[ '/DEF:' + ctx.path.make_node( export_file ).abspath() for export_file in kw['export_definitions']])
  
      # Handle Spec unique defines (if one is provided)
      if ctx.is_project_spec_specified():
          append_kw_entry(kw, 'defines', ctx.get_current_spec_defines())
  
      # Generate output file name (without file ending), use target as an default if nothing is specified
      if kw['output_file_name'] == []:
          kw['output_file_name'] = kw['target']
      elif isinstance(kw['output_file_name'],list):
          kw['output_file_name'] = kw['output_file_name'][0] # Change list into a single string
  
      # Handle force_disable_mfc (Small Hack for Perforce Plugin (no MFC, needs to be better defined))
      if kw.get('force_disable_mfc', False) and '_AFXDLL' in kw['defines']:
          kw['defines'].remove('_AFXDLL')
  
      # Clean out some duplicate kw values to reduce the size for the hash calculation
      kw['defines'] = clean_duplicates_in_list(kw['defines'],'{} : defines'.format(target))
  
      # Apply the default copyright_org if none is specified
      if len(kw['copyright_org'])==0:
          kw['copyright_org'] = ['Amazon']
  
      if ctx.is_build_monolithic():
          append_kw_entry(kw, 'defines', ['_LIB', 'AZ_MONOLITHIC_BUILD'])
          
      if kw.get('inject_copyright', True):
          append_kw_entry(kw,'features',[ 'generate_rc_file' ])
function_tokens: def ConfigureTaskGenerator ( ctx , kw ) : target = kw [ 'target' ] # Ensure we have a name for lookup purposes if 'name' not in kw : kw [ 'name' ] = target # Retrieve any platform roots or Gem module platform roots is_gem_module_platform_root = False platform_roots = kw . get ( 'platform_roots' , [ ] ) if not platform_roots : platform_roots = kw . get ( 'platform_gem_module_roots' , [ ] ) if platform_roots : is_gem_module_platform_root = True if not kw . get ( 'is_gem' , False ) : raise Errors . WafError ( "Invalid use of 'platform_gem_module_roots' on non-gem target '{}'. Use 'platform_roots' instead" . format ( target ) ) # Process any platform roots if platform_roots : if not isinstance ( platform_roots , list ) : platform_roots = [ platform_roots ] for platform_root_param in platform_roots : if not isinstance ( platform_root_param , dict ) : raise Errors . WafError ( "Invalid keyword value for 'platform_roots' for target '{}'. Expecting a list of " "dictionary entries for 'root' (path) and 'export_includes' (boolean)" . format ( target ) ) platform_root = platform_root_param [ 'root' ] export_platform_includes = platform_root_param [ 'export_includes' ] ctx . add_platform_root ( kw = kw , root = platform_root , export = export_platform_includes , is_gem_module_platform_root = is_gem_module_platform_root ) # Deal with restricted platforms ctx . process_restricted_settings ( kw ) # Determine if this is a build command (vs a platform generator) is_configure_cmd = isinstance ( ctx , ConfigurationContext ) is_build_platform_cmd = getattr ( ctx , 'is_build_cmd' , False ) # Lookup the PlatformConfiguration for the current platform/configuration (if this is a build command) current_platform_configuration = None target_platform = [ ] target_configuration = [ ] if is_build_platform_cmd : target_platform = ctx . target_platform target_configuration = ctx . target_configuration current_platform_configuration = ctx . get_platform_configuration ( target_platform , target_configuration ) # Provide the module name to the test framework. if current_platform_configuration . is_test and not ctx . is_mac_platform ( target_platform ) and not ctx . is_linux_platform ( target_platform ) and not ctx . is_android_platform ( target_platform ) : module_define = 'AZ_MODULE_NAME="{}"' . format ( target . upper ( ) ) append_kw_entry ( kw , 'defines' , module_define ) # If this is a linux target, then add 'linux_rpath' to the kw if ctx . is_linux_platform ( target_platform ) : append_to_unique_list ( kw . setdefault ( 'linux_rpath' , [ ] ) , '$ORIGIN' ) # Special case:  Only non-android launchers can use required gems apply_required_gems = kw . get ( 'use_required_gems' , False ) if kw . get ( 'is_launcher' , False ) : if apply_required_gems and not ctx . is_android_platform ( target_platform ) : ctx . apply_required_gems_to_context ( target , kw ) else : if apply_required_gems : ctx . apply_required_gems_to_context ( target , kw ) # Apply all settings, based on current platform and configuration ApplyConfigOverwrite ( ctx , kw ) ApplyPlatformSpecificSettings ( ctx , kw , target ) ApplyBuildOptionSettings ( ctx , kw ) platform = ctx . env [ 'PLATFORM' ] is_engine_project = ctx . path . is_child_of ( ctx . engine_node ) # Load all file lists (including additional settings) file_list = kw [ 'file_list' ] for setting in kw [ 'additional_settings' ] : file_list += setting . get ( 'file_list' , [ ] ) file_list += ctx . GetPlatformSpecificSettings ( setting , 'file_list' , platform , get_configuration ( ctx , kw [ 'target' ] ) ) # Load all configuration specific files when generating projects if platform == 'project_generator' : for configuration in ctx . get_all_configuration_names ( ) : file_list += ctx . GetPlatformSpecificSettings ( kw , 'file_list' , platform , configuration ) for alias in LUMBERYARD_SETTINGS . get_configuration_aliases ( ) : file_list += ctx . GetPlatformSpecificSettings ( kw , 'file_list' , platform , alias ) LoadFileLists ( ctx , kw , file_list ) LoadAdditionalFileSettings ( ctx , kw ) # If uselib is set, validate them uselib_names = kw . get ( 'uselib' , None ) if uselib_names is not None : processed_dependencies = [ ] for uselib_name in uselib_names : if not is_third_party_uselib_configured ( ctx , uselib_name ) : Logs . warn ( "[WARN] Invalid uselib '{}' declared in project {}.  This may cause compilation or linker errors" . format ( uselib_name , target ) ) else : if not uselib_name in processed_dependencies and not uselib_name in kw . get ( 'no_inherit_config' , [ ] ) : ctx . append_dependency_configuration_settings ( uselib_name , kw ) processed_dependencies . append ( uselib_name ) # Make sure we have a 'use' list if not kw . get ( 'use' , None ) : kw [ 'use' ] = [ ] if platform != 'project_generator' : # Check if we are applying external file copies if 'copy_external' in kw and len ( kw [ 'copy_external' ] ) > 0 : for copy_external_key in kw [ 'copy_external' ] : copy_external_env_key = 'COPY_EXTERNAL_FILES_{}' . format ( copy_external_key ) if 'COPY_EXTERNAL_FILES' not in ctx . env : ctx . env [ 'COPY_EXTERNAL_FILES' ] = [ ] append_kw_entry ( kw , 'features' , 'copy_external_files' ) if copy_external_env_key in ctx . env : for copy_external_value in ctx . env [ copy_external_env_key ] : ctx . env [ 'COPY_EXTERNAL_FILES' ] . append ( copy_external_value ) # Check if we are applying external file copies to specific files copy_dependent_files = kw . get ( 'copy_dependent_files' , [ ] ) if len ( copy_dependent_files ) > 0 : append_kw_entry ( kw , 'features' , 'copy_module_dependent_files' ) copy_dependent_env_key = 'COPY_DEPENDENT_FILES_{}' . format ( target . upper ( ) ) if copy_dependent_env_key not in ctx . env : ctx . env [ copy_dependent_env_key ] = [ ] for copy_dependent_file in copy_dependent_files : if is_engine_project : copy_dependent_file_abs = os . path . normpath ( os . path . join ( ctx . engine_path , copy_dependent_file ) ) else : copy_dependent_file_abs = os . path . normpath ( os . path . join ( ctx . path . abspath ( ) , copy_dependent_file ) ) ctx . env [ copy_dependent_env_key ] . append ( copy_dependent_file_abs ) if ctx . is_windows_platform ( platform ) : # Handle meta includes for WinRT for meta_include in kw . get ( 'meta_includes' , [ ] ) : append_kw_entry ( kw , 'cxxflags' , [ '/AI' + meta_include ] ) # Handle export definitions file append_kw_entry ( kw , 'linkflags' , [ '/DEF:' + ctx . path . make_node ( export_file ) . abspath ( ) for export_file in kw [ 'export_definitions' ] ] ) # Handle Spec unique defines (if one is provided) if ctx . is_project_spec_specified ( ) : append_kw_entry ( kw , 'defines' , ctx . get_current_spec_defines ( ) ) # Generate output file name (without file ending), use target as an default if nothing is specified if kw [ 'output_file_name' ] == [ ] : kw [ 'output_file_name' ] = kw [ 'target' ] elif isinstance ( kw [ 'output_file_name' ] , list ) : kw [ 'output_file_name' ] = kw [ 'output_file_name' ] [ 0 ] # Change list into a single string # Handle force_disable_mfc (Small Hack for Perforce Plugin (no MFC, needs to be better defined)) if kw . get ( 'force_disable_mfc' , False ) and '_AFXDLL' in kw [ 'defines' ] : kw [ 'defines' ] . remove ( '_AFXDLL' ) # Clean out some duplicate kw values to reduce the size for the hash calculation kw [ 'defines' ] = clean_duplicates_in_list ( kw [ 'defines' ] , '{} : defines' . format ( target ) ) # Apply the default copyright_org if none is specified if len ( kw [ 'copyright_org' ] ) == 0 : kw [ 'copyright_org' ] = [ 'Amazon' ] if ctx . is_build_monolithic ( ) : append_kw_entry ( kw , 'defines' , [ '_LIB' , 'AZ_MONOLITHIC_BUILD' ] ) if kw . get ( 'inject_copyright' , True ) : append_kw_entry ( kw , 'features' , [ 'generate_rc_file' ] )