## @file\r
# process OptionROM generation\r
#\r
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
#\r
\r
##\r
# Import Modules\r
#\r
-import os\r
-import shutil\r
+from __future__ import absolute_import\r
+import Common.LongFilePathOs as os\r
import subprocess\r
-import StringIO\r
\r
-import OptRomInfStatement\r
-from GenFdsGlobalVariable import GenFdsGlobalVariable\r
-from GenFds import GenFds\r
+from . import OptRomInfStatement\r
+from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
from CommonDataClass.FdfClass import OptionRomClassObject\r
from Common.Misc import SaveFileOnChange\r
from Common import EdkLogger\r
from Common.BuildToolError import *\r
\r
-T_CHAR_LF = '\n'\r
-\r
-## \r
+##\r
#\r
#\r
class OPTIONROM (OptionRomClassObject):\r
#\r
# @param self The object pointer\r
#\r
- def __init__(self):\r
+ def __init__(self, Name = ""):\r
OptionRomClassObject.__init__(self)\r
-\r
+ self.DriverName = Name\r
\r
## AddToBuffer()\r
#\r
# @param Buffer The buffer generated OptROM data will be put\r
# @retval string Generated OptROM file path\r
#\r
- def AddToBuffer (self, Buffer) :\r
-\r
- GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %self.DriverName)\r
+ def AddToBuffer (self, Buffer, Flag=False) :\r
+ if not Flag:\r
+ GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %self.DriverName)\r
\r
EfiFileList = []\r
BinFileList = []\r
\r
# Process Modules in FfsList\r
for FfsFile in self.FfsList :\r
- \r
+\r
if isinstance(FfsFile, OptRomInfStatement.OptRomInfStatement):\r
- FilePathNameList = FfsFile.GenFfs()\r
+ FilePathNameList = FfsFile.GenFfs(IsMakefile=Flag)\r
if len(FilePathNameList) == 0:\r
EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile.InfFileName))\r
- if FfsFile.OverrideAttribs == None:\r
+ if FfsFile.OverrideAttribs is None:\r
EfiFileList.extend(FilePathNameList)\r
else:\r
FileName = os.path.basename(FilePathNameList[0])\r
- TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r
+ TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName, FfsFile.CurrentArch)\r
if not os.path.exists(TmpOutputDir) :\r
os.makedirs(TmpOutputDir)\r
TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')\r
- \r
- GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile, \r
- FilePathNameList, \r
- [], \r
- FfsFile.OverrideAttribs.NeedCompress, \r
- FfsFile.OverrideAttribs.PciClassCode, \r
- FfsFile.OverrideAttribs.PciRevision, \r
- FfsFile.OverrideAttribs.PciDeviceId, \r
- FfsFile.OverrideAttribs.PciVendorId)\r
+\r
+ GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile,\r
+ FilePathNameList,\r
+ [],\r
+ FfsFile.OverrideAttribs.NeedCompress,\r
+ FfsFile.OverrideAttribs.PciClassCode,\r
+ FfsFile.OverrideAttribs.PciRevision,\r
+ FfsFile.OverrideAttribs.PciDeviceId,\r
+ FfsFile.OverrideAttribs.PciVendorId,\r
+ IsMakefile = Flag)\r
BinFileList.append(TmpOutputFile)\r
else:\r
- FilePathName = FfsFile.GenFfs()\r
- if FfsFile.OverrideAttribs != None:\r
+ FilePathName = FfsFile.GenFfs(IsMakefile=Flag)\r
+ if FfsFile.OverrideAttribs is not None:\r
FileName = os.path.basename(FilePathName)\r
- TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r
+ TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName, FfsFile.CurrentArch)\r
if not os.path.exists(TmpOutputDir) :\r
os.makedirs(TmpOutputDir)\r
TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')\r
- \r
- GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile, \r
- [FilePathName], \r
- [], \r
- FfsFile.OverrideAttribs.NeedCompress, \r
- FfsFile.OverrideAttribs.PciClassCode, \r
- FfsFile.OverrideAttribs.PciRevision, \r
- FfsFile.OverrideAttribs.PciDeviceId, \r
- FfsFile.OverrideAttribs.PciVendorId)\r
+\r
+ GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile,\r
+ [FilePathName],\r
+ [],\r
+ FfsFile.OverrideAttribs.NeedCompress,\r
+ FfsFile.OverrideAttribs.PciClassCode,\r
+ FfsFile.OverrideAttribs.PciRevision,\r
+ FfsFile.OverrideAttribs.PciDeviceId,\r
+ FfsFile.OverrideAttribs.PciVendorId,\r
+ IsMakefile=Flag)\r
BinFileList.append(TmpOutputFile)\r
else:\r
if FfsFile.FileType == 'EFI':\r
EfiFileList.append(FilePathName)\r
else:\r
BinFileList.append(FilePathName)\r
- \r
+\r
#\r
# Call EfiRom tool\r
#\r
OutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r
OutputFile = OutputFile + '.rom'\r
- \r
+\r
GenFdsGlobalVariable.GenerateOptionRom(\r
OutputFile,\r
EfiFileList,\r
- BinFileList\r
- )\r
+ BinFileList,\r
+ IsMakefile=Flag)\r
\r
- GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successfully" %self.DriverName)\r
+ if not Flag:\r
+ GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successfully" %self.DriverName)\r
GenFdsGlobalVariable.SharpCounter = 0\r
- \r
+\r
return OutputFile\r
\r
class OverrideAttribs:\r
- \r
+\r
## The constructor\r
#\r
# @param self The object pointer\r
#\r
def __init__(self):\r
- \r
+\r
self.PciVendorId = None\r
self.PciClassCode = None\r
self.PciDeviceId = None\r
self.PciRevision = None\r
self.NeedCompress = None\r
- \r
-
\ No newline at end of file