示例#1
0
def findClangFormat():
	"""Tries to find clang-format-XXX variants within the path"""
	allowed = ["clang-format" + x for x in ["-8"]]
	for candidate in allowed:
		if not shutil.which(candidate) is None:
			if nkt.isVerbose():
				version = str(subprocess.check_output([candidate, "--version"], universal_newlines=True)).strip()
				print("clang-format: %s\n -> Version: %s" % (candidate, version))

			return candidate

	raise "clang-format binary not found. We searched for:\n " + "\n ".join(allowed)
示例#2
0
def findClangFormat():
	"""Tries to find clang-format-XXX variants within the path"""
	cmd = "clang-format"
	allowed = [cmd] + [cmd + "-" + str(x) for x in range(nkt.MIN_CLANG_FORMAT_VERSION, nkt.MAX_CLANG_FORMAT_VERSION + 1)]
	for candidate in allowed:
		if isSupported(candidate):
			if nkt.isVerbose():
				version = str(subprocess.check_output([candidate, "--version"],
					universal_newlines=True, env=getEnv())).strip()
				print("clang-format: %s\n -> Version: %s" % (candidate, version))

			return candidate

	raise FileNotFoundError("clang-format binary not found. We searched for:\n " + "\n ".join(allowed))