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

Side by Side Diff: tools/gn/docs/reference.md

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 | « no previous file | tools/gn/variables.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # GN Reference 1 # GN Reference
2 2
3 *This page is automatically generated from* `gn help --markdown all`. 3 *This page is automatically generated from* `gn help --markdown all`.
4 4
5 ## **\--args**: Specifies build arguments overrides. 5 ## **\--args**: Specifies build arguments overrides.
6 6
7 ``` 7 ```
8 See "gn help buildargs" for an overview of how build arguments work. 8 See "gn help buildargs" for an overview of how build arguments work.
9 9
10 Most operations take a build directory. The build arguments are taken 10 Most operations take a build directory. The build arguments are taken
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 All output files must be inside the output directory of the build. 855 All output files must be inside the output directory of the build.
856 You would generally use |$target_out_dir| or |$target_gen_dir| to 856 You would generally use |$target_out_dir| or |$target_gen_dir| to
857 reference the output or generated intermediate file directories, 857 reference the output or generated intermediate file directories,
858 respectively. 858 respectively.
859 859
860 ``` 860 ```
861 861
862 ### **Variables** 862 ### **Variables**
863 863
864 ``` 864 ```
865 args, data, data_deps, depfile, deps, outputs*, script*, 865 args, console, data, data_deps, depfile, deps, outputs*, script*,
866 inputs, sources 866 inputs, sources
867 * = required 867 * = required
868 868
869 ``` 869 ```
870 870
871 ### **Example** 871 ### **Example**
872 872
873 ``` 873 ```
874 action("run_this_guy_once") { 874 action("run_this_guy_once") {
875 script = "doprocessing.py" 875 script = "doprocessing.py"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 All output files must be inside the output directory of the build. 942 All output files must be inside the output directory of the build.
943 You would generally use |$target_out_dir| or |$target_gen_dir| to 943 You would generally use |$target_out_dir| or |$target_gen_dir| to
944 reference the output or generated intermediate file directories, 944 reference the output or generated intermediate file directories,
945 respectively. 945 respectively.
946 946
947 ``` 947 ```
948 948
949 ### **Variables** 949 ### **Variables**
950 950
951 ``` 951 ```
952 args, data, data_deps, depfile, deps, outputs*, script*, 952 args, console, data, data_deps, depfile, deps, outputs*, script*,
953 inputs, sources* 953 inputs, sources*
954 * = required 954 * = required
955 955
956 ``` 956 ```
957 957
958 ### **Example** 958 ### **Example**
959 959
960 ``` 960 ```
961 # Runs the script over each IDL file. The IDL script will generate 961 # Runs the script over each IDL file. The IDL script will generate
962 # both a .cc and a .h file for each input. 962 # both a .cc and a .h file for each input.
(...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 ``` 2858 ```
2859 ## **current_toolchain**: Label of the current toolchain. 2859 ## **current_toolchain**: Label of the current toolchain.
2860 2860
2861 ``` 2861 ```
2862 A fully-qualified label representing the current toolchain. You can 2862 A fully-qualified label representing the current toolchain. You can
2863 use this to make toolchain-related decisions in the build. See also 2863 use this to make toolchain-related decisions in the build. See also
2864 "default_toolchain". 2864 "default_toolchain".
2865 2865
2866 ``` 2866 ```
2867 2867
2868 ### **Example**: 2868 ### **Example**
2869 2869
2870 ``` 2870 ```
2871 if (current_toolchain == "//build:64_bit_toolchain") { 2871 if (current_toolchain == "//build:64_bit_toolchain") {
2872 executable("output_thats_64_bit_only") { 2872 executable("output_thats_64_bit_only") {
2873 ... 2873 ...
2874 2874
2875 2875
2876 ``` 2876 ```
2877 ## **default_toolchain**: [string] Label of the default toolchain. 2877 ## **default_toolchain**: [string] Label of the default toolchain.
2878 2878
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 This is primarily useful for setting up script calls. If you are 2973 This is primarily useful for setting up script calls. If you are
2974 passing this to a script, you will want to pass it through 2974 passing this to a script, you will want to pass it through
2975 rebase_path() (see "gn help rebase_path") to convert it 2975 rebase_path() (see "gn help rebase_path") to convert it
2976 to be relative to the build directory. 2976 to be relative to the build directory.
2977 2977
2978 See also "target_out_dir" which is usually a better location for 2978 See also "target_out_dir" which is usually a better location for
2979 output files. It will be inside the root output dir. 2979 output files. It will be inside the root output dir.
2980 2980
2981 ``` 2981 ```
2982 2982
2983 ### **Example**: 2983 ### **Example**
2984 2984
2985 ``` 2985 ```
2986 action("myscript") { 2986 action("myscript") {
2987 # Pass the output dir to the script. 2987 # Pass the output dir to the script.
2988 args = [ "-o", rebase_path(root_out_dir, root_build_dir) ] 2988 args = [ "-o", rebase_path(root_out_dir, root_build_dir) ]
2989 } 2989 }
2990 2990
2991 2991
2992 ``` 2992 ```
2993 ## **target_cpu**: The desired cpu architecture for the build. 2993 ## **target_cpu**: The desired cpu architecture for the build.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3035 3035
3036 This is primarily useful for setting up include paths for generated 3036 This is primarily useful for setting up include paths for generated
3037 files. If you are passing this to a script, you will want to pass it 3037 files. If you are passing this to a script, you will want to pass it
3038 through rebase_path() (see "gn help rebase_path") to convert it 3038 through rebase_path() (see "gn help rebase_path") to convert it
3039 to be relative to the build directory. 3039 to be relative to the build directory.
3040 3040
3041 See also "gn help root_gen_dir". 3041 See also "gn help root_gen_dir".
3042 3042
3043 ``` 3043 ```
3044 3044
3045 ### **Example**: 3045 ### **Example**
3046 3046
3047 ``` 3047 ```
3048 action("myscript") { 3048 action("myscript") {
3049 # Pass the generated output dir to the script. 3049 # Pass the generated output dir to the script.
3050 args = [ "-o", rebase_path(target_gen_dir, root_build_dir) ] 3050 args = [ "-o", rebase_path(target_gen_dir, root_build_dir) ]
3051 } 3051 }
3052 3052
3053 3053
3054 ``` 3054 ```
3055 ## **target_os**: The desired operating system for the build. 3055 ## **target_os**: The desired operating system for the build.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 3108
3109 This is primarily useful for setting up arguments for calling 3109 This is primarily useful for setting up arguments for calling
3110 scripts. If you are passing this to a script, you will want to pass it 3110 scripts. If you are passing this to a script, you will want to pass it
3111 through rebase_path() (see "gn help rebase_path") to convert it 3111 through rebase_path() (see "gn help rebase_path") to convert it
3112 to be relative to the build directory. 3112 to be relative to the build directory.
3113 3113
3114 See also "gn help root_out_dir". 3114 See also "gn help root_out_dir".
3115 3115
3116 ``` 3116 ```
3117 3117
3118 ### **Example**: 3118 ### **Example**
3119 3119
3120 ``` 3120 ```
3121 action("myscript") { 3121 action("myscript") {
3122 # Pass the output dir to the script. 3122 # Pass the output dir to the script.
3123 args = [ "-o", rebase_path(target_out_dir, root_build_dir) ] 3123 args = [ "-o", rebase_path(target_out_dir, root_build_dir) ]
3124 } 3124 }
3125 3125
3126 3126
3127 ``` 3127 ```
3128 ## **all_dependent_configs**: Configs to be forced on dependents. 3128 ## **all_dependent_configs**: Configs to be forced on dependents.
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
3552 config("default_optimization") { 3552 config("default_optimization") {
3553 if (optimize_everything) { 3553 if (optimize_everything) {
3554 configs = [ ":super_optimization" ] 3554 configs = [ ":super_optimization" ]
3555 } else { 3555 } else {
3556 configs = [ ":no_optimization" ] 3556 configs = [ ":no_optimization" ]
3557 } 3557 }
3558 } 3558 }
3559 3559
3560 3560
3561 ``` 3561 ```
3562 ## **console**: Run this action in the console pool.
3563
3564 ```
3565 Boolean. Defaults to false.
3566
3567 Actions marked "console = true" will be run in the built-in ninja
3568 "console" pool. They will have access to real stdin and stdout, and
3569 output will not be buffered by ninja. This can be useful for
3570 long-running actions with progress logs, or actions that require user
3571 input.
3572
3573 Only one console pool target can run at any one time in Ninja. Refer
3574 to the Ninja documentation on the console pool for more info.
3575
3576 ```
3577
3578 ### **Example**
3579
3580 ```
3581 action("long_action_with_progress_logs") {
3582 console = true
3583 }
3584
3585
3586 ```
3562 ## **data**: Runtime data file dependencies. 3587 ## **data**: Runtime data file dependencies.
3563 3588
3564 ``` 3589 ```
3565 Lists files or directories required to run the given target. These are 3590 Lists files or directories required to run the given target. These are
3566 typically data files or directories of data files. The paths are 3591 typically data files or directories of data files. The paths are
3567 interpreted as being relative to the current build file. Since these 3592 interpreted as being relative to the current build file. Since these
3568 are runtime dependencies, they do not affect which targets are built 3593 are runtime dependencies, they do not affect which targets are built
3569 or when. To declare input files to a script, use "inputs". 3594 or when. To declare input files to a script, use "inputs".
3570 3595
3571 Appearing in the "data" section does not imply any special handling 3596 Appearing in the "data" section does not imply any special handling
(...skipping 25 matching lines...) Expand all
3597 the current target. Such dependencies will be built and will be 3622 the current target. Such dependencies will be built and will be
3598 available at runtime. 3623 available at runtime.
3599 3624
3600 This is normally used for things like plugins or helper programs that 3625 This is normally used for things like plugins or helper programs that
3601 a target needs at runtime. 3626 a target needs at runtime.
3602 3627
3603 See also "gn help deps" and "gn help data". 3628 See also "gn help deps" and "gn help data".
3604 3629
3605 ``` 3630 ```
3606 3631
3607 ### **Example**: 3632 ### **Example**
3633
3608 ``` 3634 ```
3609 executable("foo") { 3635 executable("foo") {
3610 deps = [ "//base" ] 3636 deps = [ "//base" ]
3611 data_deps = [ "//plugins:my_runtime_plugin" ] 3637 data_deps = [ "//plugins:my_runtime_plugin" ]
3612 } 3638 }
3613 3639
3614 3640
3615 ``` 3641 ```
3616 ## **defines**: C preprocessor defines. 3642 ## **defines**: C preprocessor defines.
3617 3643
(...skipping 17 matching lines...) Expand all
3635 those configs appear in the list. 3661 those configs appear in the list.
3636 5. all_dependent_configs pulled from dependencies, in the order of 3662 5. all_dependent_configs pulled from dependencies, in the order of
3637 the "deps" list. This is done recursively. If a config appears 3663 the "deps" list. This is done recursively. If a config appears
3638 more than once, only the first occurance will be used. 3664 more than once, only the first occurance will be used.
3639 6. public_configs pulled from dependencies, in the order of the 3665 6. public_configs pulled from dependencies, in the order of the
3640 "deps" list. If a dependency is public, they will be applied 3666 "deps" list. If a dependency is public, they will be applied
3641 recursively. 3667 recursively.
3642 3668
3643 ``` 3669 ```
3644 3670
3645 ### **Example**: 3671 ### **Example**
3672
3646 ``` 3673 ```
3647 defines = [ "AWESOME_FEATURE", "LOG_LEVEL=3" ] 3674 defines = [ "AWESOME_FEATURE", "LOG_LEVEL=3" ]
3648 3675
3649 3676
3650 ``` 3677 ```
3651 ## **depfile**: [string] File name for input dependencies for actions. 3678 ## **depfile**: [string] File name for input dependencies for actions.
3652 3679
3653 ``` 3680 ```
3654 If nonempty, this string specifies that the current action or 3681 If nonempty, this string specifies that the current action or
3655 action_foreach target will generate the given ".d" file containing 3682 action_foreach target will generate the given ".d" file containing
3656 the dependencies of the input. Empty or unset means that the script 3683 the dependencies of the input. Empty or unset means that the script
3657 doesn't generate the files. 3684 doesn't generate the files.
3658 3685
3659 The .d file should go in the target output directory. If you have more 3686 The .d file should go in the target output directory. If you have more
3660 than one source file that the script is being run over, you can use 3687 than one source file that the script is being run over, you can use
3661 the output file expansions described in "gn help action_foreach" to 3688 the output file expansions described in "gn help action_foreach" to
3662 name the .d file according to the input. 3689 name the .d file according to the input.
3663 The format is that of a Makefile, and all of the paths should be 3690 The format is that of a Makefile, and all of the paths should be
3664 relative to the root build directory. 3691 relative to the root build directory.
3665 3692
3666 ``` 3693 ```
3667 3694
3668 ### **Example**: 3695 ### **Example**
3696
3669 ``` 3697 ```
3670 action_foreach("myscript_target") { 3698 action_foreach("myscript_target") {
3671 script = "myscript.py" 3699 script = "myscript.py"
3672 sources = [ ... ] 3700 sources = [ ... ]
3673 3701
3674 # Locate the depfile in the output directory named like the 3702 # Locate the depfile in the output directory named like the
3675 # inputs but with a ".d" appended. 3703 # inputs but with a ".d" appended.
3676 depfile = "$relative_target_output_dir/{{source_name}}.d" 3704 depfile = "$relative_target_output_dir/{{source_name}}.d"
3677 3705
3678 # Say our script uses "-o <d file>" to indicate the depfile. 3706 # Say our script uses "-o <d file>" to indicate the depfile.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3771 those configs appear in the list. 3799 those configs appear in the list.
3772 5. all_dependent_configs pulled from dependencies, in the order of 3800 5. all_dependent_configs pulled from dependencies, in the order of
3773 the "deps" list. This is done recursively. If a config appears 3801 the "deps" list. This is done recursively. If a config appears
3774 more than once, only the first occurance will be used. 3802 more than once, only the first occurance will be used.
3775 6. public_configs pulled from dependencies, in the order of the 3803 6. public_configs pulled from dependencies, in the order of the
3776 "deps" list. If a dependency is public, they will be applied 3804 "deps" list. If a dependency is public, they will be applied
3777 recursively. 3805 recursively.
3778 3806
3779 ``` 3807 ```
3780 3808
3781 ### **Example**: 3809 ### **Example**
3810
3782 ``` 3811 ```
3783 include_dirs = [ "src/include", "//third_party/foo" ] 3812 include_dirs = [ "src/include", "//third_party/foo" ]
3784 3813
3785 3814
3786 ``` 3815 ```
3787 ## **inputs**: Additional compile-time dependencies. 3816 ## **inputs**: Additional compile-time dependencies.
3788 3817
3789 ``` 3818 ```
3790 Inputs are compile-time dependencies of the current target. This means 3819 Inputs are compile-time dependencies of the current target. This means
3791 that all inputs must be available before compiling any of the sources 3820 that all inputs must be available before compiling any of the sources
3792 or executing any actions. 3821 or executing any actions.
3793 3822
3794 Inputs are typically only used for action and action_foreach targets. 3823 Inputs are typically only used for action and action_foreach targets.
3795 3824
3796 ``` 3825 ```
3797 3826
3798 ### **Inputs for actions** 3827 ### **Inputs for actions**
3799 3828
3800 ``` 3829 ```
3801 For action and action_foreach targets, inputs should be the inputs to 3830 For action and action_foreach targets, inputs should be the inputs to
3802 script that don't vary. These should be all .py files that the script 3831 script that don't vary. These should be all .py files that the script
3803 uses via imports (the main script itself will be an implcit dependency 3832 uses via imports (the main script itself will be an implcit dependency
3804 of the action so need not be listed). 3833 of the action so need not be listed).
3805 3834
3806 For action targets, inputs should be the entire set of inputs the 3835 For action targets, inputs and sources are treated the same, but from
3807 script needs. For action_foreach targets, inputs should be the set of 3836 a style perspective, it's recommended to follow the same rule as
3808 dependencies that don't change. These will be applied to each script 3837 action_foreach and put helper files in the inputs, and the data used
3809 invocation over the sources. 3838 by the script (if any) in sources.
3810 3839
3811 Note that another way to declare input dependencies from an action 3840 Note that another way to declare input dependencies from an action
3812 is to have the action write a depfile (see "gn help depfile"). This 3841 is to have the action write a depfile (see "gn help depfile"). This
3813 allows the script to dynamically write input dependencies, that might 3842 allows the script to dynamically write input dependencies, that might
3814 not be known until actually executing the script. This is more 3843 not be known until actually executing the script. This is more
3815 efficient than doing processing while running GN to determine the 3844 efficient than doing processing while running GN to determine the
3816 inputs, and is easier to keep in-sync than hardcoding the list. 3845 inputs, and is easier to keep in-sync than hardcoding the list.
3817 3846
3818 ``` 3847 ```
3819 3848
3849 ### **Script input gotchas**
3850
3851 ```
3852 It may be tempting to write a script that enumerates all files in a
3853 directory as inputs. Don't do this! Even if you specify all the files
3854 in the inputs or sources in the GN target (or worse, enumerate the
3855 files in an exec_script call when running GN, which will be slow), the
3856 dependencies will be broken.
3857
3858 The problem happens if a file is ever removed because the inputs are
3859 not listed on the command line to the script. Because the script
3860 hasn't changed and all inputs are up-to-date, the script will not
3861 re-run and you will get a stale build. Instead, either list all
3862 inputs on the command line to the script, or if there are many, create
3863 a separate list file that the script reads. As long as this file is
3864 listed in the inputs, the build will detect when it has changed in any
3865 way and the action will re-run.
3866
3867 ```
3868
3820 ### **Inputs for binary targets** 3869 ### **Inputs for binary targets**
3821 3870
3822 ``` 3871 ```
3823 Any input dependencies will be resolved before compiling any sources. 3872 Any input dependencies will be resolved before compiling any sources.
3824 Normally, all actions that a target depends on will be run before any 3873 Normally, all actions that a target depends on will be run before any
3825 files in a target are compiled. So if you depend on generated headers, 3874 files in a target are compiled. So if you depend on generated headers,
3826 you do not typically need to list them in the inputs section. 3875 you do not typically need to list them in the inputs section.
3827 3876
3877 Inputs for binary targets will be treated as order-only dependencies,
3878 meaning that they will be forced up-to-date before compiling or
3879 any files in the target, but changes in the inputs will not
3880 necessarily force the target to compile. This is because it is
3881 expected that the compiler will report the precise list of input
3882 dependencies required to recompile each file once the initial build
3883 is done.
3884
3828 ``` 3885 ```
3829 3886
3830 ### **Example** 3887 ### **Example**
3831 3888
3832 ``` 3889 ```
3833 action("myscript") { 3890 action("myscript") {
3834 script = "domything.py" 3891 script = "domything.py"
3835 inputs = [ "input.data" ] 3892 inputs = [ "input.data" ]
3836 } 3893 }
3837 3894
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3901 those configs appear in the list. 3958 those configs appear in the list.
3902 5. all_dependent_configs pulled from dependencies, in the order of 3959 5. all_dependent_configs pulled from dependencies, in the order of
3903 the "deps" list. This is done recursively. If a config appears 3960 the "deps" list. This is done recursively. If a config appears
3904 more than once, only the first occurance will be used. 3961 more than once, only the first occurance will be used.
3905 6. public_configs pulled from dependencies, in the order of the 3962 6. public_configs pulled from dependencies, in the order of the
3906 "deps" list. If a dependency is public, they will be applied 3963 "deps" list. If a dependency is public, they will be applied
3907 recursively. 3964 recursively.
3908 3965
3909 ``` 3966 ```
3910 3967
3911 ### **Example**: 3968 ### **Example**
3969
3912 ``` 3970 ```
3913 lib_dirs = [ "/usr/lib/foo", "lib/doom_melon" ] 3971 lib_dirs = [ "/usr/lib/foo", "lib/doom_melon" ]
3914 3972
3915 3973
3916 ``` 3974 ```
3917 ## **libs**: Additional libraries to link. 3975 ## **libs**: Additional libraries to link.
3918 3976
3919 ``` 3977 ```
3920 A list of strings. 3978 A list of strings.
3921 3979
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3954 those configs appear in the list. 4012 those configs appear in the list.
3955 5. all_dependent_configs pulled from dependencies, in the order of 4013 5. all_dependent_configs pulled from dependencies, in the order of
3956 the "deps" list. This is done recursively. If a config appears 4014 the "deps" list. This is done recursively. If a config appears
3957 more than once, only the first occurance will be used. 4015 more than once, only the first occurance will be used.
3958 6. public_configs pulled from dependencies, in the order of the 4016 6. public_configs pulled from dependencies, in the order of the
3959 "deps" list. If a dependency is public, they will be applied 4017 "deps" list. If a dependency is public, they will be applied
3960 recursively. 4018 recursively.
3961 4019
3962 ``` 4020 ```
3963 4021
3964 ### **Examples**: 4022 ### **Examples**
4023
3965 ``` 4024 ```
3966 On Windows: 4025 On Windows:
3967 libs = [ "ctl3d.lib" ] 4026 libs = [ "ctl3d.lib" ]
3968 On Linux: 4027 On Linux:
3969 libs = [ "ld" ] 4028 libs = [ "ld" ]
3970 4029
3971 4030
3972 ``` 4031 ```
3973 ## **output_extension**: Value to use for the output's file extension. 4032 ## **output_extension**: Value to use for the output's file extension.
3974 4033
3975 ``` 4034 ```
3976 Normally the file extension for a target is based on the target 4035 Normally the file extension for a target is based on the target
3977 type and the operating system, but in rare cases you will need to 4036 type and the operating system, but in rare cases you will need to
3978 override the name (for example to use "libfreetype.so.6" instead 4037 override the name (for example to use "libfreetype.so.6" instead
3979 of libfreetype.so on Linux). 4038 of libfreetype.so on Linux).
3980 4039
4040 This value should not include a leading dot. If undefined or empty,
4041 the default_output_extension specified on the tool will be used.
4042 The output_extension will be used in the "{{output_extension}}"
4043 expansion which the linker tool will generally use to specify the
4044 output file name. See "gn help tool".
4045
4046 ```
4047
4048 ### **Example**
4049
4050 ```
4051 shared_library("freetype") {
4052 if (is_linux) {
4053 # Call the output "libfreetype.so.6"
4054 output_extension = "so.6"
4055 }
4056 ...
4057 }
4058
4059 # On Windows, generate a "mysettings.cpl" control panel applet.
4060 # Control panel applets are actually special shared libraries.
4061 if (is_win) {
4062 shared_library("mysettings") {
4063 output_extension = "cpl"
4064 ...
4065 }
4066 }
4067
4068
3981 ``` 4069 ```
3982 ## **output_name**: Define a name for the output file other than the default. 4070 ## **output_name**: Define a name for the output file other than the default.
3983 4071
3984 ``` 4072 ```
3985 Normally the output name of a target will be based on the target name, 4073 Normally the output name of a target will be based on the target name,
3986 so the target "//foo/bar:bar_unittests" will generate an output 4074 so the target "//foo/bar:bar_unittests" will generate an output
3987 file such as "bar_unittests.exe" (using Windows as an example). 4075 file such as "bar_unittests.exe" (using Windows as an example).
3988 4076
3989 Sometimes you will want an alternate name to avoid collisions or 4077 Sometimes you will want an alternate name to avoid collisions or
3990 if the internal name isn't appropriate for public distribution. 4078 if the internal name isn't appropriate for public distribution.
3991 4079
3992 The output name should have no extension or prefixes, these will be 4080 The output name should have no extension or prefixes, these will be
3993 added using the default system rules. For example, on Linux an output 4081 added using the default system rules. For example, on Linux an output
3994 name of "foo" will produce a shared library "libfoo.so". 4082 name of "foo" will produce a shared library "libfoo.so". There
4083 is no way to override the output prefix of a linker tool on a per-
4084 target basis. If you need more flexibility, create a copy target
4085 to produce the file you want.
3995 4086
3996 This variable is valid for all binary output target types. 4087 This variable is valid for all binary output target types.
3997 4088
3998 ``` 4089 ```
3999 4090
4000 ### **Example**: 4091 ### **Example**
4092
4001 ``` 4093 ```
4002 static_library("doom_melon") { 4094 static_library("doom_melon") {
4003 output_name = "fluffy_bunny" 4095 output_name = "fluffy_bunny"
4004 } 4096 }
4005 4097
4006 4098
4007 ``` 4099 ```
4008 ## **outputs**: Output files for actions and copy targets. 4100 ## **outputs**: Output files for actions and copy targets.
4009 4101
4010 ``` 4102 ```
4011 Outputs is valid for "copy", "action", and "action_foreach" 4103 Outputs is valid for "copy", "action", and "action_foreach"
4012 target types and indicates the resulting files. The values may contain 4104 target types and indicates the resulting files. Outputs must always
4013 source expansions to generate the output names from the sources (see 4105 refer to files in the build directory.
4014 "gn help source_expansion").
4015 4106
4016 For copy targets, the outputs is the destination for the copied 4107 copy
4017 file(s). For actions, the outputs should be the list of files 4108 Copy targets should have exactly one entry in the outputs list. If
4018 generated by the script. 4109 there is exactly one source, this can be a literal file name or a
4110 source expansion. If there is more than one source, this must
4111 contain a source expansion to map a single input name to a single
4112 output name. See "gn help copy".
4113
4114 action_foreach
4115 Action_foreach targets must always use source expansions to map
4116 input files to output files. There can be more than one output,
4117 which means that each invocation of the script will produce a set of
4118 files (presumably based on the name of the input file). See
4119 "gn help action_foreach".
4120
4121 action
4122 Action targets (excluding action_foreach) must list literal output
4123 file(s) with no source expansions. See "gn help action".
4019 4124
4020 4125
4021 ``` 4126 ```
4022 ## **precompiled_header**: [string] Header file to precompile. 4127 ## **precompiled_header**: [string] Header file to precompile.
4023 4128
4024 ``` 4129 ```
4025 Precompiled headers will be used when a target specifies this 4130 Precompiled headers will be used when a target specifies this
4026 value, or a config applying to this target specifies this value. 4131 value, or a config applying to this target specifies this value.
4027 In addition, the tool corresponding to the source files must also 4132 In addition, the tool corresponding to the source files must also
4028 specify precompiled headers (see "gn help tool"). The tool 4133 specify precompiled headers (see "gn help tool"). The tool
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
4110 a dependency A -> B -> C, then A can include C's public headers. 4215 a dependency A -> B -> C, then A can include C's public headers.
4111 However, the same is NOT true of visibility, so unless A is in C's 4216 However, the same is NOT true of visibility, so unless A is in C's
4112 visibility list, the include will be rejected. 4217 visibility list, the include will be rejected.
4113 4218
4114 GN only knows about files declared in the "sources" and "public" 4219 GN only knows about files declared in the "sources" and "public"
4115 sections of targets. If a file is included that is not known to the 4220 sections of targets. If a file is included that is not known to the
4116 build, it will be allowed. 4221 build, it will be allowed.
4117 4222
4118 ``` 4223 ```
4119 4224
4120 ### **Examples**: 4225 ### **Examples**
4226
4121 ``` 4227 ```
4122 These exact files are public: 4228 These exact files are public:
4123 public = [ "foo.h", "bar.h" ] 4229 public = [ "foo.h", "bar.h" ]
4124 4230
4125 No files are public (no targets may include headers from this one): 4231 No files are public (no targets may include headers from this one):
4126 public = [] 4232 public = []
4127 4233
4128 4234
4129 ``` 4235 ```
4130 ## **public_configs**: Configs to be applied on dependents. 4236 ## **public_configs**: Configs to be applied on dependents.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
4227 ``` 4333 ```
4228 An absolute or buildfile-relative file name of a Python script to run 4334 An absolute or buildfile-relative file name of a Python script to run
4229 for a action and action_foreach targets (see "gn help action" and 4335 for a action and action_foreach targets (see "gn help action" and
4230 "gn help action_foreach"). 4336 "gn help action_foreach").
4231 4337
4232 4338
4233 ``` 4339 ```
4234 ## **sources**: Source files for a target 4340 ## **sources**: Source files for a target
4235 4341
4236 ``` 4342 ```
4237 A list of files relative to the current buildfile. 4343 A list of files. Non-absolute paths will be resolved relative to the
4344 current build file.
4345
4346 ```
4347
4348 ### **Sources for binary targets**
4349
4350 ```
4351 For binary targets (source sets, executables, and libraries), the
4352 known file types will be compiled with the associated tools. Unknown
4353 file types and headers will be skipped. However, you should still
4354 list all C/C+ header files so GN knows about the existance of those
4355 files for the purposes of include checking.
4356
4357 As a special case, a file ending in ".def" will be treated as a
4358 Windows module definition file. It will be appended to the link
4359 line with a preceeding "/DEF:" string. There must be at most one
4360 .def file in a target and they do not cross dependency boundaries
4361 (so specifying a .def file in a static library or source set will have
4362 no effect on the executable or shared library they're linked into).
4363
4364 ```
4365
4366 ### **Sources for non-binary targets**
4367
4368 ```
4369 action_foreach
4370 The sources are the set of files that the script will be executed
4371 over. The script will run once per file.
4372
4373 action
4374 The sources will be treated the same as inputs. See "gn help inputs"
4375 for more information and usage advice.
4376
4377 copy
4378 The source are the source files to copy.
4238 4379
4239 4380
4240 ``` 4381 ```
4241 ## **testonly**: Declares a target must only be used for testing. 4382 ## **testonly**: Declares a target must only be used for testing.
4242 4383
4243 ``` 4384 ```
4244 Boolean. Defaults to false. 4385 Boolean. Defaults to false.
4245 4386
4246 When a target is marked "testonly = true", it must only be depended 4387 When a target is marked "testonly = true", it must only be depended
4247 on by other test-only targets. Otherwise, GN will issue an error 4388 on by other test-only targets. Otherwise, GN will issue an error
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
4917 ** -q**: Quiet mode. Don't print output on success. 5058 ** -q**: Quiet mode. Don't print output on success.
4918 ** \--root**: Explicitly specify source root. 5059 ** \--root**: Explicitly specify source root.
4919 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file. 5060 ** \--runtime-deps-list-file**: Save runtime dependencies for targets in file.
4920 ** \--threads**: Specify number of worker threads. 5061 ** \--threads**: Specify number of worker threads.
4921 ** \--time**: Outputs a summary of how long everything took. 5062 ** \--time**: Outputs a summary of how long everything took.
4922 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file. 5063 ** \--tracelog**: Writes a Chrome-compatible trace log to the given file.
4923 ** -v**: Verbose logging. 5064 ** -v**: Verbose logging.
4924 ** \--version**: Prints the GN version number and exits. 5065 ** \--version**: Prints the GN version number and exits.
4925 5066
4926 ``` 5067 ```
OLDNEW
« no previous file with comments | « no previous file | tools/gn/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698