1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "tools/gn/variables.h"
9 // Built-in variables ----------------------------------------------------------
11 const char kComponentMode
[] = "component_mode";
12 const char kComponentMode_HelpShort
[] =
13 "component_mode: [string] Specifies the meaning of the component() call.";
14 const char kComponentMode_Help
[] =
15 "component_mode: Specifies the meaning of the component() call.\n"
17 " This value is looked up whenever a \"component\" target type is\n"
18 " encountered. The value controls whether the given target is a shared\n"
19 " or a static library.\n"
21 " The initial value will be empty, which will cause a call to\n"
22 " component() to throw an error. Typically this value will be set in the\n"
23 " build config script.\n"
26 " - \"shared_library\"\n"
28 " - \"static_library\"\n";
30 const char kCpuArch
[] = "cpu_arch";
31 const char kCpuArch_HelpShort
[] =
32 "cpu_arch: [string] Current processor architecture.";
33 const char kCpuArch_Help
[] =
34 "cpu_arch: Current processor architecture.\n"
36 " The initial value is based on the current architecture of the host\n"
37 " system. However, the build configuration can set this to any value.\n"
39 " This value is not used internally by GN for any purpose, so you can\n"
40 " set it to whatever value is relevant to your build.\n"
42 "Possible initial values set by GN:\n"
47 const char kCurrentToolchain
[] = "current_toolchain";
48 const char kCurrentToolchain_HelpShort
[] =
49 "current_toolchain: [string] Label of the current toolchain.";
50 const char kCurrentToolchain_Help
[] =
51 "current_toolchain: Label of the current toolchain.\n"
53 " A fully-qualified label representing the current toolchain. You can\n"
54 " use this to make toolchain-related decisions in the build. See also\n"
55 " \"default_toolchain\".\n"
59 " if (current_toolchain == \"//build:64_bit_toolchain\") {\n"
60 " executable(\"output_thats_64_bit_only\") {\n"
63 const char kBuildCpuArch
[] = "build_cpu_arch";
64 const char kBuildCpuArch_HelpShort
[] =
65 "build_cpu_arch: [string] The default value for the \"cpu_arch\" "
67 const char kBuildCpuArch_Help
[] =
68 "build_cpu_arch: The default value for the \"cpu_arch\" variable.\n"
70 " This value has the same definition as \"cpu_arch\" (see\n"
71 " \"gn help cpu_arch\") but should be treated as read-only. This is so\n"
72 " the build can override the \"cpu_arch\" variable for doing\n"
73 " cross-compiles, but can still access the host build system's CPU\n"
76 const char kBuildOs
[] = "build_os";
77 const char kBuildOs_HelpShort
[] =
78 "build_os: [string] The default value for the \"os\" variable.";
79 const char kBuildOs_Help
[] =
80 "build_os: [string] The default value for the \"os\" variable.\n"
82 " This value has the same definition as \"os\" (see \"gn help os\") but\n"
83 " should be treated as read-only. This is so the build can override\n"
84 " the \"os\" variable for doing cross-compiles, but can still access\n"
85 " the host build system's operating system type.\n";
87 const char kDefaultToolchain
[] = "default_toolchain";
88 const char kDefaultToolchain_HelpShort
[] =
89 "default_toolchain: [string] Label of the default toolchain.";
90 const char kDefaultToolchain_Help
[] =
91 "default_toolchain: [string] Label of the default toolchain.\n"
93 " A fully-qualified label representing the default toolchain, which may\n"
94 " not necessarily be the current one (see \"current_toolchain\").\n";
96 const char kOs
[] = "os";
97 const char kOs_HelpShort
[] =
98 "os: [string] Indicates the operating system of the current build.";
99 const char kOs_Help
[] =
100 "os: Indicates the operating system of the current build."
102 " This value is set by default based on the current host operating\n"
103 " system. The build configuration can override the value to anything\n"
104 " it wants, or it can be set via the build arguments on the command\n"
107 " If you want to know the default value without any overrides, you can\n"
108 " use \"default_os\" (see \"gn help default_os\").\n"
110 " Note that this returns the most specific value. So even though\n"
111 " Android and ChromeOS are both Linux, the more specific value will\n"
114 "Some possible values:\n"
123 const char kPythonPath
[] = "python_path";
124 const char kPythonPath_HelpShort
[] =
125 "python_path: [string] Absolute path of Python.";
126 const char kPythonPath_Help
[] =
127 "python_path: Absolute path of Python.\n"
129 " Normally used in toolchain definitions if running some command\n"
130 " requires Python. You will normally not need this when invoking scripts\n"
131 " since GN automatically finds it for you.\n";
133 const char kRootBuildDir
[] = "root_build_dir";
134 const char kRootBuildDir_HelpShort
[] =
135 "root_build_dir: [string] Directory where build commands are run.";
136 const char kRootBuildDir_Help
[] =
137 "root_build_dir: [string] Directory where build commands are run.\n"
139 " This is the root build output directory which will be the current\n"
140 " directory when executing all compilers and scripts.\n"
142 " Most often this is used with rebase_path (see \"gn help rebase_path\")\n"
143 " to convert arguments to be relative to a script's current directory.\n";
145 const char kRootGenDir
[] = "root_gen_dir";
146 const char kRootGenDir_HelpShort
[] =
147 "root_gen_dir: [string] Directory for the toolchain's generated files.";
148 const char kRootGenDir_Help
[] =
149 "root_gen_dir: Directory for the toolchain's generated files.\n"
151 " Absolute path to the root of the generated output directory tree for\n"
152 " the current toolchain. An example value might be \"//out/Debug/gen\".\n"
153 " It will not have a trailing slash.\n"
155 " This is primarily useful for setting up include paths for generated\n"
156 " files. If you are passing this to a script, you will want to pass it\n"
157 " through to_build_path() (see \"gn help to_build_path\") to convert it\n"
158 " to be relative to the build directory.\n"
160 " See also \"target_gen_dir\" which is usually a better location for\n"
161 " generated files. It will be inside the root generated dir.\n";
163 const char kRootOutDir
[] = "root_out_dir";
164 const char kRootOutDir_HelpShort
[] =
165 "root_out_dir: [string] Root directory for toolchain output files.";
166 const char kRootOutDir_Help
[] =
167 "root_out_dir: [string] Root directory for toolchain output files.\n"
169 " Absolute path to the root of the output directory tree for the current\n"
170 " toolchain. An example value might be \"//out/Debug/gen\". It will not\n"
171 " have a trailing slash.\n"
173 " This is primarily useful for setting up script calls. If you are\n"
174 " passing this to a script, you will want to pass it through\n"
175 " to_build_path() (see \"gn help to_build_path\") to convert it\n"
176 " to be relative to the build directory.\n"
178 " See also \"target_out_dir\" which is usually a better location for\n"
179 " output files. It will be inside the root output dir.\n"
183 " custom(\"myscript\") {\n"
184 " # Pass the output dir to the script.\n"
185 " args = [ \"-o\", to_build_path(root_out_dir) ]\n"
188 const char kTargetGenDir
[] = "target_gen_dir";
189 const char kTargetGenDir_HelpShort
[] =
190 "target_gen_dir: [string] Directory for a target's generated files.";
191 const char kTargetGenDir_Help
[] =
192 "target_gen_dir: Directory for a target's generated files.\n"
194 " Absolute path to the target's generated file directory. If your\n"
195 " current target is in \"//tools/doom_melon\" then this value might be\n"
196 " \"//out/Debug/gen/tools/doom_melon\". It will not have a trailing\n"
199 " This is primarily useful for setting up include paths for generated\n"
200 " files. If you are passing this to a script, you will want to pass it\n"
201 " through to_build_path() (see \"gn help to_build_path\") to convert it\n"
202 " to be relative to the build directory.\n"
204 " See also \"gn help root_gen_dir\".\n"
208 " custom(\"myscript\") {\n"
209 " # Pass the generated output dir to the script.\n"
210 " args = [ \"-o\", to_build_path(target_gen_dir) ]\n"
213 const char kTargetOutDir
[] = "target_out_dir";
214 const char kTargetOutDir_HelpShort
[] =
215 "target_out_dir: [string] Directory for target output files.";
216 const char kTargetOutDir_Help
[] =
217 "target_out_dir: [string] Directory for target output files."
219 " Absolute path to the target's generated file directory. If your\n"
220 " current target is in \"//tools/doom_melon\" then this value might be\n"
221 " \"//out/Debug/obj/tools/doom_melon\". It will not have a trailing\n"
224 " This is primarily useful for setting up arguments for calling\n"
225 " scripts. If you are passing this to a script, you will want to pass it\n"
226 " through to_build_path() (see \"gn help to_build_path\") to convert it\n"
227 " to be relative to the build directory.\n"
229 " See also \"gn help root_out_dir\".\n"
233 " custom(\"myscript\") {\n"
234 " # Pass the output dir to the script.\n"
235 " args = [ \"-o\", to_build_path(target_out_dir) ]\n"
238 // Target variables ------------------------------------------------------------
240 const char kAllDependentConfigs
[] = "all_dependent_configs";
241 const char kAllDependentConfigs_HelpShort
[] =
242 "all_dependent_configs: [label list] Configs to be forced on dependents.";
243 const char kAllDependentConfigs_Help
[] =
244 "all_dependent_configs: Configs to be forced on dependents.\n"
246 " A list of config labels.\n"
248 " All targets depending on this one, and recursively, all targets\n"
249 " depending on those, will have the configs listed in this variable\n"
250 " added to them. These configs will also apply to the current target.\n"
252 " This addition happens in a second phase once a target and all of its\n"
253 " dependencies have been resolved. Therefore, a target will not see\n"
254 " these force-added configs in their \"configs\" variable while the\n"
255 " script is running, and then can not be removed. As a result, this\n"
256 " capability should generally only be used to add defines and include\n"
257 " directories necessary to compile a target's headers.\n"
259 " See also \"direct_dependent_configs\".\n";
261 const char kArgs
[] = "args";
262 const char kArgs_HelpShort
[] =
263 "args: [string list] Arguments passed to a custom script.";
264 const char kArgs_Help
[] =
265 "args: Arguments passed to a custom script.\n"
267 " For custom script targets, args is the list of arguments to pass\n"
268 " to the script. Typically you would use source expansion (see\n"
269 " \"gn help source_expansion\") to insert the source file names.\n"
271 " See also \"gn help custom\".\n";
273 const char kCflags
[] = "cflags";
274 const char kCflags_HelpShort
[] =
275 "cflags: [string list] Flags passed to all C compiler variants.";
276 // Avoid writing long help for each variant.
277 #define COMMON_FLAGS_HELP \
279 " Flags are never quoted. If your flag includes a string that must be\n"\
280 " quoted, you must do it yourself. This also means that you can\n"\
281 " specify more than one flag in a string if necessary (\"--foo --bar\")\n"\
282 " and have them be seen as separate by the tool.\n"
283 const char kCommonCflagsHelp
[] =
284 "cflags*: Flags passed to the C compiler.\n"
286 " A list of strings.\n"
288 " \"cflags\" are passed to all invocations of the C, C++, Objective C,\n"
289 " and Objective C++ compilers.\n"
291 " To target one of these variants individually, use \"cflags_c\",\n"
292 " \"cflags_cc\", \"cflags_objc\", and \"cflags_objcc\", respectively.\n"
293 " These variant-specific versions will be appended to the \"cflags\".\n"
295 const char* kCflags_Help
= kCommonCflagsHelp
;
297 const char kCflagsC
[] = "cflags_c";
298 const char kCflagsC_HelpShort
[] =
299 "cflags_c: [string list] Flags passed to the C compiler.";
300 const char* kCflagsC_Help
= kCommonCflagsHelp
;
302 const char kCflagsCC
[] = "cflags_cc";
303 const char kCflagsCC_HelpShort
[] =
304 "cflags_cc: [string list] Flags passed to the C++ compiler.";
305 const char* kCflagsCC_Help
= kCommonCflagsHelp
;
307 const char kCflagsObjC
[] = "cflags_objc";
308 const char kCflagsObjC_HelpShort
[] =
309 "cflags_objc: [string list] Flags passed to the Objective C compiler.";
310 const char* kCflagsObjC_Help
= kCommonCflagsHelp
;
312 const char kCflagsObjCC
[] = "cflags_objcc";
313 const char kCflagsObjCC_HelpShort
[] =
314 "cflags_objcc: [string list] Flags passed to the Objective C++ compiler.";
315 const char* kCflagsObjCC_Help
= kCommonCflagsHelp
;
317 const char kConfigs
[] = "configs";
318 const char kConfigs_HelpShort
[] =
319 "configs: [label list] Configs applying to this target.";
320 const char kConfigs_Help
[] =
321 "configs: Configs applying to this target.\n"
323 " A list of config labels.\n"
325 " The include_dirs, defines, etc. in each config are appended in the\n"
326 " order they appear to the compile command for each file in the target.\n"
327 " They will appear after the include_dirs, defines, etc. that the target\n"
330 " The build configuration script will generally set up the default\n"
331 " configs applying to a given target type (see \"set_defaults\").\n"
332 " When a target is being defined, it can add to or remove from this\n"
336 " static_library(\"foo\") {\n"
337 " configs -= \"//build:no_rtti\" # Don't use the default RTTI config.\n"
338 " configs += \":mysettings\" # Add some of our own settings.\n"
341 const char kData
[] = "data";
342 const char kData_HelpShort
[] =
343 "data: [file list] Runtime data file dependencies.";
344 const char kData_Help
[] =
345 "data: Runtime data file dependencies.\n"
347 " Lists files required to run the given target. These are typically\n"
350 " Appearing in the \"data\" section does not imply any special handling\n"
351 " such as copying them to the output directory. This is just used for\n"
352 " declaring runtime dependencies. There currently isn't a good use for\n"
353 " these but it is envisioned that test data can be listed here for use\n"
354 " running automated tests.\n"
356 " See also \"gn help source_prereqs\" and \"gn help datadeps\", both of\n"
357 " which actually affect the build in concrete ways.\n";
359 const char kDatadeps
[] = "datadeps";
360 const char kDatadeps_HelpShort
[] =
361 "datadeps: [label list] Non-linked dependencies.";
362 const char kDatadeps_Help
[] =
363 "datadeps: Non-linked dependencies.\n"
365 " A list of target labels.\n"
367 " Specifies dependencies of a target that are not actually linked into\n"
368 " the current target. Such dependencies will built and will be available\n"
371 " This is normally used for things like plugins or helper programs that\n"
372 " a target needs at runtime.\n"
374 " See also \"gn help deps\" and \"gn help data\".\n"
377 " executable(\"foo\") {\n"
378 " deps = [ \"//base\" ]\n"
379 " datadeps = [ \"//plugins:my_runtime_plugin\" ]\n"
382 const char kDefines
[] = "defines";
383 const char kDefines_HelpShort
[] =
384 "defines: [string list] C preprocessor defines.";
385 const char kDefines_Help
[] =
386 "defines: C preprocessor defines.\n"
388 " A list of strings\n"
390 " These strings will be passed to the C/C++ compiler as #defines. The\n"
391 " strings may or may not include an \"=\" to assign a value.\n"
394 " defines = [ \"AWESOME_FEATURE\", \"LOG_LEVEL=3\" ]\n";
396 const char kDeps
[] = "deps";
397 const char kDeps_HelpShort
[] =
398 "deps: [label list] Linked dependencies.";
399 const char kDeps_Help
[] =
400 "deps: Linked dependencies.\n"
402 " A list of target labels.\n"
404 " Specifies dependencies of a target. Shared and dynamic libraries will\n"
405 " be linked into the current target. Other target types that can't be\n"
406 " linked (like custom scripts and groups) listed in \"deps\" will be\n"
407 " treated as \"datadeps\". Likewise, if the current target isn't\n"
408 " linkable, then all deps will be treated as \"datadeps\".\n"
410 " See also \"datadeps\".\n";
412 const char kDirectDependentConfigs
[] = "direct_dependent_configs";
413 const char kDirectDependentConfigs_HelpShort
[] =
414 "direct_dependent_configs: [label list] Configs to be forced on "
416 const char kDirectDependentConfigs_Help
[] =
417 "direct_dependent_configs: Configs to be forced on dependents.\n"
419 " A list of config labels.\n"
421 " Targets directly referencing this one will have the configs listed in\n"
422 " this variable added to them. These configs will also apply to the\n"
425 " This addition happens in a second phase once a target and all of its\n"
426 " dependencies have been resolved. Therefore, a target will not see\n"
427 " these force-added configs in their \"configs\" variable while the\n"
428 " script is running, and then can not be removed. As a result, this\n"
429 " capability should generally only be used to add defines and include\n"
430 " directories necessary to compile a target's headers.\n"
432 " See also \"all_dependent_configs\".\n";
434 const char kExternal
[] = "external";
435 const char kExternal_HelpShort
[] =
436 "external: [boolean] Declares a target as externally generated.";
437 const char kExternal_Help
[] =
438 "external: Declares a target as externally generated.\n"
440 " External targets are treated like normal targets as far as dependent\n"
441 " targets are concerned, but do not actually have their .ninja file\n"
442 " written to disk. This allows them to be generated by an external\n"
443 " program (e.g. GYP).\n"
445 " See also \"gn help gyp\".\n"
448 " static_library(\"foo\") {\n"
452 const char kForwardDependentConfigsFrom
[] = "forward_dependent_configs_from";
453 const char kForwardDependentConfigsFrom_HelpShort
[] =
454 "forward_dependent_configs_from: [label list] Forward dependent's configs.";
455 const char kForwardDependentConfigsFrom_Help
[] =
456 "forward_dependent_configs_from\n"
458 " A list of target labels.\n"
460 " Exposes the direct_dependent_configs from a dependent target as\n"
461 " direct_dependent_configs of the current one. Each label in this list\n"
462 " must also be in the deps.\n"
464 " Sometimes you depend on a child library that exports some necessary\n"
465 " configuration via direct_dependent_configs. If your target in turn\n"
466 " exposes the child library's headers in its public headers, it might\n"
467 " mean that targets that depend on you won't work: they'll be seeing the\n"
468 " child library's code but not the necessary configuration. This list\n"
469 " specifies which of your deps' direct dependent configs to expose as\n"
474 " If we use a given library \"a\" from our public headers:\n"
476 " deps = [ \":a\", \":b\", ... ]\n"
477 " forward_dependent_configs_from = [ \":a\" ]\n"
479 " This example makes a \"transparent\" target that forwards a dependency\n"
482 " group(\"frob\") {\n"
483 " if (use_system_frob) {\n"
484 " deps = \":system_frob\"\n"
486 " deps = \"//third_party/fallback_frob\"\n"
488 " forward_dependent_configs_from = deps\n"
491 const char kGypFile
[] = "gyp_file";
492 const char kGypFile_HelpShort
[] =
493 "gyp_file: [file name] Name of GYP file to write to in GYP mode.";
494 const char kGypFile_Help
[] =
495 "gyp_file: Name of GYP file to write to in GYP mode.\n"
497 " See \"gn help gyp\" for an overview of how this works.\n"
499 " Tip: If all targets in a given BUILD.gn file should go in the same\n"
500 " GYP file, just put gyp_file = \"foo\" at the top of the file and\n"
501 " the variable will be in scope for all targets.\n";
503 const char kHardDep
[] = "hard_dep";
504 const char kHardDep_HelpShort
[] =
505 "hard_dep: [boolean] Indicates a target should be built before dependees.";
506 const char kHardDep_Help
[] =
507 "hard_dep: Indicates a target should be built before dependees.\n"
509 " Ninja's default is to assume that targets can be compiled\n"
510 " independently. This breaks down for generated files that are included\n"
511 " in other targets because Ninja doesn't know to run the generator\n"
512 " before compiling the source file.\n"
514 " Setting \"hard_dep\" to true on a target means that no sources in\n"
515 " targets depending directly on this one will be compiled until this\n"
516 " target is complete. It will introduce a Ninja implicit dependency\n"
517 " from those sources to this target. This flag is not transitive so\n"
518 " it will only affect direct dependents, which will cause problems if\n"
519 " a direct dependent uses this generated file in a public header that a\n"
520 " third target consumes. Try not to do this.\n"
522 " See also \"gn help source_prereqs\" which allows you to specify the\n"
523 " exact generated file dependency on the target consuming it.\n"
526 " executable(\"foo\") {\n"
527 " # myresource will be run before any of the sources in this target\n"
529 " deps = [ \":myresource\" ]\n"
533 " custom(\"myresource\") {\n"
535 " script = \"my_generator.py\"\n"
536 " outputs = \"$target_gen_dir/myresource.h\"\n"
539 const char kIncludeDirs
[] = "include_dirs";
540 const char kIncludeDirs_HelpShort
[] =
541 "include_dirs: [directory list] Additional include directories.";
542 const char kIncludeDirs_Help
[] =
543 "include_dirs: Additional include directories.\n"
545 " A list of source directories.\n"
547 " The directories in this list will be added to the include path for\n"
548 " the files in the affected target.\n"
551 " include_dirs = [ \"src/include\", \"//third_party/foo\" ]\n";
553 const char kLdflags
[] = "ldflags";
554 const char kLdflags_HelpShort
[] =
555 "ldflags: [string list] Flags passed to the linker.";
556 const char kLdflags_Help
[] =
557 "ldflags: Flags passed to the linker.\n"
559 " A list of strings.\n"
561 " These flags are passed on the command-line to the linker and generally\n"
562 " specify various linking options. Most targets will not need these and\n"
563 " will use \"libs\" and \"lib_dirs\" instead.\n"
566 #define COMMON_LIB_INHERITANCE_HELP \
568 " libs and lib_dirs work differently than other flags in two respects.\n" \
569 " First, then are inherited across static library boundaries until a\n" \
570 " shared library or executable target is reached. Second, they are\n" \
571 " uniquified so each one is only passed once (the first instance of it\n" \
572 " will be the one used).\n" \
574 " The order that libs/lib_dirs apply is:\n" \
575 " 1. Ones set on the target itself.\n" \
576 " 2. Ones from the configs applying to the target.\n" \
577 " 3. Ones from deps of the target, in order (recursively following\n" \
580 const char kLibDirs
[] = "lib_dirs";
581 const char kLibDirs_HelpShort
[] =
582 "lib_dirs: [directory list] Additional library directories.";
583 const char kLibDirs_Help
[] =
584 "lib_dirs: Additional library directories.\n"
586 " A list of directories.\n"
588 " Specifies additional directories passed to the linker for searching\n"
589 " for the required libraries. If an item is not an absolute path, it\n"
590 " will be treated as being relative to the current build file.\n"
591 COMMON_LIB_INHERITANCE_HELP
594 " lib_dirs = [ \"/usr/lib/foo\", \"lib/doom_melon\" ]\n";
596 const char kLibs
[] = "libs";
597 const char kLibs_HelpShort
[] =
598 "libs: [string list] Additional libraries to link.";
599 const char kLibs_Help
[] =
600 "libs: Additional libraries to link.\n"
602 " A list of strings.\n"
604 " These files will be passed to the linker, which will generally search\n"
605 " the library include path. Unlike a normal list of files, they will be\n"
606 " passed to the linker unmodified rather than being treated as file\n"
607 " names relative to the current build file. Generally you would set\n"
608 " the \"lib_dirs\" so your library is found. If you need to specify\n"
609 " a path, you can use \"rebase_path\" to convert a path to be relative\n"
610 " to the build directory.\n"
611 COMMON_LIB_INHERITANCE_HELP
615 " libs = [ \"ctl3d.lib\" ]\n"
617 " libs = [ \"ld\" ]\n";
619 const char kOutputName
[] = "output_name";
620 const char kOutputName_HelpShort
[] =
621 "output_name: [string] Name for the output file other than the default.";
622 const char kOutputName_Help
[] =
623 "output_name: Define a name for the output file other than the default.\n"
625 " Normally the output name of a target will be based on the target name,\n"
626 " so the target \"//foo/bar:bar_unittests\" will generate an output\n"
627 " file such as \"bar_unittests.exe\" (using Windows as an example).\n"
629 " Sometimes you will want an alternate name to avoid collisions or\n"
630 " if the internal name isn't appropriate for public distribution.\n"
632 " The output name should have no extension or prefixes, these will be\n"
633 " added using the default system rules. For example, on Linux an output\n"
634 " name of \"foo\" will produce a shared library \"libfoo.so\".\n"
636 " This variable is valid for all binary output target types.\n"
639 " static_library(\"doom_melon\") {\n"
640 " output_name = \"fluffy_bunny\"\n"
643 const char kOutputs
[] = "outputs";
644 const char kOutputs_HelpShort
[] =
645 "outputs: [file list] Output files for custom script and copy targets.";
646 const char kOutputs_Help
[] =
647 "outputs: Output files for custom script and copy targets.\n"
649 " Outputs is valid for \"copy\" and \"custom\" target types and\n"
650 " indicates the resulting files. The values may contain source\n"
651 " expansions to generate the output names from the sources (see\n"
652 " \"gn help source_expansion\").\n"
654 " For copy targets, the outputs is the destination for the copied\n"
655 " file(s). For custom script targets, the outputs should be the list of\n"
656 " files generated by the script.\n";
658 const char kScript
[] = "script";
659 const char kScript_HelpShort
[] =
660 "script: [file name] Script file for custom script targets.";
661 const char kScript_Help
[] =
662 "script: Script file for custom script targets.\n"
664 " An absolute or buildfile-relative file name of a Python script to run\n"
665 " for a custom script target (see \"gn help custom\").\n";
667 const char kSourcePrereqs
[] = "source_prereqs";
668 const char kSourcePrereqs_HelpShort
[] =
669 "source_prereqs: [file list] Additional compile-time dependencies.";
670 const char kSourcePrereqs_Help
[] =
671 "source_prereqs: Additional compile-time dependencies.\n"
673 " Inputs are compile-time dependencies of the current target. This means\n"
674 " that all source prerequisites must be available before compiling any\n"
677 " If one of your sources #includes a generated file, that file must be\n"
678 " available before that source file is compiled. For subsequent builds,\n"
679 " the \".d\" files will list the include dependencies of each source\n"
680 " and Ninja can know about that dependency to make sure it's generated\n"
681 " before compiling your source file. However, for the first run it's\n"
682 " not possible for Ninja to know about this dependency.\n"
684 " Source prerequisites solves this problem by declaring such\n"
685 " dependencies. It will introduce a Ninja \"implicit\" dependency for\n"
686 " each source file in the target on the listed files.\n"
688 " For binary targets, the files in the \"source_prereqs\" should all be\n"
689 " listed in the \"outputs\" section of another target. There is no\n"
690 " reason to declare static source files as source prerequisites since\n"
691 " the normal include file dependency management will handle them more\n"
692 " efficiently anwyay.\n"
694 " For custom script targets that don't generate \".d\" files, the\n"
695 " \"source_prereqs\" section is how you can list known compile-time\n"
696 " dependencies your script may have.\n"
698 " See also \"gn help data\" and \"gn help datadeps\" (which declare\n"
699 " run-time rather than compile-time dependencies), and\n"
700 " \"gn help hard_dep\" which allows you to declare the source dependency\n"
701 " on the target generating a file rather than the target consuming it.\n"
704 " executable(\"foo\") {\n"
705 " sources = [ \"foo.cc\" ]\n"
706 " source_prereqs = [ \"$root_gen_dir/something/generated_data.h\" ]\n"
709 " custom(\"myscript\") {\n"
710 " script = \"domything.py\"\n"
711 " source_prereqs = [ \"input.data\" ]\n"
714 const char kSources
[] = "sources";
715 const char kSources_HelpShort
[] =
716 "sources: [file list] Source files for a target.";
717 const char kSources_Help
[] =
718 "sources: Source files for a target\n"
720 " A list of files relative to the current buildfile.\n";
722 // -----------------------------------------------------------------------------
724 VariableInfo::VariableInfo()
729 VariableInfo::VariableInfo(const char* in_help_short
, const char* in_help
)
730 : help_short(in_help_short
),
734 #define INSERT_VARIABLE(var) \
735 info_map[k##var] = VariableInfo(k##var##_HelpShort, k##var##_Help);
737 const VariableInfoMap
& GetBuiltinVariables() {
738 static VariableInfoMap info_map
;
739 if (info_map
.empty()) {
740 INSERT_VARIABLE(BuildCpuArch
)
741 INSERT_VARIABLE(BuildOs
)
742 INSERT_VARIABLE(CpuArch
)
743 INSERT_VARIABLE(ComponentMode
)
744 INSERT_VARIABLE(CurrentToolchain
)
745 INSERT_VARIABLE(DefaultToolchain
)
747 INSERT_VARIABLE(PythonPath
)
748 INSERT_VARIABLE(RootBuildDir
)
749 INSERT_VARIABLE(RootGenDir
)
750 INSERT_VARIABLE(RootOutDir
)
751 INSERT_VARIABLE(TargetGenDir
)
752 INSERT_VARIABLE(TargetOutDir
)
757 const VariableInfoMap
& GetTargetVariables() {
758 static VariableInfoMap info_map
;
759 if (info_map
.empty()) {
760 INSERT_VARIABLE(AllDependentConfigs
)
761 INSERT_VARIABLE(Args
)
762 INSERT_VARIABLE(Cflags
)
763 INSERT_VARIABLE(CflagsC
)
764 INSERT_VARIABLE(CflagsCC
)
765 INSERT_VARIABLE(CflagsObjC
)
766 INSERT_VARIABLE(CflagsObjCC
)
767 INSERT_VARIABLE(Configs
)
768 INSERT_VARIABLE(Data
)
769 INSERT_VARIABLE(Datadeps
)
770 INSERT_VARIABLE(Deps
)
771 INSERT_VARIABLE(DirectDependentConfigs
)
772 INSERT_VARIABLE(External
)
773 INSERT_VARIABLE(ForwardDependentConfigsFrom
)
774 INSERT_VARIABLE(GypFile
)
775 INSERT_VARIABLE(HardDep
)
776 INSERT_VARIABLE(IncludeDirs
)
777 INSERT_VARIABLE(Ldflags
)
778 INSERT_VARIABLE(Libs
)
779 INSERT_VARIABLE(LibDirs
)
780 INSERT_VARIABLE(OutputName
)
781 INSERT_VARIABLE(Outputs
)
782 INSERT_VARIABLE(Script
)
783 INSERT_VARIABLE(SourcePrereqs
)
784 INSERT_VARIABLE(Sources
)
789 #undef INSERT_VARIABLE
791 } // namespace variables