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

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

Issue 914873002: Rework handling of os and cpu_arch in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« tools/gn/misc/vim/syntax/gn.vim ('K') | « tools/gn/variables.h ('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 const char kBuildCpuArch[] = "build_cpu_arch";
11 const char kBuildCpuArch_HelpShort[] =
12 "build_cpu_arch: [string] The processor architecture that GN is "
13 "running on.";
14 const char kBuildCpuArch_Help[] =
15 "build_cpu_arch: The processor architecture that GN is running on.\n"
16 "\n"
17 " This value is used to set the initial value for \"cpu_arch\" (see\n"
18 " \"gn help cpu_arch\") but otherwise should usually be treated as\n"
19 " read-only. This is exposed so that cross-compile toolchains can still\n"
20 " access the host architecture when needed, and is overridable to handle\n"
21 " unusual cases where there might be multiple plausible values for the\n"
22 " host architecture (e.g., if you can do either 32-bit or 64-bit builds.\n"
scottmg 2015/02/11 03:06:20 ) missing here
Dirk Pranke 2015/02/11 22:51:11 Acknowledged.
23 "\n"
24 "Some possible values:\n"
25 " - \"x64\"\n"
26 " - \"x86\"\n";
27
28 const char kBuildOs[] = "build_os";
29 const char kBuildOs_HelpShort[] =
30 "build_os: [string] The default value for the \"os\" variable.";
31 const char kBuildOs_Help[] =
32 "build_os: [string] The default value for the \"os\" variable.\n"
33 "\n"
34 " This value has the same definition as \"os\" (see \"gn help os\") but\n"
35 " should be treated as read-only. This is so the build can override\n"
36 " the \"os\" variable for doing cross-compiles, but can still access\n"
37 " the host build system's operating system type.\n"
38 "\n"
39 "Some possible values:\n"
40 " - \"linux\"\n"
41 " - \"mac\"\n"
42 " - \"win\"\n";
10 43
11 const char kCpuArch[] = "cpu_arch"; 44 const char kCpuArch[] = "cpu_arch";
12 const char kCpuArch_HelpShort[] = 45 const char kCpuArch_HelpShort[] =
13 "cpu_arch: [string] Current processor architecture."; 46 "cpu_arch: [string] The processor architecture of the current toolchain.";
14 const char kCpuArch_Help[] = 47 const char kCpuArch_Help[] =
15 "cpu_arch: Current processor architecture.\n" 48 "cpu_arch: The processor architecture of the current toolchain.\n"
16 "\n" 49 "\n"
17 " The initial value is based on the current architecture of the host\n" 50 " The build configuration usually sets this value based on\n"
18 " system. However, the build configuration can set this to any value.\n" 51 " \"build_cpu_arch\" (see \"gn help build_cpu_arch\") and then threads\n"
52 " this through the toolchain definitions to ensure that it always\n"
53 " reflects the appropriate value.\n"
19 "\n" 54 "\n"
20 " This value is not used internally by GN for any purpose, so you can\n" 55 " This value is not used internally by GN for any purpose, so you can\n"
21 " set it to whatever value is relevant to your build.\n" 56 " set it to whatever value is relevant to your build, but where \n"
22 "\n" 57 " you should stick to a list of common values for consistency. See\n"
23 "Possible initial values set by GN:\n" 58 " \"gn help target_cpu_arch\" for the list.\n"
24 " - \"x86\"\n" 59 "\n";
25 " - \"x64\"\n"
26 " - \"arm\"\n"
27 " - \"mipsel\"\n";
28 60
29 const char kCurrentToolchain[] = "current_toolchain"; 61 const char kCurrentToolchain[] = "current_toolchain";
30 const char kCurrentToolchain_HelpShort[] = 62 const char kCurrentToolchain_HelpShort[] =
31 "current_toolchain: [string] Label of the current toolchain."; 63 "current_toolchain: [string] Label of the current toolchain.";
32 const char kCurrentToolchain_Help[] = 64 const char kCurrentToolchain_Help[] =
33 "current_toolchain: Label of the current toolchain.\n" 65 "current_toolchain: Label of the current toolchain.\n"
34 "\n" 66 "\n"
35 " A fully-qualified label representing the current toolchain. You can\n" 67 " A fully-qualified label representing the current toolchain. You can\n"
36 " use this to make toolchain-related decisions in the build. See also\n" 68 " use this to make toolchain-related decisions in the build. See also\n"
37 " \"default_toolchain\".\n" 69 " \"default_toolchain\".\n"
38 "\n" 70 "\n"
39 "Example:\n" 71 "Example:\n"
40 "\n" 72 "\n"
41 " if (current_toolchain == \"//build:64_bit_toolchain\") {\n" 73 " if (current_toolchain == \"//build:64_bit_toolchain\") {\n"
42 " executable(\"output_thats_64_bit_only\") {\n" 74 " executable(\"output_thats_64_bit_only\") {\n"
43 " ...\n"; 75 " ...\n";
44 76
45 const char kBuildCpuArch[] = "build_cpu_arch";
46 const char kBuildCpuArch_HelpShort[] =
47 "build_cpu_arch: [string] The default value for the \"cpu_arch\" "
48 "variable.";
49 const char kBuildCpuArch_Help[] =
50 "build_cpu_arch: The default value for the \"cpu_arch\" variable.\n"
51 "\n"
52 " This value has the same definition as \"cpu_arch\" (see\n"
53 " \"gn help cpu_arch\") but should be treated as read-only. This is so\n"
54 " the build can override the \"cpu_arch\" variable for doing\n"
55 " cross-compiles, but can still access the host build system's CPU\n"
56 " architecture.\n";
57
58 const char kBuildOs[] = "build_os";
59 const char kBuildOs_HelpShort[] =
60 "build_os: [string] The default value for the \"os\" variable.";
61 const char kBuildOs_Help[] =
62 "build_os: [string] The default value for the \"os\" variable.\n"
63 "\n"
64 " This value has the same definition as \"os\" (see \"gn help os\") but\n"
65 " should be treated as read-only. This is so the build can override\n"
66 " the \"os\" variable for doing cross-compiles, but can still access\n"
67 " the host build system's operating system type.\n";
68
69 const char kDefaultToolchain[] = "default_toolchain"; 77 const char kDefaultToolchain[] = "default_toolchain";
70 const char kDefaultToolchain_HelpShort[] = 78 const char kDefaultToolchain_HelpShort[] =
71 "default_toolchain: [string] Label of the default toolchain."; 79 "default_toolchain: [string] Label of the default toolchain.";
72 const char kDefaultToolchain_Help[] = 80 const char kDefaultToolchain_Help[] =
73 "default_toolchain: [string] Label of the default toolchain.\n" 81 "default_toolchain: [string] Label of the default toolchain.\n"
74 "\n" 82 "\n"
75 " A fully-qualified label representing the default toolchain, which may\n" 83 " A fully-qualified label representing the default toolchain, which may\n"
76 " not necessarily be the current one (see \"current_toolchain\").\n"; 84 " not necessarily be the current one (see \"current_toolchain\").\n";
77 85
78 const char kOs[] = "os"; 86 const char kOs[] = "os";
79 const char kOs_HelpShort[] = 87 const char kOs_HelpShort[] =
80 "os: [string] Indicates the operating system of the current build."; 88 "os: [string] Indicates the operating system of the current toolchain.";
81 const char kOs_Help[] = 89 const char kOs_Help[] =
82 "os: Indicates the operating system of the current build." 90 "os: Indicates the operating system of the current toolchain.\n"
83 "\n" 91 "\n"
84 " This value is set by default based on the current host operating\n" 92 " This value is set by default to the value of \"target_os\" (see gn \n"
85 " system. The build configuration can override the value to anything\n" 93 " help target_os\"), but the build configuration can override the\n"
86 " it wants, or it can be set via the build arguments on the command\n" 94 " value to anything it wants, or it can be set via the build arguments \n"
87 " line.\n" 95 " on the command line.\n"
88 "\n" 96 "\n"
89 " If you want to know the default value without any overrides, you can\n" 97 " See \"gn help target_os\" for a list of common values returned.\n";
90 " use \"default_os\" (see \"gn help default_os\").\n"
91 "\n"
92 " Note that this returns the most specific value. So even though\n"
93 " Android and ChromeOS are both Linux, the more specific value will\n"
94 " be returned.\n"
95 "\n"
96 "Some possible values:\n"
97 " - \"amiga\"\n"
98 " - \"android\"\n"
99 " - \"chromeos\"\n"
100 " - \"ios\"\n"
101 " - \"linux\"\n"
102 " - \"mac\"\n"
103 " - \"win\"\n";
104 98
105 const char kPythonPath[] = "python_path"; 99 const char kPythonPath[] = "python_path";
106 const char kPythonPath_HelpShort[] = 100 const char kPythonPath_HelpShort[] =
107 "python_path: [string] Absolute path of Python."; 101 "python_path: [string] Absolute path of Python.";
108 const char kPythonPath_Help[] = 102 const char kPythonPath_Help[] =
109 "python_path: Absolute path of Python.\n" 103 "python_path: Absolute path of Python.\n"
110 "\n" 104 "\n"
111 " Normally used in toolchain definitions if running some command\n" 105 " Normally used in toolchain definitions if running some command\n"
112 " requires Python. You will normally not need this when invoking scripts\n" 106 " requires Python. You will normally not need this when invoking scripts\n"
113 " since GN automatically finds it for you.\n"; 107 " since GN automatically finds it for you.\n";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 " See also \"target_out_dir\" which is usually a better location for\n" 154 " See also \"target_out_dir\" which is usually a better location for\n"
161 " output files. It will be inside the root output dir.\n" 155 " output files. It will be inside the root output dir.\n"
162 "\n" 156 "\n"
163 "Example:\n" 157 "Example:\n"
164 "\n" 158 "\n"
165 " action(\"myscript\") {\n" 159 " action(\"myscript\") {\n"
166 " # Pass the output dir to the script.\n" 160 " # Pass the output dir to the script.\n"
167 " args = [ \"-o\", rebase_path(root_out_dir, root_build_dir) ]\n" 161 " args = [ \"-o\", rebase_path(root_out_dir, root_build_dir) ]\n"
168 " }\n"; 162 " }\n";
169 163
164 const char kTargetCpuArch[] = "target_cpu_arch";
165 const char kTargetCpuArch_HelpShort[] =
166 "target_cpu_arch: [string] The desired cpu architecture for your build.";
167 const char kTargetCpuArch_Help[] =
168 "target_cpu_arch: The desired cpu architecture for your build.\n"
169 "\n"
170 " This value should be used to indicate the desired architecture for\n"
171 " the primary object of the build. In many cases, this is the same as\n"
172 " \"build_cpu_arch\", but in the case of cross-compiles, this can be\n"
173 " set to something different. This value is different from \"cpu_arch\"\n"
174 " in that it can be referenced from inside any toolchain.\n"
175 "\n"
176 " This value is usually set once at the beginning of the build\n"
177 " configuration files and can be overridden on the command line, but\n"
178 " should otherwise be considered read only.\n"
179 "\n"
180 " This value is not used internally by GN for any purpose, so you can\n"
181 " set it to whatever value is relevant to your build, but where\n"
182 " you should stick to the following list of common values:\n"
183 "\n"
184 "Possible values:\n"
185 " - \"x86\"\n"
186 " - \"x64\"\n"
187 " - \"arm\"\n"
188 " - \"mipsel\"\n";
189
190 const char kTargetOs[] = "target_os";
191 const char kTargetOs_HelpShort[] =
192 "target_os: [string] The desired operating system for your build.";
193 const char kTargetOs_Help[] =
194 "target_os_arch: The desired operating system for your build.\n"
195 "\n"
196 " This value should be used to indicate the desired operating system for\n"
197 " the primary object of the build. In many cases, this is the same as\n"
198 " \"build_os\", but in the case of cross-compiles, this may be\n"
199 " different. This variable differs from \"os\" in that it can be\n"
200 " referenced from inside any toolchain and will always return the\n"
201 " initial value.\n"
202 "\n"
203 " This value defaults to \"build_os\" but can overridden in the\n"
204 " configuration files or on the command line. If the configuration files\n"
205 " do not use the default, it should be set only once, and\n"
206 " otherwise be considered read only.\n"
207 "\n"
208 " Note that this returns the most specific value. So even though\n"
209 " Android and ChromeOS are both Linux, the more specific value will\n"
210 " be returned.\n"
211 "\n"
212 " This value is not used internally by GN for any purpose, so you can\n"
213 " set it to whatever value is relevant to your build, but where\n"
214 " it makes sense, use one of the following list of common values:\n"
215 "\n"
216 "Possible values:\n"
217 " - \"android\"\n"
218 " - \"chromeos\"\n"
219 " - \"ios\"\n"
220 " - \"linux\"\n"
221 " - \"nacl\"\n"
222 " - \"mac\"\n"
223 " - \"win\"\n";
224
170 const char kTargetGenDir[] = "target_gen_dir"; 225 const char kTargetGenDir[] = "target_gen_dir";
171 const char kTargetGenDir_HelpShort[] = 226 const char kTargetGenDir_HelpShort[] =
172 "target_gen_dir: [string] Directory for a target's generated files."; 227 "target_gen_dir: [string] Directory for a target's generated files.";
173 const char kTargetGenDir_Help[] = 228 const char kTargetGenDir_Help[] =
174 "target_gen_dir: Directory for a target's generated files.\n" 229 "target_gen_dir: Directory for a target's generated files.\n"
175 "\n" 230 "\n"
176 " Absolute path to the target's generated file directory. If your\n" 231 " Absolute path to the target's generated file directory. If your\n"
177 " current target is in \"//tools/doom_melon\" then this value might be\n" 232 " current target is in \"//tools/doom_melon\" then this value might be\n"
178 " \"//out/Debug/gen/tools/doom_melon\". It will not have a trailing\n" 233 " \"//out/Debug/gen/tools/doom_melon\". It will not have a trailing\n"
179 " slash.\n" 234 " slash.\n"
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 INSERT_VARIABLE(BuildCpuArch) 1033 INSERT_VARIABLE(BuildCpuArch)
979 INSERT_VARIABLE(BuildOs) 1034 INSERT_VARIABLE(BuildOs)
980 INSERT_VARIABLE(CpuArch) 1035 INSERT_VARIABLE(CpuArch)
981 INSERT_VARIABLE(CurrentToolchain) 1036 INSERT_VARIABLE(CurrentToolchain)
982 INSERT_VARIABLE(DefaultToolchain) 1037 INSERT_VARIABLE(DefaultToolchain)
983 INSERT_VARIABLE(Os) 1038 INSERT_VARIABLE(Os)
984 INSERT_VARIABLE(PythonPath) 1039 INSERT_VARIABLE(PythonPath)
985 INSERT_VARIABLE(RootBuildDir) 1040 INSERT_VARIABLE(RootBuildDir)
986 INSERT_VARIABLE(RootGenDir) 1041 INSERT_VARIABLE(RootGenDir)
987 INSERT_VARIABLE(RootOutDir) 1042 INSERT_VARIABLE(RootOutDir)
1043 INSERT_VARIABLE(TargetCpuArch)
1044 INSERT_VARIABLE(TargetOs)
988 INSERT_VARIABLE(TargetGenDir) 1045 INSERT_VARIABLE(TargetGenDir)
989 INSERT_VARIABLE(TargetOutDir) 1046 INSERT_VARIABLE(TargetOutDir)
990 } 1047 }
991 return info_map; 1048 return info_map;
992 } 1049 }
993 1050
994 const VariableInfoMap& GetTargetVariables() { 1051 const VariableInfoMap& GetTargetVariables() {
995 static VariableInfoMap info_map; 1052 static VariableInfoMap info_map;
996 if (info_map.empty()) { 1053 if (info_map.empty()) {
997 INSERT_VARIABLE(AllDependentConfigs) 1054 INSERT_VARIABLE(AllDependentConfigs)
(...skipping 28 matching lines...) Expand all
1026 INSERT_VARIABLE(Sources) 1083 INSERT_VARIABLE(Sources)
1027 INSERT_VARIABLE(Testonly) 1084 INSERT_VARIABLE(Testonly)
1028 INSERT_VARIABLE(Visibility) 1085 INSERT_VARIABLE(Visibility)
1029 } 1086 }
1030 return info_map; 1087 return info_map;
1031 } 1088 }
1032 1089
1033 #undef INSERT_VARIABLE 1090 #undef INSERT_VARIABLE
1034 1091
1035 } // namespace variables 1092 } // namespace variables
OLDNEW
« tools/gn/misc/vim/syntax/gn.vim ('K') | « tools/gn/variables.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698