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_
11 #include "tools/gn/filesystem_utils.h"
12 #include "tools/gn/output_file.h"
13 #include "tools/gn/target.h"
20 // NinjaHelper -----------------------------------------------------------------
24 NinjaHelper(const BuildSettings
* build_settings
);
28 std::string
GetTopleveOutputDir() const;
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
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_
;
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_