Add show_includes GN build argument
Add a show_includes GN build argument which is used for include
file analysis. show_includes requires clang to be used and adds
the -H compile argument. This produces output that can be analyzed
to understand all header files included by the source file being
compiled. Here is a sample of the output:
```
[11/1330] clang++-14 -H <other-flags...> -c \
../../src/gpu/ganesh/GrAHardwareBufferImageGenerator.cpp -o \
obj/src/gpu/ganesh/gpu.GrAHardwareBufferImageGenerator.o
. ../../include/core/SkTypes.h
.. ../../include/private/base/SkFeatures.h
.. ../../include/private/base/SkLoadUserConfig.h
... ../../include/private/base/SkFeatures.h
... ../../include/config/SkUserConfig.h
.. ../../include/private/base/SkAPI.h
... ../../include/private/base/SkLoadUserConfig.h
<many other headers>
```
Bug: skia:12159
Change-Id: Ideeb6daa9fd27cb8f5be02f358b0d1c8c5f6dc91
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/703456
Auto-Submit: Chris Mumford <cmumford@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Chris Mumford <cmumford@google.com>
diff --git a/gn/BUILDCONFIG.gn b/gn/BUILDCONFIG.gn
index 188614c..acf4a54 100644
--- a/gn/BUILDCONFIG.gn
+++ b/gn/BUILDCONFIG.gn
@@ -33,6 +33,10 @@
ios_min_target = ""
ios_use_simulator =
target_os == "ios" && (target_cpu == "x86" || target_cpu == "x64")
+
+ # Enable -H, which prints the include tree during compilation.
+ # For use by external tools for analyzing include files.
+ show_includes = false
}
declare_args() {
is_debug = !is_official_build
diff --git a/gn/skia/BUILD.gn b/gn/skia/BUILD.gn
index bed7053..c712107 100644
--- a/gn/skia/BUILD.gn
+++ b/gn/skia/BUILD.gn
@@ -180,6 +180,21 @@
ldflags += [ "-static-libstdc++" ]
}
+ if (show_includes) {
+ assert(is_clang, "show_includes requires clang to build.")
+ if (is_win) {
+ cflags += [
+ "/clang:-H",
+ "/clang:-fshow-skipped-includes",
+ ]
+ } else {
+ cflags += [
+ "-H",
+ "-fshow-skipped-includes",
+ ]
+ }
+ }
+
if (is_ios) {
if (target_cpu == "arm") {
_arch_flags = [