BaseTools: Library hashing fix and optimization for --hash feature
[mirror_edk2.git] / BaseTools / Source / Python / Common / GlobalData.py
1 ## @file
2 # This file is used to define common static strings used by INF/DEC/DSC files
3 #
4 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 import re
8
9 gIsWindows = None
10 gWorkspace = "."
11 gOptions = None
12 gCaseInsensitive = False
13 gAllFiles = None
14 gCommand = None
15 gSKUID_CMD = None
16
17 gGlobalDefines = {}
18 gPlatformDefines = {}
19 # PCD name and value pair for fixed at build and feature flag
20 gPlatformPcds = {}
21 # PCDs with type that are not fixed at build and feature flag
22 gPlatformOtherPcds = {}
23 gActivePlatform = None
24 gCommandLineDefines = {}
25 gEdkGlobal = {}
26 gCommandMaxLength = 4096
27 # for debug trace purpose when problem occurs
28 gProcessingFile = ''
29 gBuildingModule = ''
30 gSkuids = []
31 gDefaultStores = []
32
33 # definition for a MACRO name. used to create regular expressions below.
34 _MacroNamePattern = "[A-Z][A-Z0-9_]*"
35
36 ## Regular expression for matching macro used in DSC/DEC/INF file inclusion
37 gMacroRefPattern = re.compile("\$\(({})\)".format(_MacroNamePattern), re.UNICODE)
38 gMacroDefPattern = re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+")
39 gMacroNamePattern = re.compile("^{}$".format(_MacroNamePattern))
40
41 # definition for a GUID. used to create regular expressions below.
42 _HexChar = r"[0-9a-fA-F]"
43 _GuidPattern = r"{Hex}{{8}}-{Hex}{{4}}-{Hex}{{4}}-{Hex}{{4}}-{Hex}{{12}}".format(Hex=_HexChar)
44
45 ## Regular expressions for GUID matching
46 gGuidPattern = re.compile(r'{}'.format(_GuidPattern))
47 gGuidPatternEnd = re.compile(r'{}$'.format(_GuidPattern))
48
49 ## Regular expressions for HEX matching
50 g4HexChar = re.compile(r'{}{{4}}'.format(_HexChar))
51 gHexPattern = re.compile(r'0[xX]{}+'.format(_HexChar))
52 gHexPatternAll = re.compile(r'0[xX]{}+$'.format(_HexChar))
53
54 ## Regular expressions for string identifier checking
55 gIdentifierPattern = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$', re.UNICODE)
56 ## Regular expression for GUID c structure format
57 _GuidCFormatPattern = r"{{\s*0[xX]{Hex}{{1,8}}\s*,\s*0[xX]{Hex}{{1,4}}\s*,\s*0[xX]{Hex}{{1,4}}" \
58 r"\s*,\s*{{\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}" \
59 r"\s*,\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}" \
60 r"\s*,\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}" \
61 r"\s*,\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}\s*}}\s*}}".format(Hex=_HexChar)
62 gGuidCFormatPattern = re.compile(r"{}".format(_GuidCFormatPattern))
63
64 #
65 # A global variable for whether current build in AutoGen phase or not.
66 #
67 gAutoGenPhase = False
68
69 #
70 # The Conf dir outside the workspace dir
71 #
72 gConfDirectory = ''
73
74 gBuildDirectory = ''
75 #
76 # The relative default database file path
77 #
78 gDatabasePath = ".cache/build.db"
79
80 #
81 # Build flag for binary build
82 #
83 gIgnoreSource = False
84
85 #
86 # FDF parser
87 #
88 gFdfParser = None
89
90 BuildOptionPcd = []
91
92 #
93 # Mixed PCD name dict
94 #
95 MixedPcd = {}
96
97 # Structure Pcd dict
98 gStructurePcd = {}
99 gPcdSkuOverrides={}
100 # Pcd name for the Pcd which used in the Conditional directives
101 gConditionalPcds = []
102
103 gUseHashCache = None
104 gBinCacheDest = None
105 gBinCacheSource = None
106 gPlatformHash = None
107 gPackageHash = {}
108 gModuleHash = {}
109 gEnableGenfdsMultiThread = False
110 gSikpAutoGenCache = set()
111
112 # Dictionary for tracking Module build status as success or failure
113 # False -> Fail : True -> Success
114 gModuleBuildTracking = dict()
115
116 # Dictionary of booleans that dictate whether a module or
117 # library can be skiped
118 # Top Dict: Key: Arch Type Value: Dictionary
119 # Second Dict: Key: Module\Library Name Value: True\False
120 gBuildHashSkipTracking = dict()