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

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: merge to #316930 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
« no previous file with comments | « 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 ----------------------------------------------------------
brettw 2015/02/19 17:51:27 CAn you keep the blank line below this?
Dirk Pranke 2015/02/19 19:47:09 Done.
10 const char kHostCpu[] = "host_cpu";
11 const char kHostCpu_HelpShort[] =
12 "host_cpu: [string] The processor architecture that GN is running on.";
13 const char kHostCpu_Help[] =
14 "host_cpu: The processor architecture that GN is running on.\n"
15 "\n"
16 " This is value is exposed so that cross-compile toolchains can\n"
17 " still access the host architecture when needed.\n"
brettw 2015/02/19 17:51:26 delete "still"
Dirk Pranke 2015/02/19 19:47:09 Done.
18 "\n"
19 " The value should generally be considered read-only, but it is\n"
brettw 2015/02/19 17:51:26 it is -> it can be
Dirk Pranke 2015/02/19 19:47:09 Done, but that required changing "overridable" to
20 " overridable in order to handle unusual cases where there might\n"
21 " be multiple plausible values for the host architecture (e.g., if\n"
22 " you can do either 32-bit\n or 64-bit builds). The value is not used\n"
brettw 2015/02/19 17:51:27 Delete the \n after "32-bit"
Dirk Pranke 2015/02/19 19:47:09 Done.
23 " internally by GN for any purpose.\n"
24 "\n"
25 "Some possible values:\n"
26 " - \"x64\"\n"
27 " - \"x86\"\n";
10 28
11 const char kCpuArch[] = "cpu_arch"; 29 const char kHostOs[] = "host_os";
12 const char kCpuArch_HelpShort[] = 30 const char kHostOs_HelpShort[] =
13 "cpu_arch: [string] Current processor architecture."; 31 "host_os: [string] The operating system that GN is running on.";
14 const char kCpuArch_Help[] = 32 const char kHostOs_Help[] =
15 "cpu_arch: Current processor architecture.\n" 33 "host_os: [string] The operating system that GN is running on.\n"
16 "\n" 34 "\n"
17 " The initial value is based on the current architecture of the host\n" 35 " This value is exposed so that cross-compiles can access the host\n"
18 " system. However, the build configuration can set this to any value.\n" 36 " build system's settings when need be in order to ensure that objects\n"
brettw 2015/02/19 17:51:27 I'd just end this paragraph after "settings" and d
Dirk Pranke 2015/02/19 19:47:09 Done.
37 " that need to be built and run on the host machine can be\n"
38 " configured correctly."
19 "\n" 39 "\n"
20 " This value is not used internally by GN for any purpose, so you can\n" 40 " This value should generally be treated as read-only. It, however,\n"
21 " set it to whatever value is relevant to your build.\n" 41 " is not used internally by GN for any purpose.\n"
22 "\n" 42 "\n"
23 "Possible initial values set by GN:\n" 43 "Some possible values:\n"
44 " - \"linux\"\n"
45 " - \"mac\"\n"
46 " - \"win\"\n";
47
48 const char kTargetCpu[] = "target_cpu";
49 const char kTargetCpu_HelpShort[] =
50 "target_cpu: [string] The desired cpu architecture for the build.";
51 const char kTargetCpu_Help[] =
52 "target_cpu: The desired cpu architecture for the build.\n"
53 "\n"
54 " This value should be used to indicate the desired architecture for\n"
55 " the primary objects of the build. In many cases, this is the same as\n"
brettw 2015/02/19 17:51:26 Add "It will match the cpu architecture of the def
Dirk Pranke 2015/02/19 19:47:09 Done.
56 " \"host_cpu\", but in the case of cross-compiles, this can be\n"
57 " set to something different. This value is different from\n"
58 " \"current_cpu\" in that it can be referenced from inside any\n"
59 " toolchain. This value can also be ignored if it is not needed or\n"
60 " meaningful for a project.\n"
61 "\n"
62 " This value is not used internally by GN for any purpose, so it\n"
63 " may be set to whatever value is needed for the build.\n"
64 " GN defaults this value to the empty string (\"\") and the\n"
65 " configuration files should set it to an appropriate value\n"
66 " (e.g., setting it to the value of \"host_cpu\") if it is not\n"
67 " overridden on the command line or in the args.gn file.\n"
68 "\n"
69 " Where practical, use one of the following list of common values:\n"
70 "\n"
71 "Possible values:\n"
24 " - \"x86\"\n" 72 " - \"x86\"\n"
25 " - \"x64\"\n" 73 " - \"x64\"\n"
26 " - \"arm\"\n" 74 " - \"arm\"\n"
75 " - \"arm64\"\n"
27 " - \"mipsel\"\n"; 76 " - \"mipsel\"\n";
28 77
78 const char kTargetOs[] = "target_os";
79 const char kTargetOs_HelpShort[] =
80 "target_os: [string] The desired operating system for the build.";
81 const char kTargetOs_Help[] =
82 "target_os: The desired operating system for the build.\n"
83 "\n"
84 " This value should be used to indicate the desired operating system\n"
85 " for the primary object(s) of the build. In many cases, this is the\n"
brettw 2015/02/19 17:51:26 As above "It will match the OS of the default tool
Dirk Pranke 2015/02/19 19:47:09 Done.
86 " same as \"host_os\", but in the case of cross-compiles, this\n"
87 " may be different. This variable differs from \"current_os\" in\n"
88 " that it can be referenced from inside any toolchain and will\n"
89 " always return the initial value.\n"
90 "\n"
91 " This should be set to the most specific value possible. So,\n"
92 " \"android\" or \"chromeos\" should be used instead of \"linux\"\n"
93 " where applicable, even though Android and ChromeOS are both Linux\n"
94 " variants. This can mean that one needs to write\n"
95 "\n"
96 " if (target_os == \"android\" || target_os == \"linux\") {\n"
97 " # ...\n"
98 " }\n"
99 "\n"
100 " and so forth.\n"
101 "\n"
102 " This value is not used internally by GN for any purpose, so it\n"
103 " may be set to whatever value is needed for the build.\n"
104 " GN defaults this value to the empty string (\"\") and the\n"
105 " configuration files should set it to an appropriate value\n"
106 " (e.g., setting it to the value of \"host_os\") if it is not\n"
107 " set via the command line or in the args.gn file.\n"
108 "\n"
109 " Where practical, use one of the following list of common values:\n"
110 "\n"
111 "Possible values:\n"
112 " - \"android\"\n"
113 " - \"chromeos\"\n"
114 " - \"ios\"\n"
115 " - \"linux\"\n"
116 " - \"nacl\"\n"
117 " - \"mac\"\n"
118 " - \"win\"\n";
119
120 const char kCurrentCpu[] = "current_cpu";
121 const char kCurrentCpu_HelpShort[] =
122 "current_cpu: [string] The processor architecture of the current "
123 "toolchain.";
124 const char kCurrentCpu_Help[] =
125 "current_cpu: The processor architecture of the current toolchain.\n"
126 "\n"
127 " The build configuration usually sets this value based on the value\n"
128 " of \"host_cpu\" (see \"gn help host_cpu\") and then threads\n"
129 " this through the toolchain definitions to ensure that it always\n"
130 " reflects the appropriate value.\n"
131 "\n"
132 " This value is not used internally by GN for any purpose. It is\n"
133 " set it to the empty string (\"\") by default but is declared so\n"
134 " that it can be overridden on the command line if so desired.\n"
135 "\n"
136 " See \"gn help target_cpu\" for a list of common values returned.\n";
137
138 const char kCurrentOs[] = "current_os";
139 const char kCurrentOs_HelpShort[] =
140 "current_os: [string] The operating system of the current toolchain.";
141 const char kCurrentOs_Help[] =
142 "current_os: The operating system of the current toolchain.\n"
143 "\n"
144 " The build configuration usually sets this value based on the value\n"
145 " of \"target_os\" (see \"gn help target_os\"), and then threads this\n"
146 " through the toolchain definitions to ensure that it always reflects\n"
147 " the appropriate value.\n"
148 "\n"
149 " This value is not used internally by GN for any purpose. It is\n"
150 " set it to the empty string (\"\") by default but is declared so\n"
151 " that it can be overridden on the command line if so desired.\n"
152 "\n"
153 " See \"gn help target_os\" for a list of common values returned.\n";
154
29 const char kCurrentToolchain[] = "current_toolchain"; 155 const char kCurrentToolchain[] = "current_toolchain";
30 const char kCurrentToolchain_HelpShort[] = 156 const char kCurrentToolchain_HelpShort[] =
31 "current_toolchain: [string] Label of the current toolchain."; 157 "current_toolchain: [string] Label of the current toolchain.";
32 const char kCurrentToolchain_Help[] = 158 const char kCurrentToolchain_Help[] =
33 "current_toolchain: Label of the current toolchain.\n" 159 "current_toolchain: Label of the current toolchain.\n"
34 "\n" 160 "\n"
35 " A fully-qualified label representing the current toolchain. You can\n" 161 " 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" 162 " use this to make toolchain-related decisions in the build. See also\n"
37 " \"default_toolchain\".\n" 163 " \"default_toolchain\".\n"
38 "\n" 164 "\n"
39 "Example:\n" 165 "Example:\n"
40 "\n" 166 "\n"
41 " if (current_toolchain == \"//build:64_bit_toolchain\") {\n" 167 " if (current_toolchain == \"//build:64_bit_toolchain\") {\n"
42 " executable(\"output_thats_64_bit_only\") {\n" 168 " executable(\"output_thats_64_bit_only\") {\n"
43 " ...\n"; 169 " ...\n";
44 170
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"; 171 const char kDefaultToolchain[] = "default_toolchain";
70 const char kDefaultToolchain_HelpShort[] = 172 const char kDefaultToolchain_HelpShort[] =
71 "default_toolchain: [string] Label of the default toolchain."; 173 "default_toolchain: [string] Label of the default toolchain.";
72 const char kDefaultToolchain_Help[] = 174 const char kDefaultToolchain_Help[] =
73 "default_toolchain: [string] Label of the default toolchain.\n" 175 "default_toolchain: [string] Label of the default toolchain.\n"
74 "\n" 176 "\n"
75 " A fully-qualified label representing the default toolchain, which may\n" 177 " A fully-qualified label representing the default toolchain, which may\n"
76 " not necessarily be the current one (see \"current_toolchain\").\n"; 178 " not necessarily be the current one (see \"current_toolchain\").\n";
77 179
78 const char kOs[] = "os";
79 const char kOs_HelpShort[] =
80 "os: [string] Indicates the operating system of the current build.";
81 const char kOs_Help[] =
82 "os: Indicates the operating system of the current build."
83 "\n"
84 " This value is set by default based on the current host operating\n"
85 " system. The build configuration can override the value to anything\n"
86 " it wants, or it can be set via the build arguments on the command\n"
87 " line.\n"
88 "\n"
89 " If you want to know the default value without any overrides, you can\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
105 const char kPythonPath[] = "python_path"; 180 const char kPythonPath[] = "python_path";
106 const char kPythonPath_HelpShort[] = 181 const char kPythonPath_HelpShort[] =
107 "python_path: [string] Absolute path of Python."; 182 "python_path: [string] Absolute path of Python.";
108 const char kPythonPath_Help[] = 183 const char kPythonPath_Help[] =
109 "python_path: Absolute path of Python.\n" 184 "python_path: Absolute path of Python.\n"
110 "\n" 185 "\n"
111 " Normally used in toolchain definitions if running some command\n" 186 " Normally used in toolchain definitions if running some command\n"
112 " requires Python. You will normally not need this when invoking scripts\n" 187 " requires Python. You will normally not need this when invoking scripts\n"
113 " since GN automatically finds it for you.\n"; 188 " since GN automatically finds it for you.\n";
114 189
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 : help_short(in_help_short), 1043 : help_short(in_help_short),
969 help(in_help) { 1044 help(in_help) {
970 } 1045 }
971 1046
972 #define INSERT_VARIABLE(var) \ 1047 #define INSERT_VARIABLE(var) \
973 info_map[k##var] = VariableInfo(k##var##_HelpShort, k##var##_Help); 1048 info_map[k##var] = VariableInfo(k##var##_HelpShort, k##var##_Help);
974 1049
975 const VariableInfoMap& GetBuiltinVariables() { 1050 const VariableInfoMap& GetBuiltinVariables() {
976 static VariableInfoMap info_map; 1051 static VariableInfoMap info_map;
977 if (info_map.empty()) { 1052 if (info_map.empty()) {
978 INSERT_VARIABLE(BuildCpuArch) 1053 INSERT_VARIABLE(CurrentCpu)
979 INSERT_VARIABLE(BuildOs) 1054 INSERT_VARIABLE(CurrentOs)
980 INSERT_VARIABLE(CpuArch)
981 INSERT_VARIABLE(CurrentToolchain) 1055 INSERT_VARIABLE(CurrentToolchain)
982 INSERT_VARIABLE(DefaultToolchain) 1056 INSERT_VARIABLE(DefaultToolchain)
983 INSERT_VARIABLE(Os) 1057 INSERT_VARIABLE(HostCpu)
1058 INSERT_VARIABLE(HostOs)
984 INSERT_VARIABLE(PythonPath) 1059 INSERT_VARIABLE(PythonPath)
985 INSERT_VARIABLE(RootBuildDir) 1060 INSERT_VARIABLE(RootBuildDir)
986 INSERT_VARIABLE(RootGenDir) 1061 INSERT_VARIABLE(RootGenDir)
987 INSERT_VARIABLE(RootOutDir) 1062 INSERT_VARIABLE(RootOutDir)
1063 INSERT_VARIABLE(TargetCpu)
1064 INSERT_VARIABLE(TargetOs)
988 INSERT_VARIABLE(TargetGenDir) 1065 INSERT_VARIABLE(TargetGenDir)
989 INSERT_VARIABLE(TargetOutDir) 1066 INSERT_VARIABLE(TargetOutDir)
990 } 1067 }
991 return info_map; 1068 return info_map;
992 } 1069 }
993 1070
994 const VariableInfoMap& GetTargetVariables() { 1071 const VariableInfoMap& GetTargetVariables() {
995 static VariableInfoMap info_map; 1072 static VariableInfoMap info_map;
996 if (info_map.empty()) { 1073 if (info_map.empty()) {
997 INSERT_VARIABLE(AllDependentConfigs) 1074 INSERT_VARIABLE(AllDependentConfigs)
(...skipping 28 matching lines...) Expand all
1026 INSERT_VARIABLE(Sources) 1103 INSERT_VARIABLE(Sources)
1027 INSERT_VARIABLE(Testonly) 1104 INSERT_VARIABLE(Testonly)
1028 INSERT_VARIABLE(Visibility) 1105 INSERT_VARIABLE(Visibility)
1029 } 1106 }
1030 return info_map; 1107 return info_map;
1031 } 1108 }
1032 1109
1033 #undef INSERT_VARIABLE 1110 #undef INSERT_VARIABLE
1034 1111
1035 } // namespace variables 1112 } // namespace variables
OLDNEW
« no previous file with comments | « tools/gn/variables.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698