1 // Copyright 2020 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 "gn/builtin_tool.h" 6 #include "base/logging.h" 7 #include "gn/target.h" 8 9 // static 10 const char BuiltinTool::kBuiltinToolPhony[] = "phony"; 11 BuiltinTool(const char * n)12BuiltinTool::BuiltinTool(const char* n) : Tool(n) { 13 CHECK(ValidateName(n)); 14 // Unlike regular tools, which are read from a file, 15 // builtin-tools are always ready to go and do not need 16 // phased construction. 17 SetToolComplete(); 18 } 19 20 BuiltinTool::~BuiltinTool() = default; 21 AsBuiltin()22BuiltinTool* BuiltinTool::AsBuiltin() { 23 return this; 24 } AsBuiltin() const25const BuiltinTool* BuiltinTool::AsBuiltin() const { 26 return this; 27 } 28 ValidateName(const char * name) const29bool BuiltinTool::ValidateName(const char* name) const { 30 return name == kBuiltinToolPhony; 31 } 32 SetComplete()33void BuiltinTool::SetComplete() { 34 // Already performed in constructor 35 } 36 InitTool(Scope * scope,Toolchain * toolchain,Err * err)37bool BuiltinTool::InitTool(Scope* scope, Toolchain* toolchain, Err* err) { 38 // Initialize default vars. 39 return Tool::InitTool(scope, toolchain, err); 40 } 41 ValidateSubstitution(const Substitution * sub_type) const42bool BuiltinTool::ValidateSubstitution(const Substitution* sub_type) const { 43 if (name_ == kBuiltinToolPhony) 44 return IsValidToolSubstitution(sub_type); 45 NOTREACHED(); 46 return false; 47 } 48