| 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 #ifndef TOOLS_GN_COMMANDS_H_ | 5 #ifndef TOOLS_GN_COMMANDS_H_ |
| 6 #define TOOLS_GN_COMMANDS_H_ | 6 #define TOOLS_GN_COMMANDS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 13 | 13 |
| 14 class BuildSettings; |
| 15 class Setup; |
| 14 class Target; | 16 class Target; |
| 15 | 17 |
| 16 // Each "Run" command returns the value we should return from main(). | 18 // Each "Run" command returns the value we should return from main(). |
| 17 | 19 |
| 18 namespace commands { | 20 namespace commands { |
| 19 | 21 |
| 20 typedef int (*CommandRunner)(const std::vector<std::string>&); | 22 typedef int (*CommandRunner)(const std::vector<std::string>&); |
| 21 | 23 |
| 22 extern const char kArgs[]; | 24 extern const char kArgs[]; |
| 23 extern const char kArgs_HelpShort[]; | 25 extern const char kArgs_HelpShort[]; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 37 extern const char kGen[]; | 39 extern const char kGen[]; |
| 38 extern const char kGen_HelpShort[]; | 40 extern const char kGen_HelpShort[]; |
| 39 extern const char kGen_Help[]; | 41 extern const char kGen_Help[]; |
| 40 int RunGen(const std::vector<std::string>& args); | 42 int RunGen(const std::vector<std::string>& args); |
| 41 | 43 |
| 42 extern const char kHelp[]; | 44 extern const char kHelp[]; |
| 43 extern const char kHelp_HelpShort[]; | 45 extern const char kHelp_HelpShort[]; |
| 44 extern const char kHelp_Help[]; | 46 extern const char kHelp_Help[]; |
| 45 int RunHelp(const std::vector<std::string>& args); | 47 int RunHelp(const std::vector<std::string>& args); |
| 46 | 48 |
| 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); |
| 53 |
| 47 extern const char kRefs[]; | 54 extern const char kRefs[]; |
| 48 extern const char kRefs_HelpShort[]; | 55 extern const char kRefs_HelpShort[]; |
| 49 extern const char kRefs_Help[]; | 56 extern const char kRefs_Help[]; |
| 50 int RunRefs(const std::vector<std::string>& args); | 57 int RunRefs(const std::vector<std::string>& args); |
| 51 | 58 |
| 52 // ----------------------------------------------------------------------------- | 59 // ----------------------------------------------------------------------------- |
| 53 | 60 |
| 54 struct CommandInfo { | 61 struct CommandInfo { |
| 55 CommandInfo(); | 62 CommandInfo(); |
| 56 CommandInfo(const char* in_help_short, | 63 CommandInfo(const char* in_help_short, |
| 57 const char* in_help, | 64 const char* in_help, |
| 58 CommandRunner in_runner); | 65 CommandRunner in_runner); |
| 59 | 66 |
| 60 const char* help_short; | 67 const char* help_short; |
| 61 const char* help; | 68 const char* help; |
| 62 CommandRunner runner; | 69 CommandRunner runner; |
| 63 }; | 70 }; |
| 64 | 71 |
| 65 typedef std::map<base::StringPiece, CommandInfo> CommandInfoMap; | 72 typedef std::map<base::StringPiece, CommandInfo> CommandInfoMap; |
| 66 | 73 |
| 67 const CommandInfoMap& GetCommands(); | 74 const CommandInfoMap& GetCommands(); |
| 68 | 75 |
| 69 // Helper functions for some commands ------------------------------------------ | 76 // Helper functions for some commands ------------------------------------------ |
| 70 | 77 |
| 71 // Runs a build for the given command line, returning the target identified by | 78 // Given a setup that has already been run and some command-line input, |
| 72 // the first non-switch command line parameter. | 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); |
| 84 |
| 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. |
| 73 // | 89 // |
| 74 // Note that a lot of memory is leaked to avoid proper teardown under the | 90 // If all_tolchains is false, a pattern with an unspecified toolchain will |
| 75 // assumption that you will only run this once and exit. | 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); |
| 97 |
| 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. |
| 76 // | 101 // |
| 77 // On failure, prints an error message and returns NULL. | 102 // On success, returns true. If the check fails, the error(s) will be printed |
| 78 const Target* GetTargetForDesc(const std::vector<std::string>& args); | 103 // to stdout and false will be returned. |
| 104 bool CheckPublicHeaders(const BuildSettings* build_settings, |
| 105 const std::vector<const Target*>& all_targets, |
| 106 const std::vector<const Target*>& to_check); |
| 79 | 107 |
| 80 } // namespace commands | 108 } // namespace commands |
| 81 | 109 |
| 82 #endif // TOOLS_GN_COMMANDS_H_ | 110 #endif // TOOLS_GN_COMMANDS_H_ |
| OLD | NEW |