Change next_proto member type.
[chromium-blink-merge.git] / tools / gn / commands.h
blob1fac4a3eac8b431da272989a43e13940d167ec48
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 LabelPattern;
16 class Setup;
17 class Target;
19 // Each "Run" command returns the value we should return from main().
21 namespace commands {
23 typedef int (*CommandRunner)(const std::vector<std::string>&);
25 extern const char kArgs[];
26 extern const char kArgs_HelpShort[];
27 extern const char kArgs_Help[];
28 int RunArgs(const std::vector<std::string>& args);
30 extern const char kCheck[];
31 extern const char kCheck_HelpShort[];
32 extern const char kCheck_Help[];
33 int RunCheck(const std::vector<std::string>& args);
35 extern const char kDesc[];
36 extern const char kDesc_HelpShort[];
37 extern const char kDesc_Help[];
38 int RunDesc(const std::vector<std::string>& args);
40 extern const char kGen[];
41 extern const char kGen_HelpShort[];
42 extern const char kGen_Help[];
43 int RunGen(const std::vector<std::string>& args);
45 extern const char kFormat[];
46 extern const char kFormat_HelpShort[];
47 extern const char kFormat_Help[];
48 int RunFormat(const std::vector<std::string>& args);
50 extern const char kHelp[];
51 extern const char kHelp_HelpShort[];
52 extern const char kHelp_Help[];
53 int RunHelp(const std::vector<std::string>& args);
55 extern const char kLs[];
56 extern const char kLs_HelpShort[];
57 extern const char kLs_Help[];
58 int RunLs(const std::vector<std::string>& args);
60 extern const char kRefs[];
61 extern const char kRefs_HelpShort[];
62 extern const char kRefs_Help[];
63 int RunRefs(const std::vector<std::string>& args);
65 // -----------------------------------------------------------------------------
67 struct CommandInfo {
68 CommandInfo();
69 CommandInfo(const char* in_help_short,
70 const char* in_help,
71 CommandRunner in_runner);
73 const char* help_short;
74 const char* help;
75 CommandRunner runner;
78 typedef std::map<base::StringPiece, CommandInfo> CommandInfoMap;
80 const CommandInfoMap& GetCommands();
82 // Helper functions for some commands ------------------------------------------
84 // Given a setup that has already been run and some command-line input,
85 // resolves that input as a target label and returns the corresponding target.
86 // On failure, returns null and prints the error to the standard output.
87 const Target* ResolveTargetFromCommandLineString(
88 Setup* setup,
89 const std::string& label_string);
91 // Like above but the input string can be a pattern that matches multiple
92 // targets. If the input does not parse as a pattern, prints and error and
93 // returns false. If the pattern is valid, fills the vector (which might be
94 // empty if there are no matches) and returns true.
96 // If all_tolchains is false, a pattern with an unspecified toolchain will
97 // match the default toolchain only. If true, all toolchains will be matched.
98 bool ResolveTargetsFromCommandLinePattern(
99 Setup* setup,
100 const std::string& label_pattern,
101 bool all_toolchains,
102 std::vector<const Target*>* matches);
104 // Runs the header checker. All targets in the build should be given in
105 // all_targets, and the specific targets to check should be in to_check.
107 // force_check, if true, will override targets opting out of header checking
108 // with "check_includes = false" and will check them anyway.
110 // On success, returns true. If the check fails, the error(s) will be printed
111 // to stdout and false will be returned.
112 bool CheckPublicHeaders(const BuildSettings* build_settings,
113 const std::vector<const Target*>& all_targets,
114 const std::vector<const Target*>& to_check,
115 bool force_check);
117 // Filters the given list of targets by the given pattern list. This is a
118 // helper function for setting up a call to CheckPublicHeaders based on a check
119 // filter.
120 void FilterTargetsByPatterns(const std::vector<const Target*>& input,
121 const std::vector<LabelPattern>& filter,
122 std::vector<const Target*>* output);
124 } // namespace commands
126 #endif // TOOLS_GN_COMMANDS_H_