Fix click-to-play positioning.
[chromium-blink-merge.git] / tools / gn / commands.h
blob9b8db88a3a9b552d9b2d33f7d3dbf4da8a4f7fb5
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
3 // found in the LICENSE file.
5 #ifndef TOOLS_GN_COMMANDS_H_
6 #define TOOLS_GN_COMMANDS_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/strings/string_piece.h"
14 class Target;
16 // Each "Run" command returns the value we should return from main().
18 namespace commands {
20 typedef int (*CommandRunner)(const std::vector<std::string>&);
22 extern const char kArgs[];
23 extern const char kArgs_HelpShort[];
24 extern const char kArgs_Help[];
25 int RunArgs(const std::vector<std::string>& args);
27 extern const char kCheck[];
28 extern const char kCheck_HelpShort[];
29 extern const char kCheck_Help[];
30 int RunCheck(const std::vector<std::string>& args);
32 extern const char kDesc[];
33 extern const char kDesc_HelpShort[];
34 extern const char kDesc_Help[];
35 int RunDesc(const std::vector<std::string>& args);
37 extern const char kGen[];
38 extern const char kGen_HelpShort[];
39 extern const char kGen_Help[];
40 int RunGen(const std::vector<std::string>& args);
42 extern const char kHelp[];
43 extern const char kHelp_HelpShort[];
44 extern const char kHelp_Help[];
45 int RunHelp(const std::vector<std::string>& args);
47 extern const char kRefs[];
48 extern const char kRefs_HelpShort[];
49 extern const char kRefs_Help[];
50 int RunRefs(const std::vector<std::string>& args);
52 // -----------------------------------------------------------------------------
54 struct CommandInfo {
55 CommandInfo();
56 CommandInfo(const char* in_help_short,
57 const char* in_help,
58 CommandRunner in_runner);
60 const char* help_short;
61 const char* help;
62 CommandRunner runner;
65 typedef std::map<base::StringPiece, CommandInfo> CommandInfoMap;
67 const CommandInfoMap& GetCommands();
69 // Helper functions for some commands ------------------------------------------
71 // Runs a build for the given command line, returning the target identified by
72 // the first non-switch command line parameter.
74 // Note that a lot of memory is leaked to avoid proper teardown under the
75 // assumption that you will only run this once and exit.
77 // On failure, prints an error message and returns NULL.
78 const Target* GetTargetForDesc(const std::vector<std::string>& args);
80 } // namespace commands
82 #endif // TOOLS_GN_COMMANDS_H_