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

Unified Diff: tools/gn/variables.cc

Issue 1207903002: Windows precompiled header support in GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Scott's grammar nits Created 5 years, 6 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/variables.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/variables.cc
diff --git a/tools/gn/variables.cc b/tools/gn/variables.cc
index 51a68d5728779ad5039c6847b5e2a9c5e3c5704a..472554ae964f57c484f687bafbc14e249c50533d 100644
--- a/tools/gn/variables.cc
+++ b/tools/gn/variables.cc
@@ -854,6 +854,76 @@ const char kOutputs_Help[] =
" file(s). For actions, the outputs should be the list of files\n"
" generated by the script.\n";
+const char kPrecompiledHeader[] = "precompiled_header";
+const char kPrecompiledHeader_HelpShort[] =
+ "precompiled_header: [string] Header file to precompile.";
+const char kPrecompiledHeader_Help[] =
+ "precompiled_header: [string] Header file to precompile.\n"
+ "\n"
+ " Precompiled headers will be used when a target specifies this\n"
+ " value, or a config applying to this target specifies this value.\n"
+ " In addition, the tool corresponding to the source files must also\n"
+ " specify precompiled headers (see \"gn help tool\"). The tool\n"
+ " will also specify what type of precompiled headers to use.\n"
+ "\n"
+ " The precompiled header/source variables can be specified on a target\n"
+ " or a config, but must be the same for all configs applying to a given\n"
+ " target since a target can only have one precompiled header.\n"
+ "\n"
+ "MSVC precompiled headers\n"
+ "\n"
+ " When using MSVC-style precompiled headers, the \"precompiled_header\"\n"
+ " value is a string corresponding to the header. This is NOT a path\n"
+ " to a file that GN recognises, but rather the exact string that appears\n"
+ " in quotes after an #include line in source code. The compiler will\n"
+ " match this string against includes or forced includes (/FI).\n"
+ "\n"
+ " MSVC also requires a source file to compile the header with. This must\n"
+ " be specified by the \"precompiled_source\" value. In contrast to the\n"
+ " header value, this IS a GN-style file name, and tells GN which source\n"
+ " file to compile to make the .pch file used for subsequent compiles.\n"
+ "\n"
+ " If you use both C and C++ sources, the precompiled header and source\n"
+ " file will be compiled using both tools. You will want to make sure\n"
+ " to wrap C++ includes in __cplusplus #ifdefs so the file will compile\n"
+ " in C mode.\n"
+ "\n"
+ " For example, if the toolchain specifies MSVC headers:\n"
+ "\n"
+ " toolchain(\"vc_x64\") {\n"
+ " ...\n"
+ " tool(\"cxx\") {\n"
+ " precompiled_header_type = \"msvc\"\n"
+ " ...\n"
+ "\n"
+ " You might make a config like this:\n"
+ "\n"
+ " config(\"use_precompiled_headers\") {\n"
+ " precompiled_header = \"build/precompile.h\"\n"
+ " precompiled_source = \"//build/precompile.cc\"\n"
+ "\n"
+ " # Either your source files should #include \"build/precompile.h\"\n"
+ " # first, or you can do this to force-include the header.\n"
+ " cflags = [ \"/FI$precompiled_header\" ]\n"
+ " }\n"
+ "\n"
+ " And then define a target that uses the config:\n"
+ "\n"
+ " executable(\"doom_melon\") {\n"
+ " configs += [ \":use_precompiled_headers\" ]\n"
+ " ...\n"
+ "\n";
+
+const char kPrecompiledSource[] = "precompiled_source";
+const char kPrecompiledSource_HelpShort[] =
+ "precompiled_source: [file name] Source file to precompile.";
+const char kPrecompiledSource_Help[] =
+ "precompiled_source: [file name] Source file to precompile.\n"
+ "\n"
+ " The source file that goes along with the precompiled_header when\n"
+ " using \"msvc\"-style precompiled headers. It will be implicitly added\n"
+ " to the sources of the target. See \"gn help precompiled_header\".\n";
+
const char kPublic[] = "public";
const char kPublic_HelpShort[] =
"public: [file list] Declare public header files for a target.";
@@ -1121,6 +1191,8 @@ const VariableInfoMap& GetTargetVariables() {
INSERT_VARIABLE(OutputExtension)
INSERT_VARIABLE(OutputName)
INSERT_VARIABLE(Outputs)
+ INSERT_VARIABLE(PrecompiledHeader)
+ INSERT_VARIABLE(PrecompiledSource)
INSERT_VARIABLE(Public)
INSERT_VARIABLE(PublicConfigs)
INSERT_VARIABLE(PublicDeps)
« no previous file with comments | « tools/gn/variables.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698