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

Side by Side Diff: tools/gn/variables.cc

Issue 1367923006: Enhance GN documentation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « tools/gn/docs/reference.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/variables.h" 5 #include "tools/gn/variables.h"
6 6
7 namespace variables { 7 namespace variables {
8 8
9 // Built-in variables ---------------------------------------------------------- 9 // Built-in variables ----------------------------------------------------------
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const char kCurrentToolchain[] = "current_toolchain"; 158 const char kCurrentToolchain[] = "current_toolchain";
159 const char kCurrentToolchain_HelpShort[] = 159 const char kCurrentToolchain_HelpShort[] =
160 "current_toolchain: [string] Label of the current toolchain."; 160 "current_toolchain: [string] Label of the current toolchain.";
161 const char kCurrentToolchain_Help[] = 161 const char kCurrentToolchain_Help[] =
162 "current_toolchain: Label of the current toolchain.\n" 162 "current_toolchain: Label of the current toolchain.\n"
163 "\n" 163 "\n"
164 " A fully-qualified label representing the current toolchain. You can\n" 164 " A fully-qualified label representing the current toolchain. You can\n"
165 " use this to make toolchain-related decisions in the build. See also\n" 165 " use this to make toolchain-related decisions in the build. See also\n"
166 " \"default_toolchain\".\n" 166 " \"default_toolchain\".\n"
167 "\n" 167 "\n"
168 "Example:\n" 168 "Example\n"
169 "\n" 169 "\n"
170 " if (current_toolchain == \"//build:64_bit_toolchain\") {\n" 170 " if (current_toolchain == \"//build:64_bit_toolchain\") {\n"
171 " executable(\"output_thats_64_bit_only\") {\n" 171 " executable(\"output_thats_64_bit_only\") {\n"
172 " ...\n"; 172 " ...\n";
173 173
174 const char kDefaultToolchain[] = "default_toolchain"; 174 const char kDefaultToolchain[] = "default_toolchain";
175 const char kDefaultToolchain_HelpShort[] = 175 const char kDefaultToolchain_HelpShort[] =
176 "default_toolchain: [string] Label of the default toolchain."; 176 "default_toolchain: [string] Label of the default toolchain.";
177 const char kDefaultToolchain_Help[] = 177 const char kDefaultToolchain_Help[] =
178 "default_toolchain: [string] Label of the default toolchain.\n" 178 "default_toolchain: [string] Label of the default toolchain.\n"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 " \"//out/Debug/arm\" for the \"arm\" toolchain.\n" 235 " \"//out/Debug/arm\" for the \"arm\" toolchain.\n"
236 "\n" 236 "\n"
237 " This is primarily useful for setting up script calls. If you are\n" 237 " This is primarily useful for setting up script calls. If you are\n"
238 " passing this to a script, you will want to pass it through\n" 238 " passing this to a script, you will want to pass it through\n"
239 " rebase_path() (see \"gn help rebase_path\") to convert it\n" 239 " rebase_path() (see \"gn help rebase_path\") to convert it\n"
240 " to be relative to the build directory.\n" 240 " to be relative to the build directory.\n"
241 "\n" 241 "\n"
242 " See also \"target_out_dir\" which is usually a better location for\n" 242 " See also \"target_out_dir\" which is usually a better location for\n"
243 " output files. It will be inside the root output dir.\n" 243 " output files. It will be inside the root output dir.\n"
244 "\n" 244 "\n"
245 "Example:\n" 245 "Example\n"
246 "\n" 246 "\n"
247 " action(\"myscript\") {\n" 247 " action(\"myscript\") {\n"
248 " # Pass the output dir to the script.\n" 248 " # Pass the output dir to the script.\n"
249 " args = [ \"-o\", rebase_path(root_out_dir, root_build_dir) ]\n" 249 " args = [ \"-o\", rebase_path(root_out_dir, root_build_dir) ]\n"
250 " }\n"; 250 " }\n";
251 251
252 const char kTargetGenDir[] = "target_gen_dir"; 252 const char kTargetGenDir[] = "target_gen_dir";
253 const char kTargetGenDir_HelpShort[] = 253 const char kTargetGenDir_HelpShort[] =
254 "target_gen_dir: [string] Directory for a target's generated files."; 254 "target_gen_dir: [string] Directory for a target's generated files.";
255 const char kTargetGenDir_Help[] = 255 const char kTargetGenDir_Help[] =
256 "target_gen_dir: Directory for a target's generated files.\n" 256 "target_gen_dir: Directory for a target's generated files.\n"
257 "\n" 257 "\n"
258 " Absolute path to the target's generated file directory. This will be\n" 258 " Absolute path to the target's generated file directory. This will be\n"
259 " the \"root_gen_dir\" followed by the relative path to the current\n" 259 " the \"root_gen_dir\" followed by the relative path to the current\n"
260 " build file. If your file is in \"//tools/doom_melon\" then\n" 260 " build file. If your file is in \"//tools/doom_melon\" then\n"
261 " target_gen_dir would be \"//out/Debug/gen/tools/doom_melon\". It will\n" 261 " target_gen_dir would be \"//out/Debug/gen/tools/doom_melon\". It will\n"
262 " not have a trailing slash.\n" 262 " not have a trailing slash.\n"
263 "\n" 263 "\n"
264 " This is primarily useful for setting up include paths for generated\n" 264 " This is primarily useful for setting up include paths for generated\n"
265 " files. If you are passing this to a script, you will want to pass it\n" 265 " files. If you are passing this to a script, you will want to pass it\n"
266 " through rebase_path() (see \"gn help rebase_path\") to convert it\n" 266 " through rebase_path() (see \"gn help rebase_path\") to convert it\n"
267 " to be relative to the build directory.\n" 267 " to be relative to the build directory.\n"
268 "\n" 268 "\n"
269 " See also \"gn help root_gen_dir\".\n" 269 " See also \"gn help root_gen_dir\".\n"
270 "\n" 270 "\n"
271 "Example:\n" 271 "Example\n"
272 "\n" 272 "\n"
273 " action(\"myscript\") {\n" 273 " action(\"myscript\") {\n"
274 " # Pass the generated output dir to the script.\n" 274 " # Pass the generated output dir to the script.\n"
275 " args = [ \"-o\", rebase_path(target_gen_dir, root_build_dir) ]" 275 " args = [ \"-o\", rebase_path(target_gen_dir, root_build_dir) ]"
276 "\n" 276 "\n"
277 " }\n"; 277 " }\n";
278 278
279 const char kTargetOutDir[] = "target_out_dir"; 279 const char kTargetOutDir[] = "target_out_dir";
280 const char kTargetOutDir_HelpShort[] = 280 const char kTargetOutDir_HelpShort[] =
281 "target_out_dir: [string] Directory for target output files."; 281 "target_out_dir: [string] Directory for target output files.";
282 const char kTargetOutDir_Help[] = 282 const char kTargetOutDir_Help[] =
283 "target_out_dir: [string] Directory for target output files.\n" 283 "target_out_dir: [string] Directory for target output files.\n"
284 "\n" 284 "\n"
285 " Absolute path to the target's generated file directory. If your\n" 285 " Absolute path to the target's generated file directory. If your\n"
286 " current target is in \"//tools/doom_melon\" then this value might be\n" 286 " current target is in \"//tools/doom_melon\" then this value might be\n"
287 " \"//out/Debug/obj/tools/doom_melon\". It will not have a trailing\n" 287 " \"//out/Debug/obj/tools/doom_melon\". It will not have a trailing\n"
288 " slash.\n" 288 " slash.\n"
289 "\n" 289 "\n"
290 " This is primarily useful for setting up arguments for calling\n" 290 " This is primarily useful for setting up arguments for calling\n"
291 " scripts. If you are passing this to a script, you will want to pass it\n" 291 " scripts. If you are passing this to a script, you will want to pass it\n"
292 " through rebase_path() (see \"gn help rebase_path\") to convert it\n" 292 " through rebase_path() (see \"gn help rebase_path\") to convert it\n"
293 " to be relative to the build directory.\n" 293 " to be relative to the build directory.\n"
294 "\n" 294 "\n"
295 " See also \"gn help root_out_dir\".\n" 295 " See also \"gn help root_out_dir\".\n"
296 "\n" 296 "\n"
297 "Example:\n" 297 "Example\n"
298 "\n" 298 "\n"
299 " action(\"myscript\") {\n" 299 " action(\"myscript\") {\n"
300 " # Pass the output dir to the script.\n" 300 " # Pass the output dir to the script.\n"
301 " args = [ \"-o\", rebase_path(target_out_dir, root_build_dir) ]" 301 " args = [ \"-o\", rebase_path(target_out_dir, root_build_dir) ]"
302 "\n" 302 "\n"
303 " }\n"; 303 " }\n";
304 304
305 // Target variables ------------------------------------------------------------ 305 // Target variables ------------------------------------------------------------
306 306
307 #define COMMON_ORDERING_HELP \ 307 #define COMMON_ORDERING_HELP \
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 "\n" 651 "\n"
652 " Specifies dependencies of a target that are not actually linked into\n" 652 " Specifies dependencies of a target that are not actually linked into\n"
653 " the current target. Such dependencies will be built and will be\n" 653 " the current target. Such dependencies will be built and will be\n"
654 " available at runtime.\n" 654 " available at runtime.\n"
655 "\n" 655 "\n"
656 " This is normally used for things like plugins or helper programs that\n" 656 " This is normally used for things like plugins or helper programs that\n"
657 " a target needs at runtime.\n" 657 " a target needs at runtime.\n"
658 "\n" 658 "\n"
659 " See also \"gn help deps\" and \"gn help data\".\n" 659 " See also \"gn help deps\" and \"gn help data\".\n"
660 "\n" 660 "\n"
661 "Example:\n" 661 "Example\n"
662 "\n"
662 " executable(\"foo\") {\n" 663 " executable(\"foo\") {\n"
663 " deps = [ \"//base\" ]\n" 664 " deps = [ \"//base\" ]\n"
664 " data_deps = [ \"//plugins:my_runtime_plugin\" ]\n" 665 " data_deps = [ \"//plugins:my_runtime_plugin\" ]\n"
665 " }\n"; 666 " }\n";
666 667
667 const char kDefines[] = "defines"; 668 const char kDefines[] = "defines";
668 const char kDefines_HelpShort[] = 669 const char kDefines_HelpShort[] =
669 "defines: [string list] C preprocessor defines."; 670 "defines: [string list] C preprocessor defines.";
670 const char kDefines_Help[] = 671 const char kDefines_Help[] =
671 "defines: C preprocessor defines.\n" 672 "defines: C preprocessor defines.\n"
672 "\n" 673 "\n"
673 " A list of strings\n" 674 " A list of strings\n"
674 "\n" 675 "\n"
675 " These strings will be passed to the C/C++ compiler as #defines. The\n" 676 " These strings will be passed to the C/C++ compiler as #defines. The\n"
676 " strings may or may not include an \"=\" to assign a value.\n" 677 " strings may or may not include an \"=\" to assign a value.\n"
677 COMMON_ORDERING_HELP 678 COMMON_ORDERING_HELP
678 "\n" 679 "\n"
679 "Example:\n" 680 "Example\n"
681 "\n"
680 " defines = [ \"AWESOME_FEATURE\", \"LOG_LEVEL=3\" ]\n"; 682 " defines = [ \"AWESOME_FEATURE\", \"LOG_LEVEL=3\" ]\n";
681 683
682 const char kDepfile[] = "depfile"; 684 const char kDepfile[] = "depfile";
683 const char kDepfile_HelpShort[] = 685 const char kDepfile_HelpShort[] =
684 "depfile: [string] File name for input dependencies for actions."; 686 "depfile: [string] File name for input dependencies for actions.";
685 const char kDepfile_Help[] = 687 const char kDepfile_Help[] =
686 "depfile: [string] File name for input dependencies for actions.\n" 688 "depfile: [string] File name for input dependencies for actions.\n"
687 "\n" 689 "\n"
688 " If nonempty, this string specifies that the current action or\n" 690 " If nonempty, this string specifies that the current action or\n"
689 " action_foreach target will generate the given \".d\" file containing\n" 691 " action_foreach target will generate the given \".d\" file containing\n"
690 " the dependencies of the input. Empty or unset means that the script\n" 692 " the dependencies of the input. Empty or unset means that the script\n"
691 " doesn't generate the files.\n" 693 " doesn't generate the files.\n"
692 "\n" 694 "\n"
693 " The .d file should go in the target output directory. If you have more\n" 695 " The .d file should go in the target output directory. If you have more\n"
694 " than one source file that the script is being run over, you can use\n" 696 " than one source file that the script is being run over, you can use\n"
695 " the output file expansions described in \"gn help action_foreach\" to\n" 697 " the output file expansions described in \"gn help action_foreach\" to\n"
696 " name the .d file according to the input." 698 " name the .d file according to the input."
697 "\n" 699 "\n"
698 " The format is that of a Makefile, and all of the paths should be\n" 700 " The format is that of a Makefile, and all of the paths should be\n"
699 " relative to the root build directory.\n" 701 " relative to the root build directory.\n"
700 "\n" 702 "\n"
701 "Example:\n" 703 "Example\n"
704 "\n"
702 " action_foreach(\"myscript_target\") {\n" 705 " action_foreach(\"myscript_target\") {\n"
703 " script = \"myscript.py\"\n" 706 " script = \"myscript.py\"\n"
704 " sources = [ ... ]\n" 707 " sources = [ ... ]\n"
705 "\n" 708 "\n"
706 " # Locate the depfile in the output directory named like the\n" 709 " # Locate the depfile in the output directory named like the\n"
707 " # inputs but with a \".d\" appended.\n" 710 " # inputs but with a \".d\" appended.\n"
708 " depfile = \"$relative_target_output_dir/{{source_name}}.d\"\n" 711 " depfile = \"$relative_target_output_dir/{{source_name}}.d\"\n"
709 "\n" 712 "\n"
710 " # Say our script uses \"-o <d file>\" to indicate the depfile.\n" 713 " # Say our script uses \"-o <d file>\" to indicate the depfile.\n"
711 " args = [ \"{{source}}\", \"-o\", depfile ]\n" 714 " args = [ \"{{source}}\", \"-o\", depfile ]\n"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 "include_dirs: [directory list] Additional include directories."; 784 "include_dirs: [directory list] Additional include directories.";
782 const char kIncludeDirs_Help[] = 785 const char kIncludeDirs_Help[] =
783 "include_dirs: Additional include directories.\n" 786 "include_dirs: Additional include directories.\n"
784 "\n" 787 "\n"
785 " A list of source directories.\n" 788 " A list of source directories.\n"
786 "\n" 789 "\n"
787 " The directories in this list will be added to the include path for\n" 790 " The directories in this list will be added to the include path for\n"
788 " the files in the affected target.\n" 791 " the files in the affected target.\n"
789 COMMON_ORDERING_HELP 792 COMMON_ORDERING_HELP
790 "\n" 793 "\n"
791 "Example:\n" 794 "Example\n"
795 "\n"
792 " include_dirs = [ \"src/include\", \"//third_party/foo\" ]\n"; 796 " include_dirs = [ \"src/include\", \"//third_party/foo\" ]\n";
793 797
794 const char kInputs[] = "inputs"; 798 const char kInputs[] = "inputs";
795 const char kInputs_HelpShort[] = 799 const char kInputs_HelpShort[] =
796 "inputs: [file list] Additional compile-time dependencies."; 800 "inputs: [file list] Additional compile-time dependencies.";
797 const char kInputs_Help[] = 801 const char kInputs_Help[] =
798 "inputs: Additional compile-time dependencies.\n" 802 "inputs: Additional compile-time dependencies.\n"
799 "\n" 803 "\n"
800 " Inputs are compile-time dependencies of the current target. This means\n" 804 " Inputs are compile-time dependencies of the current target. This means\n"
801 " that all inputs must be available before compiling any of the sources\n" 805 " that all inputs must be available before compiling any of the sources\n"
802 " or executing any actions.\n" 806 " or executing any actions.\n"
803 "\n" 807 "\n"
804 " Inputs are typically only used for action and action_foreach targets.\n" 808 " Inputs are typically only used for action and action_foreach targets.\n"
805 "\n" 809 "\n"
806 "Inputs for actions\n" 810 "Inputs for actions\n"
807 "\n" 811 "\n"
808 " For action and action_foreach targets, inputs should be the inputs to\n" 812 " For action and action_foreach targets, inputs should be the inputs to\n"
809 " script that don't vary. These should be all .py files that the script\n" 813 " script that don't vary. These should be all .py files that the script\n"
810 " uses via imports (the main script itself will be an implcit dependency\n" 814 " uses via imports (the main script itself will be an implcit dependency\n"
811 " of the action so need not be listed).\n" 815 " of the action so need not be listed).\n"
812 "\n" 816 "\n"
813 " For action targets, inputs should be the entire set of inputs the\n" 817 " For action targets, inputs and sources are treated the same, but from\n"
814 " script needs. For action_foreach targets, inputs should be the set of\n" 818 " a style perspective, it's recommended to follow the same rule as\n"
815 " dependencies that don't change. These will be applied to each script\n" 819 " action_foreach and put helper files in the inputs, and the data used\n"
816 " invocation over the sources.\n" 820 " by the script (if any) in sources.\n"
817 "\n" 821 "\n"
818 " Note that another way to declare input dependencies from an action\n" 822 " Note that another way to declare input dependencies from an action\n"
819 " is to have the action write a depfile (see \"gn help depfile\"). This\n" 823 " is to have the action write a depfile (see \"gn help depfile\"). This\n"
820 " allows the script to dynamically write input dependencies, that might\n" 824 " allows the script to dynamically write input dependencies, that might\n"
821 " not be known until actually executing the script. This is more\n" 825 " not be known until actually executing the script. This is more\n"
822 " efficient than doing processing while running GN to determine the\n" 826 " efficient than doing processing while running GN to determine the\n"
823 " inputs, and is easier to keep in-sync than hardcoding the list.\n" 827 " inputs, and is easier to keep in-sync than hardcoding the list.\n"
824 "\n" 828 "\n"
829 "Script input gotchas\n"
830 "\n"
831 " It may be tempting to write a script that enumerates all files in a\n"
832 " directory as inputs. Don't do this! Even if you specify all the files\n"
833 " in the inputs or sources in the GN target (or worse, enumerate the\n"
834 " files in an exec_script call when running GN, which will be slow), the\n"
835 " dependencies will be broken.\n"
836 "\n"
837 " The problem happens if a file is ever removed because the inputs are\n"
838 " not listed on the command line to the script. Because the script\n"
839 " hasn't changed and all inputs are up-to-date, the script will not\n"
840 " re-run and you will get a stale build. Instead, either list all\n"
841 " inputs on the command line to the script, or if there are many, create\n"
842 " a separate list file that the script reads. As long as this file is\n"
843 " listed in the inputs, the build will detect when it has changed in any\n"
844 " way and the action will re-run.\n"
845 "\n"
825 "Inputs for binary targets\n" 846 "Inputs for binary targets\n"
826 "\n" 847 "\n"
827 " Any input dependencies will be resolved before compiling any sources.\n" 848 " Any input dependencies will be resolved before compiling any sources.\n"
828 " Normally, all actions that a target depends on will be run before any\n" 849 " Normally, all actions that a target depends on will be run before any\n"
829 " files in a target are compiled. So if you depend on generated headers,\n" 850 " files in a target are compiled. So if you depend on generated headers,\n"
830 " you do not typically need to list them in the inputs section.\n" 851 " you do not typically need to list them in the inputs section.\n"
831 "\n" 852 "\n"
853 " Inputs for binary targets will be treated as order-only dependencies,\n"
854 " meaning that they will be forced up-to-date before compiling or\n"
855 " any files in the target, but changes in the inputs will not\n"
856 " necessarily force the target to compile. This is because it is\n"
857 " expected that the compiler will report the precise list of input\n"
858 " dependencies required to recompile each file once the initial build\n"
859 " is done.\n"
860 "\n"
832 "Example\n" 861 "Example\n"
833 "\n" 862 "\n"
834 " action(\"myscript\") {\n" 863 " action(\"myscript\") {\n"
835 " script = \"domything.py\"\n" 864 " script = \"domything.py\"\n"
836 " inputs = [ \"input.data\" ]\n" 865 " inputs = [ \"input.data\" ]\n"
837 " }\n"; 866 " }\n";
838 867
839 const char kLdflags[] = "ldflags"; 868 const char kLdflags[] = "ldflags";
840 const char kLdflags_HelpShort[] = 869 const char kLdflags_HelpShort[] =
841 "ldflags: [string list] Flags passed to the linker."; 870 "ldflags: [string list] Flags passed to the linker.";
(...skipping 27 matching lines...) Expand all
869 "lib_dirs: Additional library directories.\n" 898 "lib_dirs: Additional library directories.\n"
870 "\n" 899 "\n"
871 " A list of directories.\n" 900 " A list of directories.\n"
872 "\n" 901 "\n"
873 " Specifies additional directories passed to the linker for searching\n" 902 " Specifies additional directories passed to the linker for searching\n"
874 " for the required libraries. If an item is not an absolute path, it\n" 903 " for the required libraries. If an item is not an absolute path, it\n"
875 " will be treated as being relative to the current build file.\n" 904 " will be treated as being relative to the current build file.\n"
876 COMMON_LIB_INHERITANCE_HELP 905 COMMON_LIB_INHERITANCE_HELP
877 COMMON_ORDERING_HELP 906 COMMON_ORDERING_HELP
878 "\n" 907 "\n"
879 "Example:\n" 908 "Example\n"
909 "\n"
880 " lib_dirs = [ \"/usr/lib/foo\", \"lib/doom_melon\" ]\n"; 910 " lib_dirs = [ \"/usr/lib/foo\", \"lib/doom_melon\" ]\n";
881 911
882 const char kLibs[] = "libs"; 912 const char kLibs[] = "libs";
883 const char kLibs_HelpShort[] = 913 const char kLibs_HelpShort[] =
884 "libs: [string list] Additional libraries to link."; 914 "libs: [string list] Additional libraries to link.";
885 const char kLibs_Help[] = 915 const char kLibs_Help[] =
886 "libs: Additional libraries to link.\n" 916 "libs: Additional libraries to link.\n"
887 "\n" 917 "\n"
888 " A list of strings.\n" 918 " A list of strings.\n"
889 "\n" 919 "\n"
890 " These files will be passed to the linker, which will generally search\n" 920 " These files will be passed to the linker, which will generally search\n"
891 " the library include path. Unlike a normal list of files, they will be\n" 921 " the library include path. Unlike a normal list of files, they will be\n"
892 " passed to the linker unmodified rather than being treated as file\n" 922 " passed to the linker unmodified rather than being treated as file\n"
893 " names relative to the current build file. Generally you would set\n" 923 " names relative to the current build file. Generally you would set\n"
894 " the \"lib_dirs\" so your library is found. If you need to specify\n" 924 " the \"lib_dirs\" so your library is found. If you need to specify\n"
895 " a path, you can use \"rebase_path\" to convert a path to be relative\n" 925 " a path, you can use \"rebase_path\" to convert a path to be relative\n"
896 " to the build directory.\n" 926 " to the build directory.\n"
897 "\n" 927 "\n"
898 " When constructing the linker command, the \"lib_prefix\" attribute of\n" 928 " When constructing the linker command, the \"lib_prefix\" attribute of\n"
899 " the linker tool in the current toolchain will be prepended to each\n" 929 " the linker tool in the current toolchain will be prepended to each\n"
900 " library. So your BUILD file should not specify the switch prefix\n" 930 " library. So your BUILD file should not specify the switch prefix\n"
901 " (like \"-l\"). On Mac, libraries ending in \".framework\" will be\n" 931 " (like \"-l\"). On Mac, libraries ending in \".framework\" will be\n"
902 " special-cased: the switch \"-framework\" will be prepended instead of\n" 932 " special-cased: the switch \"-framework\" will be prepended instead of\n"
903 " the lib_prefix, and the \".framework\" suffix will be trimmed.\n" 933 " the lib_prefix, and the \".framework\" suffix will be trimmed.\n"
904 COMMON_LIB_INHERITANCE_HELP 934 COMMON_LIB_INHERITANCE_HELP
905 COMMON_ORDERING_HELP 935 COMMON_ORDERING_HELP
906 "\n" 936 "\n"
907 "Examples:\n" 937 "Examples\n"
938 "\n"
908 " On Windows:\n" 939 " On Windows:\n"
909 " libs = [ \"ctl3d.lib\" ]\n" 940 " libs = [ \"ctl3d.lib\" ]\n"
910 " On Linux:\n" 941 " On Linux:\n"
911 " libs = [ \"ld\" ]\n"; 942 " libs = [ \"ld\" ]\n";
912 943
913 const char kOutputExtension[] = "output_extension"; 944 const char kOutputExtension[] = "output_extension";
914 const char kOutputExtension_HelpShort[] = 945 const char kOutputExtension_HelpShort[] =
915 "output_extension: [string] Value to use for the output's file extension."; 946 "output_extension: [string] Value to use for the output's file extension.";
916 const char kOutputExtension_Help[] = 947 const char kOutputExtension_Help[] =
917 "output_extension: Value to use for the output's file extension.\n" 948 "output_extension: Value to use for the output's file extension.\n"
918 "\n" 949 "\n"
919 " Normally the file extension for a target is based on the target\n" 950 " Normally the file extension for a target is based on the target\n"
920 " type and the operating system, but in rare cases you will need to\n" 951 " type and the operating system, but in rare cases you will need to\n"
921 " override the name (for example to use \"libfreetype.so.6\" instead\n" 952 " override the name (for example to use \"libfreetype.so.6\" instead\n"
922 " of libfreetype.so on Linux)."; 953 " of libfreetype.so on Linux).\n"
954 "\n"
955 " This value should not include a leading dot. If undefined or empty,\n"
956 " the default_output_extension specified on the tool will be used.\n"
957 " The output_extension will be used in the \"{{output_extension}}\"\n"
958 " expansion which the linker tool will generally use to specify the\n"
959 " output file name. See \"gn help tool\".\n"
960 "\n"
961 "Example\n"
962 "\n"
963 " shared_library(\"freetype\") {\n"
964 " if (is_linux) {\n"
965 " # Call the output \"libfreetype.so.6\"\n"
966 " output_extension = \"so.6\"\n"
967 " }\n"
968 " ...\n"
969 " }\n"
970 "\n"
971 " # On Windows, generate a \"mysettings.cpl\" control panel applet.\n"
972 " # Control panel applets are actually special shared libraries.\n"
973 " if (is_win) {\n"
974 " shared_library(\"mysettings\") {\n"
975 " output_extension = \"cpl\"\n"
976 " ...\n"
977 " }\n"
978 " }\n";
923 979
924 const char kOutputName[] = "output_name"; 980 const char kOutputName[] = "output_name";
925 const char kOutputName_HelpShort[] = 981 const char kOutputName_HelpShort[] =
926 "output_name: [string] Name for the output file other than the default."; 982 "output_name: [string] Name for the output file other than the default.";
927 const char kOutputName_Help[] = 983 const char kOutputName_Help[] =
928 "output_name: Define a name for the output file other than the default.\n" 984 "output_name: Define a name for the output file other than the default.\n"
929 "\n" 985 "\n"
930 " Normally the output name of a target will be based on the target name,\n" 986 " Normally the output name of a target will be based on the target name,\n"
931 " so the target \"//foo/bar:bar_unittests\" will generate an output\n" 987 " so the target \"//foo/bar:bar_unittests\" will generate an output\n"
932 " file such as \"bar_unittests.exe\" (using Windows as an example).\n" 988 " file such as \"bar_unittests.exe\" (using Windows as an example).\n"
933 "\n" 989 "\n"
934 " Sometimes you will want an alternate name to avoid collisions or\n" 990 " Sometimes you will want an alternate name to avoid collisions or\n"
935 " if the internal name isn't appropriate for public distribution.\n" 991 " if the internal name isn't appropriate for public distribution.\n"
936 "\n" 992 "\n"
937 " The output name should have no extension or prefixes, these will be\n" 993 " The output name should have no extension or prefixes, these will be\n"
938 " added using the default system rules. For example, on Linux an output\n" 994 " added using the default system rules. For example, on Linux an output\n"
939 " name of \"foo\" will produce a shared library \"libfoo.so\".\n" 995 " name of \"foo\" will produce a shared library \"libfoo.so\". There\n"
996 " is no way to override the output prefix of a linker tool on a per-\n"
997 " target basis. If you need more flexibility, create a copy target\n"
998 " to produce the file you want.\n"
940 "\n" 999 "\n"
941 " This variable is valid for all binary output target types.\n" 1000 " This variable is valid for all binary output target types.\n"
942 "\n" 1001 "\n"
943 "Example:\n" 1002 "Example\n"
1003 "\n"
944 " static_library(\"doom_melon\") {\n" 1004 " static_library(\"doom_melon\") {\n"
945 " output_name = \"fluffy_bunny\"\n" 1005 " output_name = \"fluffy_bunny\"\n"
946 " }\n"; 1006 " }\n";
947 1007
948 const char kOutputs[] = "outputs"; 1008 const char kOutputs[] = "outputs";
949 const char kOutputs_HelpShort[] = 1009 const char kOutputs_HelpShort[] =
950 "outputs: [file list] Output files for actions and copy targets."; 1010 "outputs: [file list] Output files for actions and copy targets.";
951 const char kOutputs_Help[] = 1011 const char kOutputs_Help[] =
952 "outputs: Output files for actions and copy targets.\n" 1012 "outputs: Output files for actions and copy targets.\n"
953 "\n" 1013 "\n"
954 " Outputs is valid for \"copy\", \"action\", and \"action_foreach\"\n" 1014 " Outputs is valid for \"copy\", \"action\", and \"action_foreach\"\n"
955 " target types and indicates the resulting files. The values may contain\n" 1015 " target types and indicates the resulting files. Outputs must always\n"
956 " source expansions to generate the output names from the sources (see\n" 1016 " refer to files in the build directory.\n"
957 " \"gn help source_expansion\").\n"
958 "\n" 1017 "\n"
959 " For copy targets, the outputs is the destination for the copied\n" 1018 " copy\n"
960 " file(s). For actions, the outputs should be the list of files\n" 1019 " Copy targets should have exactly one entry in the outputs list. If\n"
961 " generated by the script.\n"; 1020 " there is exactly one source, this can be a literal file name or a\n"
1021 " source expansion. If there is more than one source, this must\n"
1022 " contain a source expansion to map a single input name to a single\n"
1023 " output name. See \"gn help copy\".\n"
1024 "\n"
1025 " action_foreach\n"
1026 " Action_foreach targets must always use source expansions to map\n"
1027 " input files to output files. There can be more than one output,\n"
1028 " which means that each invocation of the script will produce a set of\n"
1029 " files (presumably based on the name of the input file). See\n"
1030 " \"gn help action_foreach\".\n"
1031 "\n"
1032 " action\n"
1033 " Action targets (excluding action_foreach) must list literal output\n"
1034 " file(s) with no source expansions. See \"gn help action\".\n";
962 1035
963 const char kPrecompiledHeader[] = "precompiled_header"; 1036 const char kPrecompiledHeader[] = "precompiled_header";
964 const char kPrecompiledHeader_HelpShort[] = 1037 const char kPrecompiledHeader_HelpShort[] =
965 "precompiled_header: [string] Header file to precompile."; 1038 "precompiled_header: [string] Header file to precompile.";
966 const char kPrecompiledHeader_Help[] = 1039 const char kPrecompiledHeader_Help[] =
967 "precompiled_header: [string] Header file to precompile.\n" 1040 "precompiled_header: [string] Header file to precompile.\n"
968 "\n" 1041 "\n"
969 " Precompiled headers will be used when a target specifies this\n" 1042 " Precompiled headers will be used when a target specifies this\n"
970 " value, or a config applying to this target specifies this value.\n" 1043 " value, or a config applying to this target specifies this value.\n"
971 " In addition, the tool corresponding to the source files must also\n" 1044 " In addition, the tool corresponding to the source files must also\n"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 "\n" 1124 "\n"
1052 " Public files are inherited through the dependency tree. So if there is\n" 1125 " Public files are inherited through the dependency tree. So if there is\n"
1053 " a dependency A -> B -> C, then A can include C's public headers.\n" 1126 " a dependency A -> B -> C, then A can include C's public headers.\n"
1054 " However, the same is NOT true of visibility, so unless A is in C's\n" 1127 " However, the same is NOT true of visibility, so unless A is in C's\n"
1055 " visibility list, the include will be rejected.\n" 1128 " visibility list, the include will be rejected.\n"
1056 "\n" 1129 "\n"
1057 " GN only knows about files declared in the \"sources\" and \"public\"\n" 1130 " GN only knows about files declared in the \"sources\" and \"public\"\n"
1058 " sections of targets. If a file is included that is not known to the\n" 1131 " sections of targets. If a file is included that is not known to the\n"
1059 " build, it will be allowed.\n" 1132 " build, it will be allowed.\n"
1060 "\n" 1133 "\n"
1061 "Examples:\n" 1134 "Examples\n"
1135 "\n"
1062 " These exact files are public:\n" 1136 " These exact files are public:\n"
1063 " public = [ \"foo.h\", \"bar.h\" ]\n" 1137 " public = [ \"foo.h\", \"bar.h\" ]\n"
1064 "\n" 1138 "\n"
1065 " No files are public (no targets may include headers from this one):\n" 1139 " No files are public (no targets may include headers from this one):\n"
1066 " public = []\n"; 1140 " public = []\n";
1067 1141
1068 const char kPublicConfigs[] = "public_configs"; 1142 const char kPublicConfigs[] = "public_configs";
1069 const char kPublicConfigs_HelpShort[] = 1143 const char kPublicConfigs_HelpShort[] =
1070 "public_configs: [label list] Configs applied to dependents."; 1144 "public_configs: [label list] Configs applied to dependents.";
1071 const char kPublicConfigs_Help[] = 1145 const char kPublicConfigs_Help[] =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 " An absolute or buildfile-relative file name of a Python script to run\n" 1221 " An absolute or buildfile-relative file name of a Python script to run\n"
1148 " for a action and action_foreach targets (see \"gn help action\" and\n" 1222 " for a action and action_foreach targets (see \"gn help action\" and\n"
1149 " \"gn help action_foreach\").\n"; 1223 " \"gn help action_foreach\").\n";
1150 1224
1151 const char kSources[] = "sources"; 1225 const char kSources[] = "sources";
1152 const char kSources_HelpShort[] = 1226 const char kSources_HelpShort[] =
1153 "sources: [file list] Source files for a target."; 1227 "sources: [file list] Source files for a target.";
1154 const char kSources_Help[] = 1228 const char kSources_Help[] =
1155 "sources: Source files for a target\n" 1229 "sources: Source files for a target\n"
1156 "\n" 1230 "\n"
1157 " A list of files relative to the current buildfile.\n"; 1231 " A list of files. Non-absolute paths will be resolved relative to the\n"
1232 " current build file.\n"
1233 "\n"
1234 "Sources for binary targets\n"
1235 "\n"
1236 " For binary targets (source sets, executables, and libraries), the\n"
1237 " known file types will be compiled with the associated tools. Unknown\n"
1238 " file types and headers will be skipped. However, you should still\n"
1239 " list all C/C+ header files so GN knows about the existance of those\n"
1240 " files for the purposes of include checking.\n"
1241 "\n"
1242 " As a special case, a file ending in \".def\" will be treated as a\n"
1243 " Windows module definition file. It will be appended to the link\n"
1244 " line with a preceeding \"/DEF:\" string. There must be at most one\n"
1245 " .def file in a target and they do not cross dependency boundaries\n"
1246 " (so specifying a .def file in a static library or source set will have\n"
1247 " no effect on the executable or shared library they're linked into).\n"
1248 "\n"
1249 "Sources for non-binary targets\n"
1250 "\n"
1251 " action_foreach\n"
1252 " The sources are the set of files that the script will be executed\n"
1253 " over. The script will run once per file.\n"
1254 "\n"
1255 " action\n"
1256 " The sources will be treated the same as inputs. See "
1257 "\"gn help inputs\"\n"
1258 " for more information and usage advice.\n"
1259 "\n"
1260 " copy\n"
1261 " The source are the source files to copy.\n";
1158 1262
1159 const char kTestonly[] = "testonly"; 1263 const char kTestonly[] = "testonly";
1160 const char kTestonly_HelpShort[] = 1264 const char kTestonly_HelpShort[] =
1161 "testonly: [boolean] Declares a target must only be used for testing."; 1265 "testonly: [boolean] Declares a target must only be used for testing.";
1162 const char kTestonly_Help[] = 1266 const char kTestonly_Help[] =
1163 "testonly: Declares a target must only be used for testing.\n" 1267 "testonly: Declares a target must only be used for testing.\n"
1164 "\n" 1268 "\n"
1165 " Boolean. Defaults to false.\n" 1269 " Boolean. Defaults to false.\n"
1166 "\n" 1270 "\n"
1167 " When a target is marked \"testonly = true\", it must only be depended\n" 1271 " When a target is marked \"testonly = true\", it must only be depended\n"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 INSERT_VARIABLE(Sources) 1411 INSERT_VARIABLE(Sources)
1308 INSERT_VARIABLE(Testonly) 1412 INSERT_VARIABLE(Testonly)
1309 INSERT_VARIABLE(Visibility) 1413 INSERT_VARIABLE(Visibility)
1310 } 1414 }
1311 return info_map; 1415 return info_map;
1312 } 1416 }
1313 1417
1314 #undef INSERT_VARIABLE 1418 #undef INSERT_VARIABLE
1315 1419
1316 } // namespace variables 1420 } // namespace variables
OLDNEW
« no previous file with comments | « tools/gn/docs/reference.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698