Removing uses of X11 native key events.
[chromium-blink-merge.git] / tools / gn / commands.h
blob8603931d2bd50a8a03bd9ec71085137fec3acc24
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 BuildSettings;
15 class Setup;
16 class Target;
18 // Each "Run" command returns the value we should return from main().
20 namespace commands {
22 typedef int (*CommandRunner)(const std::vector<std::string>&);
24 extern const char kArgs[];
25 extern const char kArgs_HelpShort[];
26 extern const char kArgs_Help[];
27 int RunArgs(const std::vector<std::string>& args);
29 extern const char kCheck[];
30 extern const char kCheck_HelpShort[];
31 extern const char kCheck_Help[];
32 int RunCheck(const std::vector<std::string>& args);
34 extern const char kDesc[];
35 extern const char kDesc_HelpShort[];
36 extern const char kDesc_Help[];
37 int RunDesc(const std::vector<std::string>& args);
39 extern const char kGen[];
40 extern const char kGen_HelpShort[];
41 extern const char kGen_Help[];
42 int RunGen(const std::vector<std::string>& args);
44 extern const char kHelp[];
45 extern const char kHelp_HelpShort[];
46 extern const char kHelp_Help[];
47 int RunHelp(const std::vector<std::string>& args);
49 extern const char kLs[];
50 extern const char kLs_HelpShort[];
51 extern const char kLs_Help[];
52 int RunLs(const std::vector<std::string>& args);
54 extern const char kRefs[];
55 extern const char kRefs_HelpShort[];
56 extern const char kRefs_Help[];
57 int RunRefs(const std::vector<std::string>& args);
59 // -----------------------------------------------------------------------------
61 struct CommandInfo {
62 CommandInfo();
63 CommandInfo(const char* in_help_short,
64 const char* in_help,
65 CommandRunner in_runner);
67 const char* help_short;
68 const char* help;
69 CommandRunner runner;
72 typedef std::map<base::StringPiece, CommandInfo> CommandInfoMap;
74 const CommandInfoMap& GetCommands();
76 // Helper functions for some commands ------------------------------------------
78 // Given a setup that has already been run and some command-line input,
79 // resolves that input as a target label and returns the corresponding target.
80 // On failure, returns null and prints the error to the standard output.
81 const Target* ResolveTargetFromCommandLineString(
82 Setup* setup,
83 const std::string& label_string);
85 // Like above but the input string can be a pattern that matches multiple
86 // targets. If the input does not parse as a pattern, prints and error and
87 // returns false. If the pattern is valid, fills the vector (which might be
88 // empty if there are no matches) and returns true.
90 // If all_tolchains is false, a pattern with an unspecified toolchain will
91 // match the default toolchain only. If true, all toolchains will be matched.
92 bool ResolveTargetsFromCommandLinePattern(
93 Setup* setup,
94 const std::string& label_pattern,
95 bool all_toolchains,
96 std::vector<const Target*>* matches);
98 // Runs the header checker. All targets in the build should be given in
99 // all_targets, and the specific targets to check should be in to_check. If
100 // to_check is empty, all targets will be checked.
102 // force_check, if true, will override targets opting out of header checking
103 // with "check_includes = false" and will check them anyway.
105 // On success, returns true. If the check fails, the error(s) will be printed
106 // to stdout and false will be returned.
107 bool CheckPublicHeaders(const BuildSettings* build_settings,
108 const std::vector<const Target*>& all_targets,
109 const std::vector<const Target*>& to_check,
110 bool force_check);
112 } // namespace commands
114 #endif // TOOLS_GN_COMMANDS_H_