| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef TOOLS_GN_NINJA_HELPER_H_ | |
| 6 #define TOOLS_GN_NINJA_HELPER_H_ | |
| 7 | |
| 8 #include <iosfwd> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "tools/gn/filesystem_utils.h" | |
| 12 #include "tools/gn/output_file.h" | |
| 13 #include "tools/gn/target.h" | |
| 14 | |
| 15 class BuildSettings; | |
| 16 class SourceDir; | |
| 17 class SourceFile; | |
| 18 class Target; | |
| 19 | |
| 20 // NinjaHelper ----------------------------------------------------------------- | |
| 21 | |
| 22 class NinjaHelper { | |
| 23 public: | |
| 24 NinjaHelper(const BuildSettings* build_settings); | |
| 25 ~NinjaHelper(); | |
| 26 | |
| 27 // Ends in a slash. | |
| 28 std::string GetTopleveOutputDir() const; | |
| 29 | |
| 30 // Ends in a slash. | |
| 31 OutputFile GetTargetOutputDir(const Target* target) const; | |
| 32 | |
| 33 // Example: "base/base.ninja". The string version will not be escaped, and | |
| 34 // will always have slashes for path separators. | |
| 35 OutputFile GetNinjaFileForTarget(const Target* target) const; | |
| 36 | |
| 37 // Returns the name of the root .ninja file for the given toolchain. | |
| 38 OutputFile GetNinjaFileForToolchain(const Settings* settings) const; | |
| 39 | |
| 40 // Given a source file relative to the source root, returns the output | |
| 41 // filename. | |
| 42 OutputFile GetOutputFileForSource(const Target* target, | |
| 43 const SourceFile& source, | |
| 44 SourceFileType type) const; | |
| 45 | |
| 46 // Returns the filename produced by the given output. | |
| 47 // | |
| 48 // Some targets make multiple files (like a .dll and an import library). This | |
| 49 // function returns the name of the file other targets should depend on and | |
| 50 // link to (so in this example, the import library). | |
| 51 OutputFile GetTargetOutputFile(const Target* target) const; | |
| 52 | |
| 53 // Returns the prefix for rules on the given toolchain. We need this to | |
| 54 // disambiguate a given rule for each toolchain. | |
| 55 std::string GetRulePrefix(const Settings* settings) const; | |
| 56 | |
| 57 // Returns the name of the rule name for the given toolchain and file/target | |
| 58 // type. Returns the empty string for source files with no command. | |
| 59 std::string GetRuleForSourceType(const Settings* settings, | |
| 60 SourceFileType type) const; | |
| 61 | |
| 62 // Returns the relative directory in either slashes or the system separator | |
| 63 // from the ninja directory (e.g. "out/Debug") to the source root (e.g. | |
| 64 // "../.."). It has no terminating slash. | |
| 65 const std::string& build_to_src_no_last_slash() const { | |
| 66 return build_to_src_no_last_slash_; | |
| 67 } | |
| 68 const std::string& build_to_src_system_no_last_slash() const { | |
| 69 return build_to_src_system_no_last_slash_; | |
| 70 } | |
| 71 | |
| 72 private: | |
| 73 const BuildSettings* build_settings_; | |
| 74 | |
| 75 std::string build_to_src_no_last_slash_; | |
| 76 std::string build_to_src_system_no_last_slash_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(NinjaHelper); | |
| 79 }; | |
| 80 | |
| 81 #endif // TOOLS_GN_NINJA_HELPER_H_ | |
| OLD | NEW |