def ConcatSourcePseudoBuilder(env, target, source):
  """ConcatSource pseudo-builder; calls builder or passes through source nodes.

  Args:
    env: Environment in which to build
    target: List of target nodes
    source: List of source nodes

  Returns:
    If env['CONCAT_SOURCE_ENABLE'], calls env.ConcatSource and returns
    the list of target nodes.  Otherwise, returns the list of source nodes.
    Source nodes which are not CPP files are passed through unchanged to the
    list of output nodes.
  """
  if env.get('CONCAT_SOURCE_ENABLE', True):
    # Scan down source list and separate CPP sources (which we concatenate)
    # from other files (which we pass through).
    cppsource = []
    outputs = []
    suffixes = env.Flatten(env.subst_list('$CONCAT_SOURCE_SUFFIXES'))
    for source_file in env.arg2nodes(source):
      if source_file.suffix in suffixes:
        cppsource.append(source_file)
      else:
        outputs.append(source_file)

    if len(cppsource) > 1:
      # More than one file, so concatenate them together
      outputs += env.ConcatSourceBuilder(target, cppsource)
    else:
      # <2 files, so pass them through; no need for a ConcatSource target
      outputs += cppsource
    return outputs
  else:
    # ConcatSource is disabled, so pass through the list of source nodes.
    return source