1 ## @file 2 # This file is used to check format of comments 3 # 4 # Copyright (c) 2012, Intel Corporation. All rights reserved.<BR> 5 # This program and the accompanying materials 6 # are licensed and made available under the terms and conditions of the BSD License 7 # which accompanies this distribution. The full text of the license may be found at 8 # http://opensource.org/licenses/bsd-license.php 9 # 10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 # 13 14 from CommonDataClass.DataClass import ( 15 MODEL_PCD_PATCHABLE_IN_MODULE, 16 MODEL_PCD_DYNAMIC_EX, 17 MODEL_PCD_DYNAMIC, 18 MODEL_EFI_GUID, 19 MODEL_EFI_PPI, 20 MODEL_EFI_PROTOCOL 21 ) 22 from Common.BuildToolError import FORMAT_INVALID 23 import Common.EdkLogger as EdkLogger 24 25 UsageList = ("PRODUCES", "PRODUCED", "ALWAYS_PRODUCES", "ALWAYS_PRODUCED", "SOMETIMES_PRODUCES", 26 "SOMETIMES_PRODUCED", "CONSUMES", "CONSUMED", "ALWAYS_CONSUMES", "ALWAYS_CONSUMED", 27 "SOMETIMES_CONSUMES", "SOMETIMES_CONSUMED", "SOMETIME_CONSUMES") 28 ErrorMsgMap = { 29 MODEL_EFI_GUID : "The usage for this GUID is not listed in this INF: %s[%d]:%s", 30 MODEL_EFI_PPI : "The usage for this PPI is not listed in this INF: %s[%d]:%s.", 31 MODEL_EFI_PROTOCOL : "The usage for this Protocol is not listed in this INF: %s[%d]:%s.", 32 MODEL_PCD_DYNAMIC : "The usage for this PCD is not listed in this INF: %s[%d]:%s." 33 } 34 35 def CheckInfComment(SectionType, Comments, InfFile, LineNo, ValueList): 36 if SectionType in [MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_EX, MODEL_PCD_DYNAMIC]: 37 CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0]+'.'+ValueList[1], ErrorMsgMap[MODEL_PCD_DYNAMIC]) 38 elif SectionType in [MODEL_EFI_GUID, MODEL_EFI_PPI]: 39 CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType]) 40 elif SectionType == MODEL_EFI_PROTOCOL: 41 CheckUsage(Comments, UsageList + ("TO_START", "BY_START"), InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType]) 42 43 def CheckUsage(Comments, Usages, InfFile, LineNo, Value, ErrorMsg): 44 for Comment in Comments: 45 for Word in Comment[0].replace('#', ' ').split(): 46 if Word in Usages: 47 return 48 EdkLogger.error( 49 "Parser", FORMAT_INVALID, 50 ErrorMsg % (InfFile, LineNo, Value) 51 ) 52