Delete app_host from apps/
[chromium-blink-merge.git] / tools / gn / ninja_helper.h
blobe893f79fae48e5791d1661beaa02949435da7095
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_NINJA_HELPER_H_
6 #define TOOLS_GN_NINJA_HELPER_H_
8 #include <iosfwd>
9 #include <string>
11 #include "tools/gn/filesystem_utils.h"
12 #include "tools/gn/output_file.h"
13 #include "tools/gn/target.h"
15 class BuildSettings;
16 class SourceDir;
17 class SourceFile;
18 class Target;
20 // NinjaHelper -----------------------------------------------------------------
22 class NinjaHelper {
23 public:
24 NinjaHelper(const BuildSettings* build_settings);
25 ~NinjaHelper();
27 // Ends in a slash.
28 std::string GetTopleveOutputDir() const;
30 // Ends in a slash.
31 std::string GetTargetOutputDir(const Target* target) const;
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;
37 // Returns the name of the root .ninja file for the given toolchain.
38 OutputFile GetNinjaFileForToolchain(const Settings* settings) const;
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;
46 // Returns the filename produced by the given output.
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;
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 Toolchain* toolchain) const;
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 const Toolchain* toolchain,
61 SourceFileType type) const;
62 std::string GetRuleForTargetType(const Toolchain* toolchain,
63 Target::OutputType target_type) const;
65 // Returns the relative directory in either slashes or the system separator
66 // from the ninja directory (e.g. "out/Debug") to the source root (e.g.
67 // "../.."). It has no terminating slash.
68 const std::string& build_to_src_no_last_slash() const {
69 return build_to_src_no_last_slash_;
71 const std::string& build_to_src_system_no_last_slash() const {
72 return build_to_src_system_no_last_slash_;
75 private:
76 const BuildSettings* build_settings_;
78 std::string build_to_src_no_last_slash_;
79 std::string build_to_src_system_no_last_slash_;
81 DISALLOW_COPY_AND_ASSIGN(NinjaHelper);
84 #endif // TOOLS_GN_NINJA_HELPER_H_