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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "tools/gn/commands.h" | 8 #include "tools/gn/commands.h" |
9 #include "tools/gn/err.h" | 9 #include "tools/gn/err.h" |
10 #include "tools/gn/location.h" | 10 #include "tools/gn/location.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 std::vector<std::string> GetArgs(const CommandLine& cmdline) { | 14 std::vector<std::string> GetArgs(const CommandLine& cmdline) { |
15 CommandLine::StringVector in_args = cmdline.GetArgs(); | 15 CommandLine::StringVector in_args = cmdline.GetArgs(); |
16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
17 std::vector<std::string> out_args; | 17 std::vector<std::string> out_args; |
18 for (size_t i = 0; i < in_args.size(); i++) | 18 for (size_t i = 0; i < in_args.size(); i++) |
19 out_args.push_back(base::WideToUTF8(in_args[i])); | 19 out_args.push_back(base::WideToUTF8(in_args[i])); |
20 return out_args; | 20 return out_args; |
21 #else | 21 #else |
22 return in_args; | 22 return in_args; |
23 #endif | 23 #endif |
24 } | 24 } |
25 | 25 |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 int main(int argc, char** argv) { | 28 int main(int argc, char** argv) { |
29 base::AtExitManager at_exit; | 29 base::AtExitManager at_exit; |
| 30 #if defined(OS_WIN) |
| 31 CommandLine::set_slash_is_not_a_switch(); |
| 32 #endif |
30 CommandLine::Init(argc, argv); | 33 CommandLine::Init(argc, argv); |
31 | 34 |
32 const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); | 35 const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); |
33 std::vector<std::string> args = GetArgs(cmdline); | 36 std::vector<std::string> args = GetArgs(cmdline); |
34 | 37 |
35 std::string command; | 38 std::string command; |
36 if (cmdline.HasSwitch("help")) { | 39 if (cmdline.HasSwitch("help")) { |
37 // Make "--help" default to help command. | 40 // Make "--help" default to help command. |
38 command = commands::kHelp; | 41 command = commands::kHelp; |
39 } else if (args.empty()) { | 42 } else if (args.empty()) { |
(...skipping 13 matching lines...) Expand all Loading... |
53 } else { | 56 } else { |
54 Err(Location(), | 57 Err(Location(), |
55 "Command \"" + command + "\" unknown.").PrintToStdout(); | 58 "Command \"" + command + "\" unknown.").PrintToStdout(); |
56 commands::RunHelp(std::vector<std::string>()); | 59 commands::RunHelp(std::vector<std::string>()); |
57 retval = 1; | 60 retval = 1; |
58 } | 61 } |
59 | 62 |
60 exit(retval); // Don't free memory, it can be really slow! | 63 exit(retval); // Don't free memory, it can be really slow! |
61 return retval; | 64 return retval; |
62 } | 65 } |
OLD | NEW |