Bug 1429015 - Add clang-format-diff to the clang-tidy build generated by toolchains. r?sylvestre draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Tue, 09 Jan 2018 13:27:39 +0200
changeset 717740 baf1ca916aae6e7aec6c68b01e9c5d9d4f07d85e
parent 717738 6f5fac320fcb6625603fa8a744ffa8523f8b3d71
child 745323 cae5a8b5fb2dbdf098fdc5623967e9e07f44bafd
push id94753
push userbmo:bpostelnicu@mozilla.com
push dateTue, 09 Jan 2018 11:28:02 +0000
reviewerssylvestre
bugs1429015
milestone59.0a1
Bug 1429015 - Add clang-format-diff to the clang-tidy build generated by toolchains. r?sylvestre MozReview-Commit-ID: FjJqef78wa3
build/build-clang/build-clang.py
--- a/build/build-clang/build-clang.py
+++ b/build/build-clang/build-clang.py
@@ -247,34 +247,37 @@ def get_tool(config, key):
     # Assume that we have the name of some program that should be on PATH.
     try:
         return which.which(f) if f else which.which(key)
     except which.WhichError:
         raise ValueError("%s not found on PATH" % f)
 
 
 # This function is intended to be called on the final build directory when
-# building clang-tidy.  Its job is to remove all of the files which won't
-# be used for clang-tidy to reduce the download size.  Currently when this
-# function finishes its job, it will leave final_dir with a layout like this:
+# building clang-tidy. Also clang-format binaries are included that can be used
+# in conjunction with clang-tidy.
+# Its job is to remove all of the files which won't be used for clang-tidy or
+# clang-format to reduce the download size.  Currently when this function
+# finishes its job, it will leave final_dir with a layout like this:
 #
 # clang/
 #   bin/
 #     clang-apply-replacements
 #     clang-format
 #     clang-tidy
 #   include/
 #     * (nothing will be deleted here)
 #   lib/
 #     clang/
 #       4.0.0/
 #         include/
 #           * (nothing will be deleted here)
 #   share/
 #     clang/
+#       clang-format-diff.py
 #       clang-tidy-diff.py
 #       run-clang-tidy.py
 def prune_final_dir_for_clang_tidy(final_dir):
     # Make sure we only have what we expect.
     dirs = ("bin", "include", "lib", "libexec", "msbuild-bin", "share", "tools")
     for f in glob.glob("%s/*" % final_dir):
         if os.path.basename(f) not in dirs:
             raise Exception("Found unknown file %s in the final directory" % f)
@@ -306,17 +309,17 @@ def prune_final_dir_for_clang_tidy(final
     # Completely remove libexec/, msbuilld-bin and tools, if it exists.
     shutil.rmtree(os.path.join(final_dir, "libexec"))
     for d in ("msbuild-bin", "tools"):
         d = os.path.join(final_dir, d)
         if os.path.exists(d):
             shutil.rmtree(d)
 
     # In share/, only keep share/clang/*tidy*
-    re_clang_tidy = re.compile(r"tidy", re.I)
+    re_clang_tidy = re.compile(r"format|tidy", re.I)
     for f in glob.glob("%s/share/*" % final_dir):
         if os.path.basename(f) != "clang":
             delete(f)
     for f in glob.glob("%s/share/clang/*" % final_dir):
         if re_clang_tidy.search(os.path.basename(f)) is None:
             delete(f)