Use WITH_TIDY_FLAGS env variable.

This variable is a space separated string of clang-tidy flags to be passed
to clang-tidy before any other system required extra flags.
Note that when this flag or local tidy_flags is defined,
the default -header-filter flag is suppressed.

Test: make with WITH_TIDY=1 WITH_TIDY_FLAGS="-extra-arg=-DABCD1=1 -extra-arg=-DABCD2=2"
Bug: 32668284
Change-Id: If7bd31c65404ef7fe6c3499d51f0f209a704efd9
diff --git a/cc/config/tidy.go b/cc/config/tidy.go
index 3a858cd..dd52a0e 100644
--- a/cc/config/tidy.go
+++ b/cc/config/tidy.go
@@ -80,6 +80,11 @@
 			"system/",
 		}, "|")
 	})
+
+	// Use WTIH_TIDY_FLAGS to pass extra global default clang-tidy flags.
+	pctx.VariableFunc("TidyWithTidyFlags", func(ctx android.PackageVarContext) string {
+		return ctx.Config().Getenv("WITH_TIDY_FLAGS")
+	})
 }
 
 type PathBasedTidyCheck struct {