def _tmp_file(ctx, file_suffix, lines):
  """Creates a file named after the ctx label containing lines.

  Args:
    ctx: The skylark rule context.
    file_suffix: The suffix to append to the ctx label for the file name.
    lines: A list of strings to be joined by newlines as the file content.

  Returns:
    The File which was created.

    See [File documentation](https://goo.gl/fYvlcT) for more information.
  """
  tmp_file = ctx.new_file(ctx.configuration.bin_dir,
                          "%s_%s" % (ctx.label.name, file_suffix))
  ctx.file_action(output=tmp_file, content="\n".join(lines))
  return tmp_file