GuidSection.py revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
## @file
# process GUIDed section generation
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Section
import subprocess
import os
from GenFdsGlobalVariable import GenFdsGlobalVariable
from Common import ToolDefClassObject
import sys
from Common.BuildToolError import *
from FvImageSection import FvImageSection
## generate GUIDed section
#
#
class GuidSection(GuidSectionClassObject) :
## The constructor
#
# @param self The object pointer
#
## GenSection() method
#
# Generate GUIDed section
#
# @param self The object pointer
# @param OutputPath Where to place output file
# @param ModuleName Which module this section belongs to
# @param SecNum Index of section
# @param KeyStringList Filter for inputs of section generation
# @param FfsInf FfsInfStatement object that contains this section data
# @param Dict dictionary contains macro and its value
# @retval tuple (Generated file name, section alignment)
#
#
# Generate all section
#
if FfsInf != None:
SectAlign = []
Index = 0
MaxAlign = None
else:
#no use FvAddr when the image is processed.
if self.FvParentAddr != None:
#no use Parent Addr when the image is processed.
self.FvParentAddr = None
# set base address for inside FvImage
ReturnSectList, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList,FfsInf, Dict)
if Sect.IncludeFvSection:
if align != None:
if MaxAlign == None:
if ReturnSectList != []:
if align == None:
align = "1"
for file in ReturnSectList:
if MaxAlign != None:
else:
if GenFdsGlobalVariable.GetAlignment (MaxAlign) > GenFdsGlobalVariable.GetAlignment (self.Alignment):
OutputFile = OutputPath + \
ModuleName + \
'SEC' + \
SecNum + \
ExternalTool = None
ExternalOption = None
#
# If not have GUID , call default
# GENCRC32 section
#
GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Section.Section.SectionType[self.SectionType], InputAlign=SectAlign)
OutputFileList = []
#or GUID not in External Tool List
elif ExternalTool == None:
else:
#
# Call GenSection with DUMMY section type.
#
#
# Use external tool process the Output
#
TempFile = OutputPath + \
ModuleName + \
'SEC' + \
SecNum + \
'.tmp'
CmdOption = '-e'
if ExternalOption != None:
if self.ProcessRequired not in ("TRUE", "1") and self.IncludeFvSection and not FvAddrIsSet and self.FvParentAddr != None:
#FirstCall is only set for the encapsulated flash FV image without process required attribute.
#
# Call external tool
#
ReturnValue = [1]
if FirstCall:
#first try to call the guided tool with -z option and CmdOption for the no process required guided tool.
GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, '-z' + ' ' + CmdOption, ReturnValue)
#
# when no call or first call failed, ReturnValue are not 1.
# Call the guided tool with CmdOption
#
Attribute = []
HeaderLength = None
#auto sec guided attribute with process required
if HeaderLength == None:
# Guided data by -z option on first call is the process required data. Call the guided tool with the real option.
#
# Call Gensection Add Section Header
#
if 'PROCESSING_REQUIRED' not in Attribute:
OutputFileList = []
if 'PROCESSING_REQUIRED' in Attribute:
# reset guided section alignment to none for the processed required guided data
## __FindExtendTool()
#
# Find location of tools to process section data
#
# @param self The object pointer
#
def __FindExtendTool__(self):
# if user not specify filter, try to deduce it from global data.
EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)
ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.WorkSpaceDir).ToolsDefTxtDictionary
ToolPathTmp = None
'_' + \
KeyList[1] + \
'_' + \
KeyList[2]
'_' + \
KeyList[3] + \
'_' + \
'PATH')
'_' + \
KeyList[3] + \
'_' + \
'FLAGS')
if ToolPathTmp == None:
else:
if ToolPathTmp != ToolPath:
EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))
return ToolPathTmp, ToolOption