| 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_TOOLCHAIN_H_ | |
| 6 #define TOOLS_GN_TOOLCHAIN_H_ | |
| 7 | |
| 8 #include "base/compiler_specific.h" | |
| 9 #include "base/strings/string_piece.h" | |
| 10 #include "tools/gn/item.h" | |
| 11 | |
| 12 // Holds information on a specific toolchain. This data is filled in when we | |
| 13 // encounter a toolchain definition. | |
| 14 // | |
| 15 // This class is an Item so it can participate in dependency management. In | |
| 16 // particular, when a target uses a toolchain, it should have a dependency on | |
| 17 // that toolchain's object so that we can be sure we loaded the toolchain | |
| 18 // before generating the build for that target. | |
| 19 // | |
| 20 // Note on threadsafety: The label of the toolchain never changes so can | |
| 21 // safetly be accessed from any thread at any time (we do this when asking for | |
| 22 // the toolchain name). But the values in the toolchain do, so these can't | |
| 23 // be accessed until this Item is resolved. | |
| 24 class Toolchain : public Item { | |
| 25 public: | |
| 26 enum ToolType { | |
| 27 TYPE_NONE = 0, | |
| 28 TYPE_CC, | |
| 29 TYPE_CXX, | |
| 30 TYPE_ASM, | |
| 31 TYPE_ALINK, | |
| 32 TYPE_SOLINK, | |
| 33 TYPE_SOLINK_MODULE, | |
| 34 TYPE_LINK, | |
| 35 TYPE_STAMP, | |
| 36 TYPE_COPY, | |
| 37 | |
| 38 TYPE_NUMTYPES // Must be last. | |
| 39 }; | |
| 40 | |
| 41 static const char* kToolCc; | |
| 42 static const char* kToolCxx; | |
| 43 static const char* kToolAsm; | |
| 44 static const char* kToolAlink; | |
| 45 static const char* kToolSolink; | |
| 46 static const char* kToolSolinkModule; | |
| 47 static const char* kToolLink; | |
| 48 static const char* kToolStamp; | |
| 49 static const char* kToolCopy; | |
| 50 | |
| 51 struct Tool { | |
| 52 Tool(); | |
| 53 ~Tool(); | |
| 54 | |
| 55 bool empty() const { | |
| 56 return command.empty() && depfile.empty() && deps.empty() && | |
| 57 description.empty() && pool.empty() && restat.empty() && | |
| 58 rspfile.empty() && rspfile_content.empty(); | |
| 59 } | |
| 60 | |
| 61 std::string command; | |
| 62 std::string depfile; | |
| 63 std::string deps; | |
| 64 std::string description; | |
| 65 std::string pool; | |
| 66 std::string restat; | |
| 67 std::string rspfile; | |
| 68 std::string rspfile_content; | |
| 69 }; | |
| 70 | |
| 71 Toolchain(const Label& label); | |
| 72 virtual ~Toolchain(); | |
| 73 | |
| 74 // Item overrides. | |
| 75 virtual Toolchain* AsToolchain() OVERRIDE; | |
| 76 virtual const Toolchain* AsToolchain() const OVERRIDE; | |
| 77 | |
| 78 // Returns TYPE_NONE on failure. | |
| 79 static ToolType ToolNameToType(const base::StringPiece& str); | |
| 80 static std::string ToolTypeToName(ToolType type); | |
| 81 | |
| 82 const Tool& GetTool(ToolType type) const; | |
| 83 void SetTool(ToolType type, const Tool& t); | |
| 84 | |
| 85 const std::string& environment() const { return environment_; } | |
| 86 void set_environment(const std::string& env) { environment_ = env; } | |
| 87 | |
| 88 private: | |
| 89 Tool tools_[TYPE_NUMTYPES]; | |
| 90 | |
| 91 std::string environment_; | |
| 92 }; | |
| 93 | |
| 94 #endif // TOOLS_GN_TOOLCHAIN_H_ | |
| OLD | NEW |