| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "tools/gn/commands.h" | 9 #include "tools/gn/commands.h" |
| 10 #include "tools/gn/input_file.h" | 10 #include "tools/gn/input_file.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 " --args=\"doom_melon_setting=5 component_build=1\"\n" | 113 " --args=\"doom_melon_setting=5 component_build=1\"\n" |
| 114 " or in a toolchain definition (see \"gn help buildargs\" for more on\n" | 114 " or in a toolchain definition (see \"gn help buildargs\" for more on\n" |
| 115 " how this all works).\n" | 115 " how this all works).\n" |
| 116 "\n" | 116 "\n" |
| 117 " If \"arg name\" is specified, only the information for that argument\n" | 117 " If \"arg name\" is specified, only the information for that argument\n" |
| 118 " will be displayed. Otherwise all arguments will be displayed.\n"; | 118 " will be displayed. Otherwise all arguments will be displayed.\n"; |
| 119 | 119 |
| 120 int RunArgs(const std::vector<std::string>& args) { | 120 int RunArgs(const std::vector<std::string>& args) { |
| 121 Setup* setup = new Setup; | 121 Setup* setup = new Setup; |
| 122 setup->set_check_for_bad_items(false); | 122 setup->set_check_for_bad_items(false); |
| 123 if (!setup->DoSetup() || !setup->Run()) | 123 // TODO(brettw) bug 343726: Use a temporary directory instead of this |
| 124 // default one to avoid messing up any build that's in there. |
| 125 if (!setup->DoSetup("//out/Default/") || !setup->Run()) |
| 124 return 1; | 126 return 1; |
| 125 | 127 |
| 126 Scope::KeyValueMap build_args; | 128 Scope::KeyValueMap build_args; |
| 127 setup->build_settings().build_args().MergeDeclaredArguments(&build_args); | 129 setup->build_settings().build_args().MergeDeclaredArguments(&build_args); |
| 128 | 130 |
| 129 if (args.size() == 1) { | 131 if (args.size() == 1) { |
| 130 // Get help on a specific command. | 132 // Get help on a specific command. |
| 131 Scope::KeyValueMap::const_iterator found_arg = build_args.find(args[0]); | 133 Scope::KeyValueMap::const_iterator found_arg = build_args.find(args[0]); |
| 132 if (found_arg == build_args.end()) { | 134 if (found_arg == build_args.end()) { |
| 133 Err(Location(), "Unknown build argument.", | 135 Err(Location(), "Unknown build argument.", |
| (...skipping 19 matching lines...) Expand all Loading... |
| 153 for (std::map<base::StringPiece, Value>::iterator i = sorted_args.begin(); | 155 for (std::map<base::StringPiece, Value>::iterator i = sorted_args.begin(); |
| 154 i != sorted_args.end(); ++i) { | 156 i != sorted_args.end(); ++i) { |
| 155 PrintArgHelp(i->first, i->second); | 157 PrintArgHelp(i->first, i->second); |
| 156 OutputString("\n"); | 158 OutputString("\n"); |
| 157 } | 159 } |
| 158 | 160 |
| 159 return 0; | 161 return 0; |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace commands | 164 } // namespace commands |
| OLD | NEW |