CMake: update checker
authorCampbell Barton <ideasman42@gmail.com>
Wed, 28 Nov 2018 21:49:50 +0000 (08:49 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 28 Nov 2018 21:55:05 +0000 (08:55 +1100)
Support skipping cmake files

build_files/cmake/cmake_consistency_check.py
build_files/cmake/cmake_consistency_check_config.py

index ab87095874f3d9b550d21d161d3a38b875dc85ff..90a9631fe79e63995710421931969248548486d0 100755 (executable)
@@ -29,7 +29,8 @@ if not sys.version.startswith("3"):
     sys.exit(1)
 
 from cmake_consistency_check_config import (
-    IGNORE,
+    IGNORE_SOURCE,
+    IGNORE_CMAKE,
     UTF8_CHECK,
     SOURCE_DIR,
     BUILD_DIR,
@@ -156,6 +157,7 @@ def cmake_get_src(f):
                         break
 
                     # replace dirs
+                    l = l.replace("${CMAKE_SOURCE_DIR}", SOURCE_DIR)
                     l = l.replace("${CMAKE_CURRENT_SOURCE_DIR}", cmake_base)
                     l = l.replace("${CMAKE_CURRENT_BINARY_DIR}", cmake_base_bin)
                     l = l.strip('"')
@@ -238,8 +240,16 @@ def cmake_get_src(f):
     filen.close()
 
 
-def is_ignore(f, ignore_used):
-    for index, ig in enumerate(IGNORE):
+def is_ignore_source(f, ignore_used):
+    for index, ig in enumerate(IGNORE_SOURCE):
+        if ig in f:
+            ignore_used[index] = True
+            return True
+    return False
+
+
+def is_ignore_cmake(f, ignore_used):
+    for index, ig in enumerate(IGNORE_CMAKE):
         if ig in f:
             ignore_used[index] = True
             return True
@@ -250,8 +260,12 @@ def main():
 
     print("Scanning:", SOURCE_DIR)
 
+    ignore_used_source = [False] * len(IGNORE_SOURCE)
+    ignore_used_cmake = [False] * len(IGNORE_CMAKE)
+
     for cmake in source_list(SOURCE_DIR, is_cmake):
-        cmake_get_src(cmake)
+        if not is_ignore_cmake(cmake, ignore_used_cmake):
+            cmake_get_src(cmake)
 
     # First do stupid check, do these files exist?
     print("\nChecking for missing references:")
@@ -282,12 +296,10 @@ def main():
     del is_err
     del errs
 
-    ignore_used = [False] * len(IGNORE)
-
     # now check on files not accounted for.
     print("\nC/C++ Files CMake does not know about...")
     for cf in sorted(source_list(SOURCE_DIR, is_c)):
-        if not is_ignore(cf, ignore_used):
+        if not is_ignore_source(cf, ignore_used_source):
             if cf not in global_c:
                 print("missing_c: ", cf)
 
@@ -304,7 +316,7 @@ def main():
 
     print("\nC/C++ Headers CMake does not know about...")
     for hf in sorted(source_list(SOURCE_DIR, is_c_header)):
-        if not is_ignore(hf, ignore_used):
+        if not is_ignore_source(hf, ignore_used_source):
             if hf not in global_h:
                 print("missing_h: ", hf)
 
@@ -326,9 +338,15 @@ def main():
                                 traceback.print_exc()
 
     # Check ignores aren't stale
-    print("\nCheck for unused 'IGNORE' paths...")
-    for index, ig in enumerate(IGNORE):
-        if not ignore_used[index]:
+    print("\nCheck for unused 'IGNORE_SOURCE' paths...")
+    for index, ig in enumerate(IGNORE_SOURCE):
+        if not ignore_used_source[index]:
+            print("unused ignore: %r" % ig)
+
+    # Check ignores aren't stale
+    print("\nCheck for unused 'IGNORE_CMAKE' paths...")
+    for index, ig in enumerate(IGNORE_CMAKE):
+        if not ignore_used_cmake[index]:
             print("unused ignore: %r" % ig)
 
 
index 2fbf855c38638204ec33ccaaf0b8a356b1438247..bb98cb22644d6c522ec69d85120bd1f8c37897cf 100644 (file)
@@ -1,10 +1,13 @@
 import os
 
-IGNORE = (
+IGNORE_SOURCE = (
     "/test/",
     "/tests/gtests/",
     "/release/",
 
+    # specific source files
+    "extern/audaspace/"
+
     # specific source files
     "extern/bullet2/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp",
     "extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp",
@@ -17,6 +20,10 @@ IGNORE = (
     "intern/audaspace/SRC/AUD_SRCResampleFactory.cpp",
     "intern/audaspace/SRC/AUD_SRCResampleReader.cpp",
 
+    "doc/doxygen/doxygen.extern.h",
+    "doc/doxygen/doxygen.intern.h",
+    "doc/doxygen/doxygen.main.h",
+    "doc/doxygen/doxygen.source.h",
     "extern/bullet2/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h",
     "extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h",
     "extern/bullet2/src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.h",
@@ -29,6 +36,9 @@ IGNORE = (
     "intern/audaspace/SRC/AUD_SRCResampleReader.h",
 )
 
+IGNORE_CMAKE = (
+)
+
 UTF8_CHECK = True
 
 SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))))