[libc-commits] [PATCH] D76978: [libc builder] Add custom step to run clang-tidy.

Paula Toth via Phabricator via libc-commits libc-commits at lists.llvm.org
Sat Mar 28 01:35:35 PDT 2020


PaulkaToast created this revision.
PaulkaToast added a reviewer: sivachandra.
PaulkaToast added projects: libc-project, Zorg.
PaulkaToast edited the summary of this revision.

By running this on the buildbot, we ensure that clang-tidy rules are being enforced without having to burden developers with building all of clang.


Repository:
  rZORG LLVM Github Zorg

https://reviews.llvm.org/D76978

Files:
  zorg/buildbot/builders/annotated/libc-linux.py


Index: zorg/buildbot/builders/annotated/libc-linux.py
===================================================================
--- zorg/buildbot/builders/annotated/libc-linux.py
+++ zorg/buildbot/builders/annotated/libc-linux.py
@@ -14,24 +14,36 @@
     ap.add_argument('--asan', action='store_true', default=False)
     args = ap.parse_args(argv[1:])
 
-    extra_cmake_args = ['-DCMAKE_BUILD_TYPE=Debug']
-    if args.asan:
-        extra_cmake_args.append('-DLLVM_USE_SANITIZER=Address')
+    source_dir = os.path.join('..', 'llvm-project')
 
-    projects = ['llvm', 'libc']
-    check_targets = ['check-libc']
+    # Cmake step
+    with step('cmake'):
+        projects = ['llvm', 'libc', 'clang', 'clang-tools-extra']
 
-    builder = annotated_builder.AnnotatedBuilder()
-    builder.run_steps(projects=projects,
-                      check_targets=check_targets,
-                      extra_cmake_args=extra_cmake_args)
+        cmake_args = ['-GNinja', '-DCMAKE_BUILD_TYPE=Debug']
+        if args.asan:
+            cmake_args.append('-DLLVM_USE_SANITIZER=Address')
+        cmake_args.append('-DLLVM_ENABLE_PROJECTS={}'.format(';'.join(projects)))
+
+        run_command(['cmake', os.path.join(source_dir, 'llvm')] + cmake_args)
+
+    # Build and test step
+    with step('ninja: build and check'):
+        run_command(['ninja', 'check-libc'])
 
     # AOR tests step
     if not args.asan:
         with step('AOR Tests'):
-            aor_dir = os.path.join('..', 'llvm-project', 'libc', 'AOR_v20.02')
+            aor_dir = os.path.join(source_dir, 'libc', 'AOR_v20.02')
             run_command(['make', 'check'], directory=aor_dir)
 
+    # Clang-tidy step
+    with step('build clang-tidy'):
+        run_command(['ninja', 'clang-tidy'])
+    with step('run clang-tidy'):
+        tidy_glob = os.path.join(source_dir,'libc', 'src', '**', '**.cpp')
+        run_command('bin/clang-tidy ' + tidy_glob, shell=True)
+
 
 @contextmanager
 def step(step_name, halt_on_fail=True):
@@ -52,8 +64,8 @@
     finally:
         sys.stdout.flush()
 
-def run_command(cmd, directory='.'):
-    util.report_run_cmd(cmd, cwd=directory)
+def run_command(cmd, directory='.', shell=False):
+    util.report_run_cmd(cmd, cwd=directory, shell=shell)
 
 
 if __name__ == '__main__':


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76978.253309.patch
Type: text/x-patch
Size: 2277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200328/013ca675/attachment.bin>


More information about the libc-commits mailing list