parameters: (target_name, actions, extra_sources, extra_deps,
                   path_to_gyp, output)
docstring: Write CMake for the 'actions' in the target.
  
    Args:
      target_name: the name of the CMake target being generated.
      actions: the Gyp 'actions' dict for this target.
      extra_sources: [(<cmake_src>, <src>)] to append with generated source files.
      extra_deps: [<cmake_taget>] to append with generated targets.
      path_to_gyp: relative path from CMakeLists.txt being generated to
          the Gyp file in which the target being generated is defined.
docstring_summary: Write CMake for the 'actions' in the target.
docstring_tokens: Write CMake for the actions in the target .
function: def WriteActions(target_name, actions, extra_sources, extra_deps,
                   path_to_gyp, output):
    """Write CMake for the 'actions' in the target.
  
    Args:
      target_name: the name of the CMake target being generated.
      actions: the Gyp 'actions' dict for this target.
      extra_sources: [(<cmake_src>, <src>)] to append with generated source files.
      extra_deps: [<cmake_taget>] to append with generated targets.
      path_to_gyp: relative path from CMakeLists.txt being generated to
          the Gyp file in which the target being generated is defined.
    """
    for action in actions:
      action_name = StringToCMakeTargetName(action['action_name'])
      action_target_name = '%s__%s' % (target_name, action_name)
  
      inputs = action['inputs']
      inputs_name = action_target_name + '__input'
      SetVariableList(output, inputs_name,
          [NormjoinPathForceCMakeSource(path_to_gyp, dep) for dep in inputs])
  
      outputs = action['outputs']
      cmake_outputs = [NormjoinPathForceCMakeSource(path_to_gyp, out)
                       for out in outputs]
      outputs_name = action_target_name + '__output'
      SetVariableList(output, outputs_name, cmake_outputs)
  
      # Build up a list of outputs.
      # Collect the output dirs we'll need.
      dirs = set(dir for dir in (os.path.dirname(o) for o in outputs) if dir)
  
      if int(action.get('process_outputs_as_sources', False)):
        extra_sources.extend(zip(cmake_outputs, outputs))
  
      # add_custom_command
      output.write('add_custom_command(OUTPUT ')
      WriteVariable(output, outputs_name)
      output.write('\n')
  
      if len(dirs) > 0:
        for directory in dirs:
          output.write('  COMMAND ${CMAKE_COMMAND} -E make_directory ')
          output.write(directory)
          output.write('\n')
  
      output.write('  COMMAND ')
      output.write(gyp.common.EncodePOSIXShellList(action['action']))
      output.write('\n')
  
      output.write('  DEPENDS ')
      WriteVariable(output, inputs_name)
      output.write('\n')
  
      output.write('  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/')
      output.write(path_to_gyp)
      output.write('\n')
  
      output.write('  COMMENT ')
      if 'message' in action:
        output.write(action['message'])
      else:
        output.write(action_target_name)
      output.write('\n')
  
      output.write('  VERBATIM\n')
      output.write(')\n')
  
      # add_custom_target
      output.write('add_custom_target(')
      output.write(action_target_name)
      output.write('\n  DEPENDS ')
      WriteVariable(output, outputs_name)
      output.write('\n  SOURCES ')
      WriteVariable(output, inputs_name)
      output.write('\n)\n')
  
      extra_deps.append(action_target_name)
function_tokens: def WriteActions ( target_name , actions , extra_sources , extra_deps , path_to_gyp , output ) : for action in actions : action_name = StringToCMakeTargetName ( action [ 'action_name' ] ) action_target_name = '%s__%s' % ( target_name , action_name ) inputs = action [ 'inputs' ] inputs_name = action_target_name + '__input' SetVariableList ( output , inputs_name , [ NormjoinPathForceCMakeSource ( path_to_gyp , dep ) for dep in inputs ] ) outputs = action [ 'outputs' ] cmake_outputs = [ NormjoinPathForceCMakeSource ( path_to_gyp , out ) for out in outputs ] outputs_name = action_target_name + '__output' SetVariableList ( output , outputs_name , cmake_outputs ) # Build up a list of outputs. # Collect the output dirs we'll need. dirs = set ( dir for dir in ( os . path . dirname ( o ) for o in outputs ) if dir ) if int ( action . get ( 'process_outputs_as_sources' , False ) ) : extra_sources . extend ( zip ( cmake_outputs , outputs ) ) # add_custom_command output . write ( 'add_custom_command(OUTPUT ' ) WriteVariable ( output , outputs_name ) output . write ( '\n' ) if len ( dirs ) > 0 : for directory in dirs : output . write ( '  COMMAND ${CMAKE_COMMAND} -E make_directory ' ) output . write ( directory ) output . write ( '\n' ) output . write ( '  COMMAND ' ) output . write ( gyp . common . EncodePOSIXShellList ( action [ 'action' ] ) ) output . write ( '\n' ) output . write ( '  DEPENDS ' ) WriteVariable ( output , inputs_name ) output . write ( '\n' ) output . write ( '  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/' ) output . write ( path_to_gyp ) output . write ( '\n' ) output . write ( '  COMMENT ' ) if 'message' in action : output . write ( action [ 'message' ] ) else : output . write ( action_target_name ) output . write ( '\n' ) output . write ( '  VERBATIM\n' ) output . write ( ')\n' ) # add_custom_target output . write ( 'add_custom_target(' ) output . write ( action_target_name ) output . write ( '\n  DEPENDS ' ) WriteVariable ( output , outputs_name ) output . write ( '\n  SOURCES ' ) WriteVariable ( output , inputs_name ) output . write ( '\n)\n' ) extra_deps . append ( action_target_name )