Skip to content

Commit

Permalink
R9 Build & GenFds ECP support initial check in.
Browse files Browse the repository at this point in the history
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1318 7335b38e-4728-0410-8992-fb3ffe349368
  • Loading branch information
jlin16 committed Sep 1, 2008
1 parent 5d30d4c commit 2d0ec7d
Show file tree
Hide file tree
Showing 19 changed files with 1,417 additions and 853 deletions.
60 changes: 54 additions & 6 deletions Source/Python/AutoGen/AutoGen.py
Expand Up @@ -344,6 +344,7 @@ def _Init(self, Workspace, PlatformFile, Target, Toolchain, Arch):
self.BuildTarget = Target
self.Arch = Arch
self.SourceDir = path.dirname(PlatformFile)
self.SourceOverrideDir = None
self.FdTargetList = self.Workspace.FdTargetList
self.FvTargetList = self.Workspace.FvTargetList

Expand Down Expand Up @@ -1031,9 +1032,14 @@ def ResolveLibraryReference(self, Module):
for LibraryName in M.Libraries:
Library = self.Platform.LibraryClasses[LibraryName, ':dummy:']
if Library == None:
EdkLogger.warn("build", "Library [%s] is not found" % LibraryName, File=str(M),
ExtraData="\t%s [%s]" % (str(Module), self.Arch))
continue
for Key in self.Platform.LibraryClasses.data.keys():
if LibraryName.upper() == Key.upper():
Library = self.Platform.LibraryClasses[Key, ':dummy:']
break
if Library == None:
EdkLogger.warn("build", "Library [%s] is not found" % LibraryName, File=str(M),
ExtraData="\t%s [%s]" % (str(Module), self.Arch))
continue

if Library not in LibraryList:
LibraryList.append(Library)
Expand Down Expand Up @@ -1164,6 +1170,11 @@ def _Init(self, Workspace, ModuleFile, Target, Toolchain, Arch, PlatformFile):
return False

self.SourceDir = path.dirname(self._MetaFile)
self.SourceOverrideDir = None
# use overrided path defined in DSC file
if self._MetaFile.upper() in GlobalData.gOverrideDir:
self.SourceOverrideDir = GlobalData.gOverrideDir[self._MetaFile.upper()]

self.FileBase, self.FileExt = path.splitext(path.basename(self._MetaFile))

self.ToolChain = Toolchain
Expand Down Expand Up @@ -1223,6 +1234,10 @@ def _GetModule(self):
## Return the module name
def _GetBaseName(self):
return self.Module.BaseName

## Return the module SourceOverridePath
def _GetSourceOverridePath(self):
return self.Module.SourceOverridePath

## Return the module meta-file GUID
def _GetGuid(self):
Expand Down Expand Up @@ -1293,7 +1308,10 @@ def _GetCustomMakefile(self):
MakeType = gMakeTypeMap[Type]
else:
MakeType = 'nmake'
self._CustomMakefile[MakeType] = os.path.join(self.SourceDir, self.Module.CustomMakefile[Type])
File = os.path.join(self.SourceOverrideDir, self.Module.CustomMakefile[Type])
if not os.path.exists(File):
File = os.path.join(self.SourceDir, self.Module.CustomMakefile[Type])
self._CustomMakefile[MakeType] = File
return self._CustomMakefile

## Return the directory of the makefile
Expand Down Expand Up @@ -1385,6 +1403,21 @@ def _GetSourceFileList(self):
ExtraData="[%s]" % self._MetaFile)
ToolChainFamily = self.PlatformInfo.ToolChainFamily["CC"]
BuildRule = self.PlatformInfo.BuildRule

# Add source override path to include
if self.SourceOverrideDir != '' and self.SourceOverrideDir != None:
Status, FullPath = ValidFile2(GlobalData.gAllFiles,
'',
Ext=None,
Workspace=GlobalData.gWorkspace,
EfiSource=GlobalData.gEfiSource,
EdkSource=GlobalData.gEdkSource,
Dir=self.SourceDir,
OverrideDir=self.SourceOverrideDir
)
if Status and FullPath not in self.IncludePathList:
self.IncludePathList.insert(0, FullPath)

for F in self.Module.Sources:
SourceFile = F.SourceFile
# match tool chain
Expand All @@ -1402,7 +1435,7 @@ def _GetSourceFileList(self):
Dir = path.dirname(SourceFile)
if Dir != "":
Dir = path.join(self.WorkspaceDir, self.SourceDir, Dir)
if Dir not in self.IncludePathList:
if Dir not in self.IncludePathList and self.AutoGenVersion >= 0x00010005:
self.IncludePathList.insert(0, Dir)

# skip unknown file
Expand All @@ -1412,7 +1445,17 @@ def _GetSourceFileList(self):
FileType, RuleObject = BuildRule[Ext, self.BuildType, self.Arch, ToolChainFamily]
# unicode must be processed by AutoGen
if FileType == "UNICODE-TEXT-FILE":
self._UnicodeFileList.append(os.path.join(self.WorkspaceDir, self.SourceDir, SourceFile))
Status, FullPath = ValidFile2(GlobalData.gAllFiles,
SourceFile,
Ext=None,
Workspace=GlobalData.gWorkspace,
EfiSource=GlobalData.gEfiSource,
EdkSource=GlobalData.gEdkSource,
Dir=self.SourceDir,
OverrideDir=self.SourceOverrideDir
)
if Status:
self._UnicodeFileList.append(FullPath)

# if there's dxs file, don't use content in [depex] section to generate .depex file
if FileType == "DEPENDENCY-EXPRESSION-FILE":
Expand Down Expand Up @@ -1613,8 +1656,13 @@ def CreateCodeFile(self, CreateLibraryCodeFile=True):

AutoGenList = []
IgoredAutoGenList = []

for File in self.AutoGenFileList:
if GenC.Generate(path.join(self.DebugDir, File), str(self.AutoGenFileList[File])):
#Ignore R8 AutoGen.c
if self.AutoGenVersion < 0x00010005 and File.find('AutoGen.c') > -1:
continue

AutoGenList.append(File)
else:
IgoredAutoGenList.append(File)
Expand Down
5 changes: 4 additions & 1 deletion Source/Python/AutoGen/BuildEngine.py
Expand Up @@ -117,7 +117,7 @@ def IsSupported(self, FileExt):
#
# @retval tuple (Source file in full path, List of individual sourcefiles, Destionation file, List of build commands)
#
def Apply(self, SourceFile, RelativeToDir, PathSeparator):
def Apply(self, SourceFile, RelativeToDir, PathSeparator, OverrideDestDir=None):
# source file
if not self.IsMultipleInput:
SrcFileName = os.path.basename(SourceFile)
Expand All @@ -131,6 +131,9 @@ def Apply(self, SourceFile, RelativeToDir, PathSeparator):
else:
SrcFileDir = "."
SrcFile = SourceFile
# Force src dir = current module dir
if OverrideDestDir != None:
SrcFileDir = "."
SrcPath = os.path.dirname(SrcFile)
else:
SrcFileName = ""
Expand Down
5 changes: 4 additions & 1 deletion Source/Python/AutoGen/GenC.py
Expand Up @@ -1634,7 +1634,7 @@ def CreateFooterCode(Info, AutoGenC, AutoGenH):
#
def CreateCode(Info, AutoGenC, AutoGenH):
CreateHeaderCode(Info, AutoGenC, AutoGenH)

if Info.AutoGenVersion >= 0x00010005:
CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH)
CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH)
Expand All @@ -1647,6 +1647,9 @@ def CreateCode(Info, AutoGenC, AutoGenH):
CreateUnicodeStringCode(Info, AutoGenC, AutoGenH)

CreateFooterCode(Info, AutoGenC, AutoGenH)

if Info.AutoGenVersion < 0x00010005 and Info.ComponentType.upper() == 'ACPITABLE':
AutoGenC.String = ''

## Create the code file
#
Expand Down
19 changes: 18 additions & 1 deletion Source/Python/AutoGen/GenMake.py
Expand Up @@ -587,13 +587,29 @@ def ProcessSourceFileList(self):
CCodeFlag = False
FileList = self._AutoGenObject.SourceFileList
SourceDir = os.path.join(self._AutoGenObject.WorkspaceDir, self._AutoGenObject.SourceDir)
#SourceOverrideDir = os.path.join(self._AutoGenObject.WorkspaceDir, self._AutoGenObject.SourceOverrideDir)

for FileInfo in FileList:
F, SrcFileType, SrcFileBuildRule = FileInfo
# no rule, no build
if SrcFileBuildRule == None:
continue
if SrcFileType == "C-CODE-FILE":
CCodeFlag = True

NewDestDir = None
NewSourceDir, SourceDir, F = ValidFile3(GlobalData.gAllFiles,
F,
Workspace=GlobalData.gWorkspace,
EfiSource=GlobalData.gEfiSource,
EdkSource=GlobalData.gEdkSource,
Dir=self._AutoGenObject.SourceDir,
OverrideDir=self._AutoGenObject.SourceOverrideDir
)
if SourceDir != NewSourceDir:
NewDestDir = SourceDir
SourceDir = NewSourceDir

SrcFileName = path.basename(F)
SrcFileBase, SrcFileExt = path.splitext(SrcFileName)
SrcFileDir = path.dirname(F)
Expand All @@ -603,9 +619,10 @@ def ProcessSourceFileList(self):
P = "$(OUTPUT_DIR)" + Separator + SrcFileDir
if P not in self.IntermediateDirectoryList:
self.IntermediateDirectoryList.append(P)

SrcFileRelativePath = os.path.join(SourceDir, F)

SrcFile, ExtraSrcFileList, DstFile, CommandList = SrcFileBuildRule.Apply(F, SourceDir, Separator)
SrcFile, ExtraSrcFileList, DstFile, CommandList = SrcFileBuildRule.Apply(F, SourceDir, Separator, OverrideDestDir=NewDestDir)
if SrcFileType not in self.SourceFileDatabase:
self.SourceFileDatabase[SrcFileType] = []
self.SourceFileDatabase[SrcFileType].append(SrcFile)
Expand Down
2 changes: 2 additions & 0 deletions Source/Python/Common/DataType.py
Expand Up @@ -237,6 +237,8 @@
TAB_COMPONENTS_IPF = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_IPF
TAB_COMPONENTS_EBC = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_EBC

TAB_COMPONENTS_SOURCE_OVERRIDE_PATH = 'SOURCE_OVERRIDE_PATH'

TAB_BUILD_OPTIONS = 'BuildOptions'

TAB_DEFINE = 'DEFINE'
Expand Down
6 changes: 6 additions & 0 deletions Source/Python/Common/GlobalData.py
Expand Up @@ -11,9 +11,15 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

gEdkCompatibilityPkg = "EdkCompatibilityPkg"
gWorkspace = "."
gEdkSource = "Edk"
gEfiSource = "Efi"

gGlobalDefines = {}
gAllFiles = {}

gEdkGlobal = {}
gOverrideDir = {}

# for debug trace purpose when problem occurs
gProcessingFile = ''
Expand Down
128 changes: 122 additions & 6 deletions Source/Python/Common/Misc.py
Expand Up @@ -257,19 +257,133 @@ def DataRestore(File):
# @retval True if file exists
# @retval False if file doesn't exists
#
def ValidFile(File, Ext=None, Dir='.'):
def ValidFile(File, Ext=None, Dir='.', OverrideDir = ''):
if Ext != None:
Dummy, FileExt = os.path.splitext(File)
if FileExt.lower() != Ext.lower():
return False
Wd = os.getcwd()
os.chdir(Dir)
if not os.path.exists(File):
os.chdir(Wd)
return False
if OverrideDir != '' and OverrideDir != None:
os.chdir(OverrideDir)
if not os.path.exists(File):
os.chdir(Dir)
if not os.path.exists(File):
os.chdir(Wd)
return False
os.chdir(Wd)
return True

## Check if gvien file exists or not
#
#
def ValidFile2(AllFiles, File, Ext=None, Workspace='', EfiSource='', EdkSource='', Dir='.', OverrideDir=''):
NewFile = File
if Ext != None:
Dummy, FileExt = os.path.splitext(File)
if FileExt.lower() != Ext.lower():
return False, File

# Replace the R8 macros
if OverrideDir != '' and OverrideDir != None:
if OverrideDir.find('$(EFI_SOURCE)') > -1:
OverrideDir = OverrideDir.replace('$(EFI_SOURCE)', EfiSource)
if OverrideDir.find('$(EDK_SOURCE)') > -1:
OverrideDir = OverrideDir.replace('$(EDK_SOURCE)', EdkSource)

# Replace the default dir to current dir
if Dir == '.':
Dir = os.getcwd()
Dir = Dir[len(Workspace)+1:]

# First check if File has R8 definition itself
if File.find('$(EFI_SOURCE)') > -1 or File.find('$(EDK_SOURCE)') > -1:
File = File.replace('$(EFI_SOURCE)', EfiSource)
File = File.replace('$(EDK_SOURCE)', EdkSource)
NewFile = os.path.normpath(os.path.join(Workspace, File))
if NewFile.upper() in AllFiles:
return True, AllFiles[NewFile.upper()]

# Second check the path with override value
if OverrideDir != '' and OverrideDir != None:
NewFile = os.path.normpath(os.path.join(Workspace, OverrideDir, File))
if NewFile.upper() in AllFiles:
return True, AllFiles[NewFile.upper()]

# Last check the path with normal definitions
NewFile = os.path.normpath(os.path.join(Workspace, Dir, File))
if NewFile.upper() in AllFiles:
return True, AllFiles[NewFile.upper()]

return False, NewFile

## Check if gvien file exists or not
#
#
def ValidFile3(AllFiles, File, Workspace='', EfiSource='', EdkSource='', Dir='.', OverrideDir=''):
# Replace the R8 macros
if OverrideDir != '' and OverrideDir != None:
if OverrideDir.find('$(EFI_SOURCE)') > -1:
OverrideDir = OverrideDir.replace('$(EFI_SOURCE)', EfiSource)
if OverrideDir.find('$(EDK_SOURCE)') > -1:
OverrideDir = OverrideDir.replace('$(EDK_SOURCE)', EdkSource)

# Replace the default dir to current dir
# Dir is current module dir related to workspace
if Dir == '.':
Dir = os.getcwd()
Dir = Dir[len(Workspace)+1:]

NewFile = File
RelaPath = AllFiles[os.path.normpath(os.path.join(Workspace, Dir)).upper()]
NewRelaPath = RelaPath

while(True):
# First check if File has R8 definition itself
if File.find('$(EFI_SOURCE)') > -1 or File.find('$(EDK_SOURCE)') > -1:
File = File.replace('$(EFI_SOURCE)', EfiSource)
File = File.replace('$(EDK_SOURCE)', EdkSource)
NewFile = os.path.normpath(os.path.join(Workspace, File))
if NewFile.upper() in AllFiles:
NewFile = AllFiles[NewFile.upper()]
NewRelaPath = os.path.dirname(NewFile)
File = os.path.basename(NewFile)
#NewRelaPath = NewFile[:len(NewFile) - len(File.replace("..\\", '').replace("../", '')) - 1]
break

# Second check the path with override value
if OverrideDir != '' and OverrideDir != None:
NewFile = os.path.normpath(os.path.join(Workspace, OverrideDir, File))
if NewFile.upper() in AllFiles:
NewFile = AllFiles[NewFile.upper()]
#NewRelaPath = os.path.dirname(NewFile)
NewRelaPath = NewFile[:len(NewFile) - len(File.replace("..\\", '').replace("../", '')) - 1]
break

# Last check the path with normal definitions
NewFile = os.path.normpath(os.path.join(Workspace, Dir, File))
if NewFile.upper() in AllFiles:
NewFile = AllFiles[NewFile.upper()]
break

# No file found
break

return NewRelaPath, RelaPath, File


def GetRelPath(Path1, Path2):
FileName = os.path.basename(Path2)
L1 = os.path.normpath(Path1).split(os.path.normpath('/'))
L2 = os.path.normpath(Path2).split(os.path.normpath('/'))
for Index in range(0, len(L1)):
if L1[Index] != L2[Index]:
FileName = '../' * (len(L1) - Index)
for Index2 in range(Index, len(L2)):
FileName = os.path.join(FileName, L2[Index2])
break
return os.path.normpath(FileName)


## Get GUID value from given packages
#
# @param CName The CName of the GUID
Expand Down Expand Up @@ -760,7 +874,9 @@ def ParseConsoleLog(Filename):
# script.
#
if __name__ == '__main__':
ParseConsoleLog('C:\\R861\\Log\\Tiger.log')
#ParseConsoleLog('C:\\R861\\Log\\Tiger.log')
print os.path.normpath(GetRelPath('C:/WK/AA', 'C:\\WK\\BB\\CC\\2.txt'))
print os.path.normpath(GetRelPath('C:\\WK\\AA', 'C:/WK//AAAA/CC\\2.txt'))
# print GuidStringToGuidStructureString('6441F818-6362-4E44-B570-7DBA31DD2453')
# d = tdict(True, 3)
# d['COMMON', 'PEIM', "A",] = 1
Expand Down

0 comments on commit 2d0ec7d

Please sign in to comment.