]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/build/build.py
BaseTools: update the mail address for stack trace info
[mirror_edk2.git] / BaseTools / Source / Python / build / build.py
index b5df773f08d9a715536e238d6fa586ab14636c7e..23ca76e82c121777c7455bb35c0ba7e4abc160ca 100644 (file)
@@ -2,7 +2,7 @@
 # build a platform or a module\r
 #\r
 #  Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>\r
-#  Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2016, 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
@@ -156,16 +156,18 @@ def CheckEnvVariable():
         EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "No space is allowed in EFI_SOURCE path",\r
                         ExtraData=EfiSourceDir)\r
 \r
-    # change absolute path to relative path to WORKSPACE\r
-    if EfiSourceDir.upper().find(WorkspaceDir.upper()) != 0:\r
-        EdkLogger.error("build", PARAMETER_INVALID, "EFI_SOURCE is not under WORKSPACE",\r
-                        ExtraData="WORKSPACE = %s\n    EFI_SOURCE = %s" % (WorkspaceDir, EfiSourceDir))\r
-    if EdkSourceDir.upper().find(WorkspaceDir.upper()) != 0:\r
-        EdkLogger.error("build", PARAMETER_INVALID, "EDK_SOURCE is not under WORKSPACE",\r
-                        ExtraData="WORKSPACE = %s\n    EDK_SOURCE = %s" % (WorkspaceDir, EdkSourceDir))\r
-    if EcpSourceDir.upper().find(WorkspaceDir.upper()) != 0:\r
-        EdkLogger.error("build", PARAMETER_INVALID, "ECP_SOURCE is not under WORKSPACE",\r
-                        ExtraData="WORKSPACE = %s\n    ECP_SOURCE = %s" % (WorkspaceDir, EcpSourceDir))\r
+    # check those variables on single workspace case\r
+    if not PackagesPath:\r
+        # change absolute path to relative path to WORKSPACE\r
+        if EfiSourceDir.upper().find(WorkspaceDir.upper()) != 0:\r
+            EdkLogger.error("build", PARAMETER_INVALID, "EFI_SOURCE is not under WORKSPACE",\r
+                            ExtraData="WORKSPACE = %s\n    EFI_SOURCE = %s" % (WorkspaceDir, EfiSourceDir))\r
+        if EdkSourceDir.upper().find(WorkspaceDir.upper()) != 0:\r
+            EdkLogger.error("build", PARAMETER_INVALID, "EDK_SOURCE is not under WORKSPACE",\r
+                            ExtraData="WORKSPACE = %s\n    EDK_SOURCE = %s" % (WorkspaceDir, EdkSourceDir))\r
+        if EcpSourceDir.upper().find(WorkspaceDir.upper()) != 0:\r
+            EdkLogger.error("build", PARAMETER_INVALID, "ECP_SOURCE is not under WORKSPACE",\r
+                            ExtraData="WORKSPACE = %s\n    ECP_SOURCE = %s" % (WorkspaceDir, EcpSourceDir))\r
 \r
     # check EDK_TOOLS_PATH\r
     if "EDK_TOOLS_PATH" not in os.environ:\r
@@ -208,7 +210,7 @@ def NormFile(FilePath, Workspace):
 \r
     # check if the file path exists or not\r
     if not os.path.isfile(FileFullPath):\r
-        EdkLogger.error("build", FILE_NOT_FOUND, ExtraData="\t%s (Please give file in absolute path or relative to WORKSPACE)"  % FileFullPath)\r
+        EdkLogger.error("build", FILE_NOT_FOUND, ExtraData="\t%s (Please give file in absolute path or relative to WORKSPACE)" % FileFullPath)\r
 \r
     # remove workspace directory from the beginning part of the file path\r
     if Workspace[-1] in ["\\", "/"]:\r
@@ -285,6 +287,7 @@ def LaunchCommand(Command, WorkingDir):
         Proc.wait()\r
     except: # in case of aborting\r
         # terminate the threads redirecting the program output\r
+        EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())\r
         if EndOfProcedure != None:\r
             EndOfProcedure.set()\r
         if Proc == None:\r
@@ -778,10 +781,16 @@ class Build():
 \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
+            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
+            EdkLogger.quiet("%-16s = %s" % ("EDK_TOOLS_BIN", os.path.normcase(os.path.normpath(os.environ["EDK_TOOLS_BIN"]))))\r
 \r
         EdkLogger.info("")\r
 \r
@@ -1114,13 +1123,13 @@ class Build():
                 # Update Image to new BaseAddress by GenFw tool\r
                 #\r
                 LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)\r
-                LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleDebugImage],  ModuleInfo.DebugDir)\r
+                LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleDebugImage], ModuleInfo.DebugDir)\r
             else:\r
                 #\r
                 # Set new address to the section header only for SMM driver.\r
                 #\r
                 LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)\r
-                LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleDebugImage],  ModuleInfo.DebugDir)\r
+                LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleDebugImage], ModuleInfo.DebugDir)\r
             #\r
             # Collect funtion address from Map file\r
             #\r
@@ -1128,7 +1137,7 @@ class Build():
             FunctionList = []\r
             if os.path.exists(ImageMapTable):\r
                 OrigImageBaseAddress = 0\r
-                ImageMap = open (ImageMapTable, 'r')\r
+                ImageMap = open(ImageMapTable, 'r')\r
                 for LinStr in ImageMap:\r
                     if len (LinStr.strip()) == 0:\r
                         continue\r
@@ -1141,7 +1150,7 @@ class Build():
 \r
                     StrList = LinStr.split()\r
                     if len (StrList) > 4:\r
-                        if StrList[3] == 'f' or StrList[3] =='F':\r
+                        if StrList[3] == 'f' or StrList[3] == 'F':\r
                             Name = StrList[1]\r
                             RelativeAddress = int (StrList[2], 16) - OrigImageBaseAddress\r
                             FunctionList.append ((Name, RelativeAddress))\r
@@ -1265,7 +1274,7 @@ class Build():
                     if not ImageClass.IsValid:\r
                         EdkLogger.error("build", FILE_PARSE_FAILURE, ExtraData=ImageClass.ErrorInfo)\r
                     ImageInfo = PeImageInfo(Module.Name, Module.Guid, Module.Arch, Module.OutputDir, Module.DebugDir, ImageClass)\r
-                    if Module.ModuleType in ['PEI_CORE', 'PEIM', 'COMBINED_PEIM_DRIVER','PIC_PEIM', 'RELOCATABLE_PEIM', 'DXE_CORE']:\r
+                    if Module.ModuleType in ['PEI_CORE', 'PEIM', 'COMBINED_PEIM_DRIVER', 'PIC_PEIM', 'RELOCATABLE_PEIM', 'DXE_CORE']:\r
                         PeiModuleList[Module.MetaFile] = ImageInfo\r
                         PeiSize += ImageInfo.Image.Size\r
                     elif Module.ModuleType in ['BS_DRIVER', 'DXE_DRIVER', 'UEFI_DRIVER']:\r
@@ -1346,21 +1355,21 @@ class Build():
             for PcdInfo in PcdTable:\r
                 ReturnValue = 0\r
                 if PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE:\r
-                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE, str (PeiSize/0x1000))\r
+                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE, str (PeiSize / 0x1000))\r
                 elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE:\r
-                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE, str (BtSize/0x1000))\r
+                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE, str (BtSize / 0x1000))\r
                 elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE:\r
-                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE, str (RtSize/0x1000))\r
+                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE, str (RtSize / 0x1000))\r
                 elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE and len (SmmModuleList) > 0:\r
-                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, str (SmmSize/0x1000))\r
+                    ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, str (SmmSize / 0x1000))\r
                 if ReturnValue != 0:\r
                     EdkLogger.error("build", PARAMETER_INVALID, "Patch PCD value failed", ExtraData=ErrorInfo)\r
 \r
-        MapBuffer.write('PEI_CODE_PAGE_NUMBER      = 0x%x\n' % (PeiSize/0x1000))\r
-        MapBuffer.write('BOOT_CODE_PAGE_NUMBER     = 0x%x\n' % (BtSize/0x1000))\r
-        MapBuffer.write('RUNTIME_CODE_PAGE_NUMBER  = 0x%x\n' % (RtSize/0x1000))\r
+        MapBuffer.write('PEI_CODE_PAGE_NUMBER      = 0x%x\n' % (PeiSize / 0x1000))\r
+        MapBuffer.write('BOOT_CODE_PAGE_NUMBER     = 0x%x\n' % (BtSize / 0x1000))\r
+        MapBuffer.write('RUNTIME_CODE_PAGE_NUMBER  = 0x%x\n' % (RtSize / 0x1000))\r
         if len (SmmModuleList) > 0:\r
-            MapBuffer.write('SMM_CODE_PAGE_NUMBER      = 0x%x\n' % (SmmSize/0x1000))\r
+            MapBuffer.write('SMM_CODE_PAGE_NUMBER      = 0x%x\n' % (SmmSize / 0x1000))\r
 \r
         PeiBaseAddr = TopMemoryAddress - RtSize - BtSize\r
         BtBaseAddr  = TopMemoryAddress - RtSize\r
@@ -1369,7 +1378,7 @@ class Build():
         self._RebaseModule (MapBuffer, PeiBaseAddr, PeiModuleList, TopMemoryAddress == 0)\r
         self._RebaseModule (MapBuffer, BtBaseAddr, BtModuleList, TopMemoryAddress == 0)\r
         self._RebaseModule (MapBuffer, RtBaseAddr, RtModuleList, TopMemoryAddress == 0)\r
-        self._RebaseModule (MapBuffer, 0x1000, SmmModuleList, AddrIsOffset = False, ModeIsSmm = True)\r
+        self._RebaseModule (MapBuffer, 0x1000, SmmModuleList, AddrIsOffset=False, ModeIsSmm=True)\r
         MapBuffer.write('\n\n')\r
         sys.stdout.write ("\n")\r
         sys.stdout.flush()\r
@@ -1387,7 +1396,7 @@ class Build():
         SaveFileOnChange(MapFilePath, MapBuffer.getvalue(), False)\r
         MapBuffer.close()\r
         if self.LoadFixAddress != 0:\r
-            sys.stdout.write ("\nLoad Module At Fix Address Map file can be found at %s\n" %(MapFilePath))\r
+            sys.stdout.write ("\nLoad Module At Fix Address Map file can be found at %s\n" % (MapFilePath))\r
         sys.stdout.flush()\r
 \r
     ## Build active platform for different build targets and different tool chains\r
@@ -1521,7 +1530,7 @@ class Build():
                                 BUILD_ERROR,\r
                                 "Module for [%s] is not a component of active platform."\\r
                                 " Please make sure that the ARCH and inf file path are"\\r
-                                " given in the same as in [%s]" %\\r
+                                " given in the same as in [%s]" % \\r
                                     (', '.join(Wa.ArchList), self.PlatformFile),\r
                                 ExtraData=self.ModuleFile\r
                                 )\r
@@ -1866,8 +1875,8 @@ def SingleCheckCallback(option, opt_str, value, parser):
 #   @retval Args  Target of build command\r
 #\r
 def MyOptionParser():\r
-    Parser = OptionParser(description=__copyright__,version=__version__,prog="build.exe",usage="%prog [options] [all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]")\r
-    Parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32','X64','IPF','EBC','ARM', 'AARCH64'], dest="TargetArch",\r
+    Parser = OptionParser(description=__copyright__, version=__version__, prog="build.exe", usage="%prog [options] [all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]")\r
+    Parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32', 'X64', 'IPF', 'EBC', 'ARM', 'AARCH64'], dest="TargetArch",\r
         help="ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 or EBC, which overrides target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option.")\r
     Parser.add_option("-p", "--platform", action="callback", type="string", dest="PlatformFile", callback=SingleCheckCallback,\r
         help="Build the platform specified by the DSC file name argument, overriding target.txt's ACTIVE_PLATFORM definition.")\r
@@ -1909,7 +1918,7 @@ def MyOptionParser():
     Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")\r
 \r
     Parser.add_option("-y", "--report-file", action="store", dest="ReportFile", help="Create/overwrite the report to the specified filename.")\r
-    Parser.add_option("-Y", "--report-type", action="append", type="choice", choices=['PCD','LIBRARY','FLASH','DEPEX','BUILD_FLAGS','FIXED_ADDRESS', 'EXECUTION_ORDER'], dest="ReportType", default=[],\r
+    Parser.add_option("-Y", "--report-type", action="append", type="choice", choices=['PCD', 'LIBRARY', 'FLASH', 'DEPEX', 'BUILD_FLAGS', 'FIXED_ADDRESS', 'EXECUTION_ORDER'], dest="ReportType", default=[],\r
         help="Flags that control the type of build report to generate.  Must be one of: [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS, FIXED_ADDRESS, EXECUTION_ORDER].  "\\r
              "To specify more than one flag, repeat this option on the command line and the default flag set is [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS, FIXED_ADDRESS]")\r
     Parser.add_option("-F", "--flag", action="store", type="string", dest="Flag",\r
@@ -1921,7 +1930,7 @@ def MyOptionParser():
     Parser.add_option("--check-usage", action="store_true", dest="CheckUsage", default=False, help="Check usage content of entries listed in INF file.")\r
     Parser.add_option("--ignore-sources", action="store_true", dest="IgnoreSources", default=False, help="Focus to a binary build and ignore all source files")\r
 \r
-    (Opt, Args)=Parser.parse_args()\r
+    (Opt, Args) = Parser.parse_args()\r
     return (Opt, Args)\r
 \r
 ## Tool entrance method\r
@@ -1977,13 +1986,13 @@ def Main():
             Target = "all"\r
         elif len(Target) >= 2:\r
             EdkLogger.error("build", OPTION_NOT_SUPPORTED, "More than one targets are not supported.",\r
-                            ExtraData="Please select one of: %s" %(' '.join(gSupportedTarget)))\r
+                            ExtraData="Please select one of: %s" % (' '.join(gSupportedTarget)))\r
         else:\r
             Target = Target[0].lower()\r
 \r
         if Target not in gSupportedTarget:\r
             EdkLogger.error("build", OPTION_NOT_SUPPORTED, "Not supported target [%s]." % Target,\r
-                            ExtraData="Please select one of: %s" %(' '.join(gSupportedTarget)))\r
+                            ExtraData="Please select one of: %s" % (' '.join(gSupportedTarget)))\r
 \r
         #\r
         # Check environment variable: EDK_TOOLS_PATH, WORKSPACE, PATH\r
@@ -2061,7 +2070,7 @@ def Main():
         if Option != None and Option.debug != None:\r
             EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())\r
         else:\r
-            EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError = False)\r
+            EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False)\r
         ReturnCode = FORMAT_INVALID\r
     except KeyboardInterrupt:\r
         ReturnCode = ABORT_ERROR\r
@@ -2083,7 +2092,7 @@ def Main():
                     "\nbuild",\r
                     CODE_ERROR,\r
                     "Unknown fatal error when processing [%s]" % MetaFile,\r
-                    ExtraData="\n(Please send email to edk2-devel@lists.sourceforge.net for help, attaching following call stack trace!)\n",\r
+                    ExtraData="\n(Please send email to edk2-devel@lists.01.org for help, attaching following call stack trace!)\n",\r
                     RaiseError=False\r
                     )\r
         EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())\r
@@ -2102,7 +2111,7 @@ def Main():
     BuildDuration = time.gmtime(int(round(FinishTime - StartTime)))\r
     BuildDurationStr = ""\r
     if BuildDuration.tm_yday > 1:\r
-        BuildDurationStr = time.strftime("%H:%M:%S", BuildDuration) + ", %d day(s)"%(BuildDuration.tm_yday - 1)\r
+        BuildDurationStr = time.strftime("%H:%M:%S", BuildDuration) + ", %d day(s)" % (BuildDuration.tm_yday - 1)\r
     else:\r
         BuildDurationStr = time.strftime("%H:%M:%S", BuildDuration)\r
     if MyBuild != None:\r