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 #include "tools/gn/toolchain.h"
7 #include "base/logging.h"
8 #include "tools/gn/value.h"
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";
22 Toolchain::Tool::Tool() {
25 Toolchain::Tool::~Tool() {
28 Toolchain::Toolchain(const Settings
* settings
, const Label
& label
)
29 : Item(settings
, label
) {
32 Toolchain::~Toolchain() {
35 Toolchain
* Toolchain::AsToolchain() {
39 const Toolchain
* Toolchain::AsToolchain() const {
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
;
60 std::string
Toolchain::ToolTypeToName(ToolType 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
;
79 const Toolchain::Tool
& Toolchain::GetTool(ToolType type
) const {
80 DCHECK(type
!= TYPE_NONE
);
81 return tools_
[static_cast<size_t>(type
)];
84 void Toolchain::SetTool(ToolType type
, const Tool
& t
) {
85 DCHECK(type
!= TYPE_NONE
);
86 tools_
[static_cast<size_t>(type
)] = t
;