presubmit: Add ifndef/define check

Bug: b/287529705
Change-Id: I77d757d07f764162ed4c91350865fa99471d3e54
Reviewed-on: https://pigweed-review.googlesource.com/c/open-dice/+/152197
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Darren Krahn <dkrahn@google.com>
diff --git a/tools/open_dice_tools/presubmit.py b/tools/open_dice_tools/presubmit.py
index d4415cf..48752ae 100644
--- a/tools/open_dice_tools/presubmit.py
+++ b/tools/open_dice_tools/presubmit.py
@@ -17,6 +17,7 @@
 import logging
 import os
 from pathlib import Path
+import re
 import sys
 
 import pw_cli.log
@@ -24,6 +25,7 @@
 from pw_presubmit import (
     build,
     cli,
+    cpp_checks,
     format_code,
     git_repo,
     inclusive_language,
@@ -66,13 +68,23 @@
     _FORMAT,
 )
 
+
+def include_guard(path: Path) -> str:
+    path = path.relative_to(PROJECT_ROOT)
+    exclude = ("include",)
+    transform = {"ulib": "lib"}
+    parts = [transform.get(x, x) for x in path.parts if x not in exclude]
+    return re.sub(r"[.-]", "_", "".join(f"{x}_" for x in parts).upper())
+
+
 LINTFORMAT = (
-    # keep-sorted: start
     _FORMAT,
+    cpp_checks.include_guard_check(include_guard).with_filter(
+        exclude=EXCLUSIONS
+    ),
     inclusive_language.presubmit_check.with_filter(exclude=EXCLUSIONS),
     keep_sorted.presubmit_check.with_filter(exclude=EXCLUSIONS),
     python_checks.gn_python_lint,
-    # keep-sorted: end
 )
 
 FULL = (