Ensure opt-in platform ABI dumps are configured with ref_dump_dirs

Test: make
Bug: 323447559
Change-Id: I8eaa38970c81c71b7473bdb9e77dfe9b49a93c92
diff --git a/cc/library.go b/cc/library.go
index 12ecc13..895b199 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1490,6 +1490,11 @@
 					fileName, nameExt, isLlndk)
 			}
 		}
+		// Ensure that a module tagged with only platformLsdumpTag has ref_dump_dirs.
+		// Android.bp in vendor projects should be cleaned up before this is enforced for vendorLsdumpTag and productLsdumpTag.
+		if len(headerAbiChecker.Ref_dump_dirs) == 0 && len(tags) == 1 && tags[0] == platformLsdumpTag {
+			ctx.ModuleErrorf("header_abi_checker is explicitly enabled, but no ref_dump_dirs are specified.")
+		}
 		// Check against the opt-in reference dumps.
 		for i, optInDumpDir := range headerAbiChecker.Ref_dump_dirs {
 			optInDumpDirPath := android.PathForModuleSrc(ctx, optInDumpDir)