| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 GetContextForValue(value, &location, &comment); | 108 GetContextForValue(value, &location, &comment); |
| 109 OutputString(" " + location + "\n" + comment); | 109 OutputString(" " + location + "\n" + comment); |
| 110 } else { | 110 } else { |
| 111 OutputString(" (Internally set)\n"); | 111 OutputString(" (Internally set)\n"); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 int ListArgs(const std::string& build_dir) { | 115 int ListArgs(const std::string& build_dir) { |
| 116 Setup* setup = new Setup; | 116 Setup* setup = new Setup; |
| 117 setup->set_check_for_bad_items(false); | 117 setup->set_check_for_bad_items(false); |
| 118 if (!setup->DoSetup(build_dir) || !setup->Run()) | 118 if (!setup->DoSetup(build_dir, false) || !setup->Run()) |
| 119 return 1; | 119 return 1; |
| 120 | 120 |
| 121 Scope::KeyValueMap build_args; | 121 Scope::KeyValueMap build_args; |
| 122 setup->build_settings().build_args().MergeDeclaredArguments(&build_args); | 122 setup->build_settings().build_args().MergeDeclaredArguments(&build_args); |
| 123 | 123 |
| 124 // Find all of the arguments we care about. Use a regular map so they're | 124 // Find all of the arguments we care about. Use a regular map so they're |
| 125 // sorted nicely when we write them out. | 125 // sorted nicely when we write them out. |
| 126 std::map<base::StringPiece, Value> sorted_args; | 126 std::map<base::StringPiece, Value> sorted_args; |
| 127 std::string list_value = | 127 std::string list_value = |
| 128 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(kSwitchList); | 128 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(kSwitchList); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 226 |
| 227 int EditArgsFile(const std::string& build_dir) { | 227 int EditArgsFile(const std::string& build_dir) { |
| 228 { | 228 { |
| 229 // Scope the setup. We only use it for some basic state. We'll do the | 229 // Scope the setup. We only use it for some basic state. We'll do the |
| 230 // "real" build below in the gen command. | 230 // "real" build below in the gen command. |
| 231 Setup setup; | 231 Setup setup; |
| 232 setup.set_check_for_bad_items(false); | 232 setup.set_check_for_bad_items(false); |
| 233 // 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 |
| 234 // these in the first place. | 234 // these in the first place. |
| 235 setup.set_fill_arguments(false); | 235 setup.set_fill_arguments(false); |
| 236 if (!setup.DoSetup(build_dir)) | 236 if (!setup.DoSetup(build_dir, true)) |
| 237 return 1; | 237 return 1; |
| 238 | 238 |
| 239 // Ensure the file exists. Need to normalize path separators since on | 239 // Ensure the file exists. Need to normalize path separators since on |
| 240 // 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 |
| 241 // of the commands. | 241 // of the commands. |
| 242 base::FilePath arg_file = | 242 base::FilePath arg_file = |
| 243 setup.build_settings().GetFullPath(setup.GetBuildArgFile()) | 243 setup.build_settings().GetFullPath(setup.GetBuildArgFile()) |
| 244 .NormalizePathSeparators(); | 244 .NormalizePathSeparators(); |
| 245 if (!base::PathExists(arg_file)) { | 245 if (!base::PathExists(arg_file)) { |
| 246 std::string argfile_default_contents = | 246 std::string argfile_default_contents = |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 "Or see \"gn help args\" for more variants.").PrintToStdout(); | 338 "Or see \"gn help args\" for more variants.").PrintToStdout(); |
| 339 return 1; | 339 return 1; |
| 340 } | 340 } |
| 341 | 341 |
| 342 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) | 342 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) |
| 343 return ListArgs(args[0]); | 343 return ListArgs(args[0]); |
| 344 return EditArgsFile(args[0]); | 344 return EditArgsFile(args[0]); |
| 345 } | 345 } |
| 346 | 346 |
| 347 } // namespace commands | 347 } // namespace commands |
| OLD | NEW |