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_GYP_BINARY_TARGET_WRITER_H_
6 #define TOOLS_GN_GYP_BINARY_TARGET_WRITER_H_
11 #include "base/compiler_specific.h"
12 #include "tools/gn/gyp_target_writer.h"
13 #include "tools/gn/target.h"
14 #include "tools/gn/toolchain.h"
16 // Writes a portion of a .gyp file for a binary target type (an executable, a
17 // shared library, or a static library).
18 class GypBinaryTargetWriter : public GypTargetWriter {
20 GypBinaryTargetWriter(const TargetGroup& group, std::ostream& out);
21 virtual ~GypBinaryTargetWriter();
23 virtual void Run() OVERRIDE;
30 std::vector<std::string> defines;
31 std::vector<SourceDir> include_dirs;
33 std::vector<std::string> cflags;
34 std::vector<std::string> cflags_c;
35 std::vector<std::string> cflags_cc;
36 std::vector<std::string> cflags_objc;
37 std::vector<std::string> cflags_objcc;
38 std::vector<std::string> ldflags;
39 std::vector<SourceDir> lib_dirs;
40 std::vector<std::string> libs;
43 // Writes the given number of spaces to the output stream and returns it.
44 std::ostream& Indent(int spaces);
46 void WriteName(int indent);
47 void WriteType(int indent);
49 // Writes the flags, sources, and deps.
50 void WriteVCConfiguration(int indent);
51 void WriteLinuxConfiguration(int indent);
52 void WriteMacConfiguration(int indent);
54 // Writes the flags, defines, etc. The flags input is non-const because the
55 // cflags will be fixed up to account for things converted to VC settings
56 // (rather than compiler flags).
57 void WriteVCFlags(Flags& flags, int indent);
58 void WriteMacFlags(Flags& flags, int indent);
60 // Writes the Linux compiler and linker flags. The first version does the
61 // flags for the given target, the second version takes a pregenerted list of
63 void WriteLinuxFlagsForTarget(const Target* target, int indent);
64 void WriteLinuxFlags(const Flags& flags, int indent);
66 // Shared helpers for writing specific parts of GYP files.
67 void WriteSources(const Target* target, int indent);
68 void WriteDeps(const Target* target, int indent);
69 void WriteIncludeDirs(const Flags& flags, int indent);
70 void WriteDirectDependentSettings(int indent);
71 void WriteAllDependentSettings(int indent);
73 // Writes out the given flags and such from all configs in the given list.
74 void WriteSettingsFromConfigList(const std::vector<const Config*>& configs,
77 // Fills the given flags structure.
78 Flags FlagsFromTarget(const Target* target) const;
79 Flags FlagsFromConfigList(const LabelConfigVector& configs) const;
81 // All associated targets.
84 DISALLOW_COPY_AND_ASSIGN(GypBinaryTargetWriter);
87 #endif // TOOLS_GN_GYP_BINARY_TARGET_WRITER_H_