def METHOD_NAME(argv, log=False):
  """Call nvcc with arguments assembled from argv.
  Args:
    argv: A list of strings, possibly the argv passed to main().
    log: True if logging is requested.
  Returns:
    The return value of calling os.system('nvcc ' + args)
  """
  src_files = [f for f in argv if
               re.search('\.cpp$|\.cc$|\.c$|\.cxx$|\.C$', f)]
  if len(src_files) == 0:
    raise Error('No source files found for cuda compilation.')
  out_file = [ f for f in argv if f.startswith('/Fo') ]
  if len(out_file) != 1:
    raise Error('Please sepecify exactly one output file for cuda compilation.')
  out = ['-o', out_file[0][len('/Fo'):]]
  nvcc_compiler_options, argv = GetNvccOptions(argv)
  opt_option, argv = GetOptionValue(argv, 'O')
  opt = ['-g', '-G']
  if (len(opt_option) > 0 and opt_option[0] != 'd'):
    opt = ['-O2']
  include_options, argv = GetOptionValue(argv, 'I')
  includes = ["-I " + include for include in include_options]
  defines, argv = GetOptionValue(argv, 'D')
  defines = ['-D' + define for define in defines]
  undefines, argv = GetOptionValue(argv, 'U')
  undefines = ['-U' + define for define in undefines]
  # The rest of the unrecongized options should be passed to host compiler
  host_compiler_options = [option for option in argv if option not in (src_files + out_file)]
  m_options = ["-m64"]
  nvccopts = ['-D_FORCE_INLINES']
  for capability in supported_cuda_compute_capabilities:
    capability = capability.replace('.', '')
    nvccopts += [r'-gencode=arch=compute_%s,"code=sm_%s,compute_%s"' % (
        capability, capability, capability)]
  nvccopts += nvcc_compiler_options
  nvccopts += undefines
  nvccopts += defines
  nvccopts += m_options
  nvccopts += ['--compiler-options="' + " ".join(host_compiler_options) + '"']
  nvccopts += ['-x', 'cu'] + opt + includes + out + ['-c'] + src_files
  # If we don't specify --keep-dir, nvcc will generate intermediate files under TEMP
  # Put them under NVCC_TEMP_DIR instead, then Bazel can ignore files under NVCC_TEMP_DIR during dependency check
  # http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#options-for-guiding-compiler-driver
  # Different actions are sharing NVCC_TEMP_DIR, so we cannot remove it if the directory already exists.
  if os.path.isfile(NVCC_TEMP_DIR):
    os.remove(NVCC_TEMP_DIR)
  if not os.path.exists(NVCC_TEMP_DIR):
    os.makedirs(NVCC_TEMP_DIR)
  nvccopts += ['--keep', '--keep-dir', NVCC_TEMP_DIR]
  cmd = [NVCC_PATH] + nvccopts
  if log:
    Log(cmd)
  proc = subprocess.Popen(cmd,
                          stdout=sys.stdout,
                          stderr=sys.stderr,
                          env=os.environ.copy(),
                          shell=True)
  proc.wait()
  return proc.returncode