1 // Copyright 2019 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/general_tool.h" 6 #include "gn/target.h" 7 8 const char* GeneralTool::kGeneralToolStamp = "stamp"; 9 const char* GeneralTool::kGeneralToolCopy = "copy"; 10 const char* GeneralTool::kGeneralToolCopyBundleData = "copy_bundle_data"; 11 const char* GeneralTool::kGeneralToolCompileXCAssets = "compile_xcassets"; 12 const char* GeneralTool::kGeneralToolAction = "action"; 13 GeneralTool(const char * n)14GeneralTool::GeneralTool(const char* n) : Tool(n) { 15 CHECK(ValidateName(n)); 16 } 17 18 GeneralTool::~GeneralTool() = default; 19 AsGeneral()20GeneralTool* GeneralTool::AsGeneral() { 21 return this; 22 } AsGeneral() const23const GeneralTool* GeneralTool::AsGeneral() const { 24 return this; 25 } 26 ValidateName(const char * name) const27bool GeneralTool::ValidateName(const char* name) const { 28 return name == kGeneralToolStamp || name == kGeneralToolCopy || 29 name == kGeneralToolCopyBundleData || 30 name == kGeneralToolCompileXCAssets || name == kGeneralToolAction; 31 } 32 SetComplete()33void GeneralTool::SetComplete() { 34 SetToolComplete(); 35 } 36 InitTool(Scope * scope,Toolchain * toolchain,Err * err)37bool GeneralTool::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 GeneralTool::ValidateSubstitution(const Substitution* sub_type) const { 43 if (name_ == kGeneralToolStamp || name_ == kGeneralToolAction) 44 return IsValidToolSubstitution(sub_type); 45 else if (name_ == kGeneralToolCopy || name_ == kGeneralToolCopyBundleData) 46 return IsValidCopySubstitution(sub_type); 47 else if (name_ == kGeneralToolCompileXCAssets) 48 return IsValidCompileXCassetsSubstitution(sub_type); 49 NOTREACHED(); 50 return false; 51 } 52