| OLD | NEW |
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 const char kPythonPath[] = "python_path"; | 72 const char kPythonPath[] = "python_path"; |
| 73 const char kPythonPath_HelpShort[] = | 73 const char kPythonPath_HelpShort[] = |
| 74 "python_path: [string] Absolute path of Python."; | 74 "python_path: [string] Absolute path of Python."; |
| 75 const char kPythonPath_Help[] = | 75 const char kPythonPath_Help[] = |
| 76 "python_path: Absolute path of Python.\n" | 76 "python_path: Absolute path of Python.\n" |
| 77 "\n" | 77 "\n" |
| 78 " Normally used in toolchain definitions if running some command\n" | 78 " Normally used in toolchain definitions if running some command\n" |
| 79 " requires Python. You will normally not need this when invoking scripts\n" | 79 " requires Python. You will normally not need this when invoking scripts\n" |
| 80 " since GN automatically finds it for you.\n"; | 80 " since GN automatically finds it for you.\n"; |
| 81 | 81 |
| 82 const char kRelativeBuildToSourceRootDir[] = | |
| 83 "relative_build_to_source_root_dir"; | |
| 84 const char kRelativeBuildToSourceRootDir_HelpShort[] = | |
| 85 "relative_build_to_source_root_dir: [string] Relative location of root"; | |
| 86 const char kRelativeBuildToSourceRootDir_Help[] = | |
| 87 "relative_build_to_source_root_dir: Relative location of root.\n" | |
| 88 "\n" | |
| 89 " A relative path from the build directory to the root of the source\n" | |
| 90 " tree, with no terminating slash. The build directory will be the\n" | |
| 91 " directory when executing normal build commands (except for scripts).\n" | |
| 92 "\n" | |
| 93 " If the checkout is in \"/foo/src/\" and the build directory is in\n" | |
| 94 " \"/foo/src/out/Debug/\" then the relative build to source root dir\n" | |
| 95 " will be \"../..\".\n" | |
| 96 "\n" | |
| 97 " See also relative_source_root_dir.\n" | |
| 98 "\n" | |
| 99 "Example:\n" | |
| 100 " This is typically used to invoke tools checked out in the tree:\n" | |
| 101 "\n" | |
| 102 " tool(\"link\") {\n" | |
| 103 " command = \"$relative_build_to_source_root_dir/third_party/gold/ld\n" | |
| 104 " }\n"; | |
| 105 | |
| 106 const char kRelativeRootGenDir[] = "relative_root_gen_dir"; | |
| 107 const char kRelativeRootGenDir_HelpShort[] = | |
| 108 "relative_root_gen_dir: [string] Relative root dir for generated files."; | |
| 109 const char kRelativeRootGenDir_Help[] = | |
| 110 "relative_root_gen_dir: Relative root for generated files.\n" | |
| 111 "\n" | |
| 112 " Relative path from the directory of the current build file to the\n" | |
| 113 " root of the generated file directory hierarchy for the current\n" | |
| 114 " toolchain.\n" | |
| 115 "\n" | |
| 116 " Generally scripts should use \"relative_target_output_dir\" instead.\n" | |
| 117 "\n" | |
| 118 " See also \"root_gen_dir\".\n" | |
| 119 "\n" | |
| 120 "Example:\n" | |
| 121 "\n" | |
| 122 " If your current build file is in \"//tools\", you might write\n" | |
| 123 " args = [ \"$relative_root_gen_dir/output.txt\" ]\n"; | |
| 124 | |
| 125 const char kRelativeRootOutputDir[] = "relative_root_output_dir"; | |
| 126 const char kRelativeRootOutputDir_HelpShort[] = | |
| 127 "relative_root_output_dir: [string] Relative dir for output files."; | |
| 128 const char kRelativeRootOutputDir_Help[] = | |
| 129 "relative_root_output_dir: Relative dir for output files.\n" | |
| 130 "\n" | |
| 131 " Relative path from the directory of the current build file to the\n" | |
| 132 " current toolchain's root build output directory.\n" | |
| 133 "\n" | |
| 134 " Generally scripts should use \"relative_target_output_dir\" instead.\n"; | |
| 135 | |
| 136 extern const char kRelativeSourceRootDir[] = "relative_source_root_dir"; | |
| 137 extern const char kRelativeSourceRootDir_HelpShort[] = | |
| 138 "relative_source_root_dir: [string] Relative location of root."; | |
| 139 extern const char kRelativeSourceRootDir_Help[] = | |
| 140 "relative_source_root_dir: Relative location of root.\n" | |
| 141 "\n" | |
| 142 " A relative path from the current source directory to the root of the\n" | |
| 143 " source tree, with no terminating slash. The build directory will be\n" | |
| 144 " the directory when executing scripts.\n" | |
| 145 "\n" | |
| 146 " If the checkout is in \"/foo/src/\" and the build directory is in\n" | |
| 147 " \"/foo/src/out/Debug/\" then the relative build to source root dir\n" | |
| 148 " will be \"../..\".\n" | |
| 149 "\n" | |
| 150 " See also relative_build_to_source_root_dir.\n" | |
| 151 "\n" | |
| 152 "Example:\n" | |
| 153 " This is typically used to invoke tools checked out in the tree:\n" | |
| 154 "\n" | |
| 155 " tool(\"link\") {\n" | |
| 156 " command = \"$relative_build_to_source_root_dir/third_party/gold/ld\n" | |
| 157 " }\n"; | |
| 158 | |
| 159 const char kRelativeTargetGenDir[] = "relative_target_gen_dir"; | |
| 160 const char kRelativeTargetGenDir_HelpShort[] = | |
| 161 "relative_target_gen_dir: [string] Relative dir for generated files."; | |
| 162 const char kRelativeTargetGenDir_Help[] = | |
| 163 "relative_target_gen_dir: Relative dir for generated files.\n" | |
| 164 "\n" | |
| 165 " Relative path from the directory of the current build file to the\n" | |
| 166 " current target's generated file directory.\n" | |
| 167 "\n" | |
| 168 " Normally used when invoking scripts (the current directory of which is\n" | |
| 169 " that of the invoking buildfile) that need to write files.\n" | |
| 170 "\n" | |
| 171 " Scripts generating final rather than intermediate files should use the\n" | |
| 172 " \"relative_target_output_dir\" instead.\n" | |
| 173 "\n" | |
| 174 " See also \"target_gen_dir\".\n" | |
| 175 "\n" | |
| 176 "Example:\n" | |
| 177 "\n" | |
| 178 " If your current build file is in \"//tools\", you might write\n" | |
| 179 " args = [ \"$relative_root_gen_dir/output.txt\" ]\n"; | |
| 180 | |
| 181 const char kRelativeTargetOutputDir[] = "relative_target_output_dir"; | |
| 182 const char kRelativeTargetOutputDir_HelpShort[] = | |
| 183 "relative_target_output_dir: [string] Relative dir for build results."; | |
| 184 const char kRelativeTargetOutputDir_Help[] = | |
| 185 "relative_target_output_dir: Relative dir for build results." | |
| 186 "\n" | |
| 187 " Relative path from the directory of the current build file to the\n" | |
| 188 " current target's generated file directory.\n" | |
| 189 "\n" | |
| 190 " Normally used when invoking scripts (the current directory of which is\n" | |
| 191 " that of the invoking buildfile) that need to write files.\n" | |
| 192 "\n" | |
| 193 " Scripts generating intermediate files rather than final output files\n" | |
| 194 " should use the \"relative_target_output_dir\" instead.\n" | |
| 195 "\n" | |
| 196 "Example:\n" | |
| 197 "\n" | |
| 198 " If your current build file is in \"//tools\", you might write\n" | |
| 199 " args = [ \"$relative_target_output_dir/final.lib\" ]\n"; | |
| 200 | |
| 201 const char kRootGenDir[] = "root_gen_dir"; | 82 const char kRootGenDir[] = "root_gen_dir"; |
| 202 const char kRootGenDir_HelpShort[] = | 83 const char kRootGenDir_HelpShort[] = |
| 203 "root_gen_dir: [string] Absolute root dir for generated files."; | 84 "root_gen_dir: [string] Directory for the toolchain's generated files."; |
| 204 const char kRootGenDir_Help[] = | 85 const char kRootGenDir_Help[] = |
| 205 "root_gen_dir: Absolute root dir for generated files.\n" | 86 "root_gen_dir: Directory for the toolchain's generated files.\n" |
| 206 "\n" | 87 "\n" |
| 207 " Absolute path to the root of the generated output directory tree for\n" | 88 " Absolute path to the root of the generated output directory tree for\n" |
| 208 " the current toolchain. An example value might be \"//out/Debug/gen\".\n" | 89 " the current toolchain. An example value might be \"//out/Debug/gen\".\n" |
| 209 " It will not have a trailing slash.\n" | 90 " It will not have a trailing slash.\n" |
| 210 "\n" | 91 "\n" |
| 211 " This is primarily useful for setting up include paths for generated\n" | 92 " This is primarily useful for setting up include paths for generated\n" |
| 212 " files. Scripts will want the \"relative_root_gen_dir\" instead\n" | 93 " files. If you are passing this to a script, you will want to pass it\n" |
| 213 " which will be relative to the scripts' current directory.\n" | 94 " through to_build_path() (see \"gn help to_build_path\") to convert it\n" |
| 95 " to be relative to the build directory.\n" |
| 214 "\n" | 96 "\n" |
| 215 " See also \"relative_root_gen_dir\" and \"target_gen_dir\".\n"; | 97 " See also \"target_gen_dir\" which is usually a better location for\n" |
| 98 " generated files. It will be inside the root generated dir.\n"; |
| 99 |
| 100 const char kRootOutDir[] = "root_out_dir"; |
| 101 const char kRootOutDir_HelpShort[] = |
| 102 "root_out_dir: [string] Root directory for toolchain output files."; |
| 103 const char kRootOutDir_Help[] = |
| 104 "root_out_dir: [string] Root directory for toolchain output files.\n" |
| 105 "\n" |
| 106 " Absolute path to the root of the output directory tree for the current\n" |
| 107 " toolchain. An example value might be \"//out/Debug/gen\". It will not\n" |
| 108 " have a trailing slash.\n" |
| 109 "\n" |
| 110 " This is primarily useful for setting up script calls. If you are\n" |
| 111 " passing this to a script, you will want to pass it through\n" |
| 112 " to_build_path() (see \"gn help to_build_path\") to convert it\n" |
| 113 " to be relative to the build directory.\n" |
| 114 "\n" |
| 115 " See also \"target_out_dir\" which is usually a better location for\n" |
| 116 " output files. It will be inside the root output dir.\n" |
| 117 "\n" |
| 118 "Example:\n" |
| 119 "\n" |
| 120 " custom(\"myscript\") {\n" |
| 121 " # Pass the output dir to the script.\n" |
| 122 " args = [ \"-o\", to_build_path(root_out_dir) ]\n" |
| 123 " }\n"; |
| 216 | 124 |
| 217 const char kTargetGenDir[] = "target_gen_dir"; | 125 const char kTargetGenDir[] = "target_gen_dir"; |
| 218 const char kTargetGenDir_HelpShort[] = | 126 const char kTargetGenDir_HelpShort[] = |
| 219 "target_gen_dir: [string] Absolute dir for generated files."; | 127 "target_gen_dir: [string] Directory for a target's generated files."; |
| 220 const char kTargetGenDir_Help[] = | 128 const char kTargetGenDir_Help[] = |
| 221 "target_gen_dir: Absolute dir for generated files.\n" | 129 "target_gen_dir: Directory for a target's generated files.\n" |
| 222 "\n" | 130 "\n" |
| 223 " Absolute path to the target's generated file directory. If your\n" | 131 " Absolute path to the target's generated file directory. If your\n" |
| 224 " current target is in \"//tools/doom_melon\" then this value might be\n" | 132 " current target is in \"//tools/doom_melon\" then this value might be\n" |
| 225 " \"//out/Debug/gen/tools/doom_melon\". It will not have a trailing\n" | 133 " \"//out/Debug/gen/tools/doom_melon\". It will not have a trailing\n" |
| 226 " slash.\n" | 134 " slash.\n" |
| 227 "\n" | 135 "\n" |
| 228 " Scripts generating files will generally want the relative version of\n" | 136 " This is primarily useful for setting up include paths for generated\n" |
| 229 " this instead: \"relative_target_gen_dir\".\n" | 137 " files. If you are passing this to a script, you will want to pass it\n" |
| 138 " through to_build_path() (see \"gn help to_build_path\") to convert it\n" |
| 139 " to be relative to the build directory.\n" |
| 140 "\n" |
| 141 " See also \"gn help root_gen_dir\".\n" |
| 230 "\n" | 142 "\n" |
| 231 "Example:\n" | 143 "Example:\n" |
| 232 "\n" | 144 "\n" |
| 233 " # Add the gen directory to the include path.\n" | 145 " custom(\"myscript\") {\n" |
| 234 " args = [ target_gen_dir ]\n"; | 146 " # Pass the generated output dir to the script.\n" |
| 147 " args = [ \"-o\", to_build_path(target_gen_dir) ]\n" |
| 148 " }\n"; |
| 149 |
| 150 const char kTargetOutDir[] = "target_out_dir"; |
| 151 const char kTargetOutDir_HelpShort[] = |
| 152 "target_out_dir: [string] Directory for target output files."; |
| 153 const char kTargetOutDir_Help[] = |
| 154 "target_out_dir: [string] Directory for target output files." |
| 155 "\n" |
| 156 " Absolute path to the target's generated file directory. If your\n" |
| 157 " current target is in \"//tools/doom_melon\" then this value might be\n" |
| 158 " \"//out/Debug/obj/tools/doom_melon\". It will not have a trailing\n" |
| 159 " slash.\n" |
| 160 "\n" |
| 161 " This is primarily useful for setting up arguments for calling\n" |
| 162 " scripts. If you are passing this to a script, you will want to pass it\n" |
| 163 " through to_build_path() (see \"gn help to_build_path\") to convert it\n" |
| 164 " to be relative to the build directory.\n" |
| 165 "\n" |
| 166 " See also \"gn help root_out_dir\".\n" |
| 167 "\n" |
| 168 "Example:\n" |
| 169 "\n" |
| 170 " custom(\"myscript\") {\n" |
| 171 " # Pass the output dir to the script.\n" |
| 172 " args = [ \"-o\", to_build_path(target_out_dir) ]\n" |
| 173 " }\n"; |
| 235 | 174 |
| 236 // Target variables ------------------------------------------------------------ | 175 // Target variables ------------------------------------------------------------ |
| 237 | 176 |
| 238 const char kAllDependentConfigs[] = "all_dependent_configs"; | 177 const char kAllDependentConfigs[] = "all_dependent_configs"; |
| 239 const char kAllDependentConfigs_HelpShort[] = | 178 const char kAllDependentConfigs_HelpShort[] = |
| 240 "all_dependent_configs: [label list] Configs to be forced on dependents."; | 179 "all_dependent_configs: [label list] Configs to be forced on dependents."; |
| 241 const char kAllDependentConfigs_Help[] = | 180 const char kAllDependentConfigs_Help[] = |
| 242 "all_dependent_configs: Configs to be forced on dependents.\n" | 181 "all_dependent_configs: Configs to be forced on dependents.\n" |
| 243 "\n" | 182 "\n" |
| 244 " A list of config labels.\n" | 183 " A list of config labels.\n" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 const VariableInfoMap& GetBuiltinVariables() { | 571 const VariableInfoMap& GetBuiltinVariables() { |
| 633 static VariableInfoMap info_map; | 572 static VariableInfoMap info_map; |
| 634 if (info_map.empty()) { | 573 if (info_map.empty()) { |
| 635 INSERT_VARIABLE(CurrentToolchain) | 574 INSERT_VARIABLE(CurrentToolchain) |
| 636 INSERT_VARIABLE(DefaultToolchain) | 575 INSERT_VARIABLE(DefaultToolchain) |
| 637 INSERT_VARIABLE(IsLinux) | 576 INSERT_VARIABLE(IsLinux) |
| 638 INSERT_VARIABLE(IsMac) | 577 INSERT_VARIABLE(IsMac) |
| 639 INSERT_VARIABLE(IsPosix) | 578 INSERT_VARIABLE(IsPosix) |
| 640 INSERT_VARIABLE(IsWin) | 579 INSERT_VARIABLE(IsWin) |
| 641 INSERT_VARIABLE(PythonPath) | 580 INSERT_VARIABLE(PythonPath) |
| 642 INSERT_VARIABLE(RelativeBuildToSourceRootDir) | |
| 643 INSERT_VARIABLE(RelativeRootGenDir) | |
| 644 INSERT_VARIABLE(RelativeRootOutputDir) | |
| 645 INSERT_VARIABLE(RelativeSourceRootDir) | |
| 646 INSERT_VARIABLE(RelativeTargetGenDir) | |
| 647 INSERT_VARIABLE(RelativeTargetOutputDir) | |
| 648 INSERT_VARIABLE(RootGenDir) | 581 INSERT_VARIABLE(RootGenDir) |
| 582 INSERT_VARIABLE(RootOutDir) |
| 649 INSERT_VARIABLE(TargetGenDir) | 583 INSERT_VARIABLE(TargetGenDir) |
| 584 INSERT_VARIABLE(TargetOutDir) |
| 650 } | 585 } |
| 651 return info_map; | 586 return info_map; |
| 652 } | 587 } |
| 653 | 588 |
| 654 const VariableInfoMap& GetTargetVariables() { | 589 const VariableInfoMap& GetTargetVariables() { |
| 655 static VariableInfoMap info_map; | 590 static VariableInfoMap info_map; |
| 656 if (info_map.empty()) { | 591 if (info_map.empty()) { |
| 657 INSERT_VARIABLE(AllDependentConfigs) | 592 INSERT_VARIABLE(AllDependentConfigs) |
| 658 INSERT_VARIABLE(Cflags) | 593 INSERT_VARIABLE(Cflags) |
| 659 INSERT_VARIABLE(CflagsC) | 594 INSERT_VARIABLE(CflagsC) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 672 INSERT_VARIABLE(OutputName) | 607 INSERT_VARIABLE(OutputName) |
| 673 INSERT_VARIABLE(SourcePrereqs) | 608 INSERT_VARIABLE(SourcePrereqs) |
| 674 INSERT_VARIABLE(Sources) | 609 INSERT_VARIABLE(Sources) |
| 675 } | 610 } |
| 676 return info_map; | 611 return info_map; |
| 677 } | 612 } |
| 678 | 613 |
| 679 #undef INSERT_VARIABLE | 614 #undef INSERT_VARIABLE |
| 680 | 615 |
| 681 } // namespace variables | 616 } // namespace variables |
| OLD | NEW |