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

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