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

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

Issue 2492273002: GN: Always check for bad items. (Closed)
Patch Set: Created 4 years, 1 month 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/command_analyze.cc ('k') | tools/gn/command_desc.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 // 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 GetContextForValue(value, &location, &comment); 111 GetContextForValue(value, &location, &comment);
112 OutputString(" " + location + "\n" + comment); 112 OutputString(" " + location + "\n" + comment);
113 } else { 113 } else {
114 OutputString(" (Internally set; try `gn help " + name.as_string() + 114 OutputString(" (Internally set; try `gn help " + name.as_string() +
115 "`.)\n"); 115 "`.)\n");
116 } 116 }
117 } 117 }
118 118
119 int ListArgs(const std::string& build_dir) { 119 int ListArgs(const std::string& build_dir) {
120 Setup* setup = new Setup; 120 Setup* setup = new Setup;
121 setup->build_settings().set_check_for_bad_items(false);
122 if (!setup->DoSetup(build_dir, false) || !setup->Run()) 121 if (!setup->DoSetup(build_dir, false) || !setup->Run())
123 return 1; 122 return 1;
124 123
125 Scope::KeyValueMap build_args; 124 Scope::KeyValueMap build_args;
126 setup->build_settings().build_args().MergeDeclaredArguments(&build_args); 125 setup->build_settings().build_args().MergeDeclaredArguments(&build_args);
127 126
128 // Find all of the arguments we care about. Use a regular map so they're 127 // Find all of the arguments we care about. Use a regular map so they're
129 // sorted nicely when we write them out. 128 // sorted nicely when we write them out.
130 std::map<base::StringPiece, Value> sorted_args; 129 std::map<base::StringPiece, Value> sorted_args;
131 std::string list_value = 130 std::string list_value =
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 return system(cmd.c_str()) == 0; 223 return system(cmd.c_str()) == 0;
225 } 224 }
226 225
227 #endif 226 #endif
228 227
229 int EditArgsFile(const std::string& build_dir) { 228 int EditArgsFile(const std::string& build_dir) {
230 { 229 {
231 // Scope the setup. We only use it for some basic state. We'll do the 230 // Scope the setup. We only use it for some basic state. We'll do the
232 // "real" build below in the gen command. 231 // "real" build below in the gen command.
233 Setup setup; 232 Setup setup;
234 setup.build_settings().set_check_for_bad_items(false);
brettw 2016/11/11 18:21:49 This is the only non-introspection disabling of th
235 // Don't fill build arguments. We're about to edit the file which supplies 233 // Don't fill build arguments. We're about to edit the file which supplies
236 // these in the first place. 234 // these in the first place.
237 setup.set_fill_arguments(false); 235 setup.set_fill_arguments(false);
238 if (!setup.DoSetup(build_dir, true)) 236 if (!setup.DoSetup(build_dir, true))
239 return 1; 237 return 1;
240 238
241 // Ensure the file exists. Need to normalize path separators since on 239 // Ensure the file exists. Need to normalize path separators since on
242 // Windows they can come out as forward slashes here, and that confuses some 240 // Windows they can come out as forward slashes here, and that confuses some
243 // of the commands. 241 // of the commands.
244 base::FilePath arg_file = 242 base::FilePath arg_file =
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 "Or see \"gn help args\" for more variants.").PrintToStdout(); 343 "Or see \"gn help args\" for more variants.").PrintToStdout();
346 return 1; 344 return 1;
347 } 345 }
348 346
349 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) 347 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList))
350 return ListArgs(args[0]); 348 return ListArgs(args[0]);
351 return EditArgsFile(args[0]); 349 return EditArgsFile(args[0]);
352 } 350 }
353 351
354 } // namespace commands 352 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/command_analyze.cc ('k') | tools/gn/command_desc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698