from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import re\r
-import StringIO\r
+from io import BytesIO\r
import sys\r
import glob\r
import time\r
from Common import Misc as Utils\r
\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
-from Common.LongFilePathSupport import LongFilePath\r
from Common.TargetTxtClassObject import *\r
from Common.ToolDefClassObject import *\r
from Common.DataType import *\r
\r
import Common.EdkLogger\r
import Common.GlobalData as GlobalData\r
-from GenFds.GenFds import GenFds\r
+from GenFds.GenFds import GenFds, GenFdsApi\r
\r
from collections import OrderedDict, defaultdict\r
\r
# Version and Copyright\r
VersionNumber = "0.60" + ' ' + gBUILD_VERSION\r
__version__ = "%prog Version " + VersionNumber\r
-__copyright__ = "Copyright (c) 2007 - 2017, Intel Corporation All rights reserved."\r
+__copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation All rights reserved."\r
\r
## standard targets of build command\r
gSupportedTarget = ['all', 'genc', 'genmake', 'modules', 'libraries', 'fds', 'clean', 'cleanall', 'cleanlib', 'run']\r
EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "No space is allowed in WORKSPACE path",\r
ExtraData=WorkspaceDir)\r
os.environ["WORKSPACE"] = WorkspaceDir\r
- \r
+\r
# set multiple workspace\r
PackagesPath = os.getenv("PACKAGES_PATH")\r
mws.setWs(WorkspaceDir, PackagesPath)\r
GlobalData.gGlobalDefines["EDK_SOURCE"] = EdkSourceDir\r
GlobalData.gGlobalDefines["ECP_SOURCE"] = EcpSourceDir\r
GlobalData.gGlobalDefines["EDK_TOOLS_PATH"] = os.environ["EDK_TOOLS_PATH"]\r
- \r
+\r
## Get normalized file path\r
#\r
# Convert the path to be local format, and remove the WORKSPACE path at the\r
# if working directory doesn't exist, Popen() will raise an exception\r
if not os.path.isdir(WorkingDir):\r
EdkLogger.error("build", FILE_NOT_FOUND, ExtraData=WorkingDir)\r
- \r
+\r
# Command is used as the first Argument in following Popen().\r
# It could be a string or sequence. We find that if command is a string in following Popen(),\r
# ubuntu may fail with an error message that the command is not found.\r
if EndOfProcedure is not None:\r
EndOfProcedure.set()\r
if Proc is None:\r
- if type(Command) != type(""):\r
+ if not isinstance(Command, type("")):\r
Command = " ".join(Command)\r
EdkLogger.error("build", COMMAND_FAILURE, "Failed to start command", ExtraData="%s [%s]" % (Command, WorkingDir))\r
\r
\r
# check the return code of the program\r
if Proc.returncode != 0:\r
- if type(Command) != type(""):\r
+ if not isinstance(Command, type("")):\r
Command = " ".join(Command)\r
# print out the Response file and its content when make failure\r
RespFile = os.path.join(WorkingDir, 'OUTPUT', 'respfilelist.txt')\r
# print current build environment and configuration\r
EdkLogger.quiet("%-16s = %s" % ("WORKSPACE", os.environ["WORKSPACE"]))\r
if "PACKAGES_PATH" in os.environ:\r
- # WORKSPACE env has been converted before. Print the same path style with WORKSPACE env. \r
+ # WORKSPACE env has been converted before. Print the same path style with WORKSPACE env.\r
EdkLogger.quiet("%-16s = %s" % ("PACKAGES_PATH", os.path.normcase(os.path.normpath(os.environ["PACKAGES_PATH"]))))\r
EdkLogger.quiet("%-16s = %s" % ("ECP_SOURCE", os.environ["ECP_SOURCE"]))\r
EdkLogger.quiet("%-16s = %s" % ("EDK_SOURCE", os.environ["EDK_SOURCE"]))\r
EdkLogger.quiet("%-16s = %s" % ("EFI_SOURCE", os.environ["EFI_SOURCE"]))\r
EdkLogger.quiet("%-16s = %s" % ("EDK_TOOLS_PATH", os.environ["EDK_TOOLS_PATH"]))\r
if "EDK_TOOLS_BIN" in os.environ:\r
- # Print the same path style with WORKSPACE env. \r
+ # Print the same path style with WORKSPACE env.\r
EdkLogger.quiet("%-16s = %s" % ("EDK_TOOLS_BIN", os.path.normcase(os.path.normpath(os.environ["EDK_TOOLS_BIN"]))))\r
EdkLogger.quiet("%-16s = %s" % ("CONF_PATH", GlobalData.gConfDirectory))\r
self.InitPreBuild()\r
if TAB_TOD_DEFINES_FAMILY not in ToolDefinition or Tool not in ToolDefinition[TAB_TOD_DEFINES_FAMILY] \\r
or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][Tool]:\r
EdkLogger.warn("build", "No tool chain family found in configuration for %s. Default to MSFT." % Tool)\r
- ToolChainFamily.append("MSFT")\r
+ ToolChainFamily.append(TAB_COMPILER_MSFT)\r
else:\r
ToolChainFamily.append(ToolDefinition[TAB_TOD_DEFINES_FAMILY][Tool])\r
self.ToolChainFamily = ToolChainFamily\r
else:\r
self.Db.InitDatabase()\r
self.Db_Flag = True\r
- Platform = self.Db._MapPlatform(str(self.PlatformFile))\r
+ Platform = self.Db.MapPlatform(str(self.PlatformFile))\r
self.Prebuild = str(Platform.Prebuild)\r
if self.Prebuild:\r
PrebuildList = []\r
if 'POSTBUILD' in GlobalData.gCommandLineDefines:\r
self.Postbuild = GlobalData.gCommandLineDefines.get('POSTBUILD')\r
else:\r
- Platform = self.Db._MapPlatform(str(self.PlatformFile))\r
+ Platform = self.Db.MapPlatform(str(self.PlatformFile))\r
self.Postbuild = str(Platform.Postbuild)\r
if self.Postbuild:\r
PostbuildList = []\r
\r
# genfds\r
if Target == 'fds':\r
- LaunchCommand(AutoGenObject.GenFdsCommand, AutoGenObject.MakeFileDir)\r
+ GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db)\r
return True\r
\r
# run\r
if not Ma.IsLibrary:\r
ModuleList[Ma.Guid.upper()] = Ma\r
\r
- MapBuffer = StringIO('')\r
+ MapBuffer = BytesIO('')\r
if self.LoadFixAddress != 0:\r
#\r
# Rebase module to the preferred memory address before GenFds\r
if not Ma.IsLibrary:\r
ModuleList[Ma.Guid.upper()] = Ma\r
\r
- MapBuffer = StringIO('')\r
+ MapBuffer = BytesIO('')\r
if self.LoadFixAddress != 0:\r
#\r
# Rebase module to the preferred memory address before GenFds\r
self._SaveMapFile (MapBuffer, Wa)\r
\r
def _GenFfsCmd(self):\r
- # convert dictionary of Cmd:(Inf,Arch) \r
+ # convert dictionary of Cmd:(Inf,Arch)\r
# to a new dictionary of (Inf,Arch):Cmd,Cmd,Cmd...\r
CmdSetDict = defaultdict(set)\r
GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData)\r
for Module in ModuleList:\r
# Get ModuleAutoGen object to generate C code file and makefile\r
Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile)\r
- \r
+\r
if Ma is None:\r
continue\r
if Ma.CanSkipbyHash():\r
#\r
# Rebase module to the preferred memory address before GenFds\r
#\r
- MapBuffer = StringIO('')\r
+ MapBuffer = BytesIO('')\r
if self.LoadFixAddress != 0:\r
self._CollectModuleMapBuffer(MapBuffer, ModuleList)\r
\r
# Generate FD image if there's a FDF file found\r
#\r
GenFdsStart = time.time()\r
- LaunchCommand(Wa.GenFdsCommand, os.getcwd())\r
+ GenFdsApi(Wa.GenFdsCommandDict, self.Db)\r
\r
#\r
# Create MAP file for all platform FVs after GenFds.\r