Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: tools/gn/docs/reference.md

Issue 1217093007: Add a //nogncheck anntation to GN include checker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/c_include_iterator_unittest.cc ('k') | tools/gn/variables.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/docs/reference.md
diff --git a/tools/gn/docs/reference.md b/tools/gn/docs/reference.md
index c55f42e05b394327fe6bb25e2d7d6a0715f91954..ad3ac85676af7484335a90a07b9eeb3dbfb8eeb0 100644
--- a/tools/gn/docs/reference.md
+++ b/tools/gn/docs/reference.md
@@ -1011,6 +1011,7 @@
```
Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc,
defines, include_dirs, ldflags, lib_dirs, libs
+ precompiled_header, precompiled_source
```
@@ -1209,6 +1210,7 @@
```
Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc,
defines, include_dirs, ldflags, lib_dirs, libs
+ precompiled_header, precompiled_source
Deps: data_deps, deps, forward_dependent_configs_from, public_deps
Dependent configs: all_dependent_configs, public_configs
General: check_includes, configs, data, inputs, output_name,
@@ -1920,6 +1922,7 @@
```
Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc,
defines, include_dirs, ldflags, lib_dirs, libs
+ precompiled_header, precompiled_source
Deps: data_deps, deps, forward_dependent_configs_from, public_deps
Dependent configs: all_dependent_configs, public_configs
General: check_includes, configs, data, inputs, output_name,
@@ -1960,6 +1963,7 @@
```
Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc,
defines, include_dirs, ldflags, lib_dirs, libs
+ precompiled_header, precompiled_source
Deps: data_deps, deps, forward_dependent_configs_from, public_deps
Dependent configs: all_dependent_configs, public_configs
General: check_includes, configs, data, inputs, output_name,
@@ -1983,6 +1987,7 @@
```
Flags: cflags, cflags_c, cflags_cc, cflags_objc, cflags_objcc,
defines, include_dirs, ldflags, lib_dirs, libs
+ precompiled_header, precompiled_source
Deps: data_deps, deps, forward_dependent_configs_from, public_deps
Dependent configs: all_dependent_configs, public_configs
General: check_includes, configs, data, inputs, output_name,
@@ -2292,6 +2297,20 @@
Posix systems:
output_prefix = "lib"
+ precompiled_header_type [string]
+ Valid for: "cc", "cxx", "objc", "objcxx"
+
+ Type of precompiled headers. If undefined or the empty string,
+ precompiled headers will not be used for this tool. Otherwise
+ use "msvc" which is the only currently supported value.
+
+ For precompiled headers to be used for a given target, the
+ target (or a config applied to it) must also specify a
+ "precompiled_header" and, for "msvc"-style headers, a
+ "precompiled_source" value.
+
+ See "gn help precompiled_header" for more.
+
restat [boolean]
Valid for: all tools (optional, defaults to false)
@@ -2332,6 +2351,7 @@
```
### **Expansions for tool variables**
+
```
All paths are relative to the root build directory, which is the
current directory for running all tools. These expansions are
@@ -3242,6 +3262,30 @@
```
+### **Controlling includes individually**
+
+```
+ If only certain includes are problematic, you can annotate them
+ individually rather than disabling header checking on an entire
+ target. Add the string "nogncheck" to the include line:
+
+ #include "foo/something_weird.h" // nogncheck (bug 12345)
+
+ It is good form to include a reference to a bug (if the include is
+ improper, or some other comment expressing why the header checker
+ doesn't work for this particular case.
+
+ The most common reason to need "nogncheck" is conditional includes.
+ The header checker does not understand the preprocessor, so may flag
+ some includes as improper even if the dependencies and #defines are
+ always matched correctly:
+
+ #if defined(ENABLE_DOOM_MELON)
+ #include "doom_melon/beam_controller.h" // nogncheck
+ #endif
+
+```
+
### **Example**
```
@@ -3772,6 +3816,77 @@
```
+## **precompiled_header**: [string] Header file to precompile.
+
+```
+ Precompiled headers will be used when a target specifies this
+ value, or a config applying to this target specifies this value.
+ In addition, the tool corresponding to the source files must also
+ specify precompiled headers (see "gn help tool"). The tool
+ will also specify what type of precompiled headers to use.
+
+ The precompiled header/source variables can be specified on a target
+ or a config, but must be the same for all configs applying to a given
+ target since a target can only have one precompiled header.
+
+```
+
+### **MSVC precompiled headers**
+
+```
+ When using MSVC-style precompiled headers, the "precompiled_header"
+ value is a string corresponding to the header. This is NOT a path
+ to a file that GN recognises, but rather the exact string that appears
+ in quotes after an #include line in source code. The compiler will
+ match this string against includes or forced includes (/FI).
+
+ MSVC also requires a source file to compile the header with. This must
+ be specified by the "precompiled_source" value. In contrast to the
+ header value, this IS a GN-style file name, and tells GN which source
+ file to compile to make the .pch file used for subsequent compiles.
+
+ If you use both C and C++ sources, the precompiled header and source
+ file will be compiled using both tools. You will want to make sure
+ to wrap C++ includes in __cplusplus #ifdefs so the file will compile
+ in C mode.
+
+ For example, if the toolchain specifies MSVC headers:
+
+ toolchain("vc_x64") {
+ ...
+ tool("cxx") {
+ precompiled_header_type = "msvc"
+ ...
+
+ You might make a config like this:
+
+ config("use_precompiled_headers") {
+ precompiled_header = "build/precompile.h"
+ precompiled_source = "//build/precompile.cc"
+
+ # Either your source files should #include "build/precompile.h"
+ # first, or you can do this to force-include the header.
+ cflags = [ "/FI$precompiled_header" ]
+ }
+
+ And then define a target that uses the config:
+
+ executable("doom_melon") {
+ configs += [ ":use_precompiled_headers" ]
+ ...
+
+
+
+```
+## **precompiled_source**: [file name] Source file to precompile.
+
+```
+ The source file that goes along with the precompiled_header when
+ using "msvc"-style precompiled headers. It will be implicitly added
+ to the sources of the target. See "gn help precompiled_header".
+
+
+```
## **public**: Declare public header files for a target.
```
« no previous file with comments | « tools/gn/c_include_iterator_unittest.cc ('k') | tools/gn/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698