(spec, actions_to_add)
return actions_spec, sources_handled_by_action
Add actions accumulated into an actions_to_add, merging as needed.

  Arguments:
    spec: the target project dict
    actions_to_add: dictionary keyed on input name, which maps to a list of
        dicts describing the actions attached to that input file.

  Returns:
    A pair of (action specification, the sources handled by this action).
Add actions accumulated into an actions_to_add, merging as needed.
Add actions accumulated into an actions_to_add merging as needed .
def _GenerateActionsForMSBuild(spec, actions_to_add):
  """Add actions accumulated into an actions_to_add, merging as needed.

  Arguments:
    spec: the target project dict
    actions_to_add: dictionary keyed on input name, which maps to a list of
        dicts describing the actions attached to that input file.

  Returns:
    A pair of (action specification, the sources handled by this action).
  """
  sources_handled_by_action = OrderedSet()
  actions_spec = []
  for primary_input, actions in actions_to_add.iteritems():
    inputs = OrderedSet()
    outputs = OrderedSet()
    descriptions = []
    commands = []
    for action in actions:
      inputs.update(OrderedSet(action['inputs']))
      outputs.update(OrderedSet(action['outputs']))
      descriptions.append(action['description'])
      cmd = action['command']
      # For most actions, add 'call' so that actions that invoke batch files
      # return and continue executing.  msbuild_use_call provides a way to
      # disable this but I have not seen any adverse effect from doing that
      # for everything.
      if action.get('msbuild_use_call', True):
        cmd = 'call ' + cmd
      commands.append(cmd)
    # Add the custom build action for one input file.
    description = ', and also '.join(descriptions)

    # We can't join the commands simply with && because the command line will
    # get too long. See also _AddActions: cygwin's setup_env mustn't be called
    # for every invocation or the command that sets the PATH will grow too
    # long.
    command = '\r\n'.join([c + '\r\nif %errorlevel% neq 0 exit /b %errorlevel%'
                           for c in commands])
    _AddMSBuildAction(spec,
                      primary_input,
                      inputs,
                      outputs,
                      command,
                      description,
                      sources_handled_by_action,
                      actions_spec)
  return actions_spec, sources_handled_by_action
def _GenerateActionsForMSBuild ( spec , actions_to_add ) : sources_handled_by_action = OrderedSet ( ) actions_spec = [ ] for primary_input , actions in actions_to_add . iteritems ( ) : inputs = OrderedSet ( ) outputs = OrderedSet ( ) descriptions = [ ] commands = [ ] for action in actions : inputs . update ( OrderedSet ( action [ 'inputs' ] ) ) outputs . update ( OrderedSet ( action [ 'outputs' ] ) ) descriptions . append ( action [ 'description' ] ) cmd = action [ 'command' ] # For most actions, add 'call' so that actions that invoke batch files # return and continue executing.  msbuild_use_call provides a way to # disable this but I have not seen any adverse effect from doing that # for everything. if action . get ( 'msbuild_use_call' , True ) : cmd = 'call ' + cmd commands . append ( cmd ) # Add the custom build action for one input file. description = ', and also ' . join ( descriptions ) # We can't join the commands simply with && because the command line will # get too long. See also _AddActions: cygwin's setup_env mustn't be called # for every invocation or the command that sets the PATH will grow too # long. command = '\r\n' . join ( [ c + '\r\nif %errorlevel% neq 0 exit /b %errorlevel%' for c in commands ] ) _AddMSBuildAction ( spec , primary_input , inputs , outputs , command , description , sources_handled_by_action , actions_spec ) return actions_spec , sources_handled_by_action