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 #include "tools/gn/toolchain.h" 6 7 #include "base/logging.h" 8 #include "tools/gn/value.h" 9 10 const char* Toolchain::kToolCc = "cc"; 11 const char* Toolchain::kToolCxx = "cxx"; 12 const char* Toolchain::kToolObjC = "objc"; 13 const char* Toolchain::kToolObjCxx = "objcxx"; 14 const char* Toolchain::kToolRc = "rc"; 15 const char* Toolchain::kToolAsm = "asm"; 16 const char* Toolchain::kToolAlink = "alink"; 17 const char* Toolchain::kToolSolink = "solink"; 18 const char* Toolchain::kToolLink = "link"; 19 const char* Toolchain::kToolStamp = "stamp"; 20 const char* Toolchain::kToolCopy = "copy"; 21 22 Toolchain::Tool::Tool() { 23 } 24 25 Toolchain::Tool::~Tool() { 26 } 27 28 Toolchain::Toolchain(const Settings* settings, const Label& label) 29 : Item(settings, label) { 30 } 31 32 Toolchain::~Toolchain() { 33 } 34 35 Toolchain* Toolchain::AsToolchain() { 36 return this; 37 } 38 39 const Toolchain* Toolchain::AsToolchain() const { 40 return this; 41 } 42 43 // static 44 Toolchain::ToolType Toolchain::ToolNameToType(const base::StringPiece& str) { 45 if (str == kToolCc) return TYPE_CC; 46 if (str == kToolCxx) return TYPE_CXX; 47 if (str == kToolObjC) return TYPE_OBJC; 48 if (str == kToolObjCxx) return TYPE_OBJCXX; 49 if (str == kToolRc) return TYPE_RC; 50 if (str == kToolAsm) return TYPE_ASM; 51 if (str == kToolAlink) return TYPE_ALINK; 52 if (str == kToolSolink) return TYPE_SOLINK; 53 if (str == kToolLink) return TYPE_LINK; 54 if (str == kToolStamp) return TYPE_STAMP; 55 if (str == kToolCopy) return TYPE_COPY; 56 return TYPE_NONE; 57 } 58 59 // static 60 std::string Toolchain::ToolTypeToName(ToolType type) { 61 switch (type) { 62 case TYPE_CC: return kToolCc; 63 case TYPE_CXX: return kToolCxx; 64 case TYPE_OBJC: return kToolObjC; 65 case TYPE_OBJCXX: return kToolObjCxx; 66 case TYPE_RC: return kToolRc; 67 case TYPE_ASM: return kToolAsm; 68 case TYPE_ALINK: return kToolAlink; 69 case TYPE_SOLINK: return kToolSolink; 70 case TYPE_LINK: return kToolLink; 71 case TYPE_STAMP: return kToolStamp; 72 case TYPE_COPY: return kToolCopy; 73 default: 74 NOTREACHED(); 75 return std::string(); 76 } 77 } 78 79 const Toolchain::Tool& Toolchain::GetTool(ToolType type) const { 80 DCHECK(type != TYPE_NONE); 81 return tools_[static_cast<size_t>(type)]; 82 } 83 84 void Toolchain::SetTool(ToolType type, const Tool& t) { 85 DCHECK(type != TYPE_NONE); 86 tools_[static_cast<size_t>(type)] = t; 87 } 88