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