2 # This file is used to check format of comments
4 # Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
8 from CommonDataClass
.DataClass
import (
9 MODEL_PCD_PATCHABLE_IN_MODULE
,
16 from Common
.BuildToolError
import FORMAT_INVALID
17 import Common
.EdkLogger
as EdkLogger
19 UsageList
= ("PRODUCES", "PRODUCED", "ALWAYS_PRODUCES", "ALWAYS_PRODUCED", "SOMETIMES_PRODUCES",
20 "SOMETIMES_PRODUCED", "CONSUMES", "CONSUMED", "ALWAYS_CONSUMES", "ALWAYS_CONSUMED",
21 "SOMETIMES_CONSUMES", "SOMETIMES_CONSUMED", "SOMETIME_CONSUMES")
23 MODEL_EFI_GUID
: "The usage for this GUID is not listed in this INF: %s[%d]:%s",
24 MODEL_EFI_PPI
: "The usage for this PPI is not listed in this INF: %s[%d]:%s.",
25 MODEL_EFI_PROTOCOL
: "The usage for this Protocol is not listed in this INF: %s[%d]:%s.",
26 MODEL_PCD_DYNAMIC
: "The usage for this PCD is not listed in this INF: %s[%d]:%s."
29 def CheckInfComment(SectionType
, Comments
, InfFile
, LineNo
, ValueList
):
30 if SectionType
in [MODEL_PCD_PATCHABLE_IN_MODULE
, MODEL_PCD_DYNAMIC_EX
, MODEL_PCD_DYNAMIC
]:
31 CheckUsage(Comments
, UsageList
, InfFile
, LineNo
, ValueList
[0]+'.'+ValueList
[1], ErrorMsgMap
[MODEL_PCD_DYNAMIC
])
32 elif SectionType
in [MODEL_EFI_GUID
, MODEL_EFI_PPI
]:
33 CheckUsage(Comments
, UsageList
, InfFile
, LineNo
, ValueList
[0], ErrorMsgMap
[SectionType
])
34 elif SectionType
== MODEL_EFI_PROTOCOL
:
35 CheckUsage(Comments
, UsageList
+ ("TO_START", "BY_START"), InfFile
, LineNo
, ValueList
[0], ErrorMsgMap
[SectionType
])
37 def CheckUsage(Comments
, Usages
, InfFile
, LineNo
, Value
, ErrorMsg
):
38 for Comment
in Comments
:
39 for Word
in Comment
[0].replace('#', ' ').split():
43 "Parser", FORMAT_INVALID
,
44 ErrorMsg
% (InfFile
, LineNo
, Value
)