]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/GenFds.py
BaseTools: update the mail address for stack trace info
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GenFds.py
index c0762edf228f875ca0e8c5aad60667d3ff16f450..d97fc2813dae672e36bdfdadf4aa39a5db2112f4 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # generate flash image\r
 #\r
-#  Copyright (c) 2007 - 2013, 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
@@ -17,7 +17,7 @@
 #\r
 from optparse import OptionParser\r
 import sys\r
-import os\r
+import Common.LongFilePathOs as os\r
 import linecache\r
 import FdfParser\r
 import Common.BuildToolError as BuildToolError\r
@@ -34,15 +34,17 @@ import Common.DataType
 import Common.GlobalData as GlobalData\r
 from Common import EdkLogger\r
 from Common.String import *\r
-from Common.Misc import DirCache,PathClass\r
+from Common.Misc import DirCache, PathClass\r
 from Common.Misc import SaveFileOnChange\r
+from Common.Misc import ClearDuplicatedInf\r
 from Common.Misc import GuidStructureStringToGuidString\r
 from Common.BuildVersion import gBUILD_VERSION\r
+from Common.MultipleWorkspace import MultipleWorkspace as mws\r
 \r
 ## Version and Copyright\r
 versionNumber = "1.0" + ' ' + gBUILD_VERSION\r
 __version__ = "%prog Version " + versionNumber\r
-__copyright__ = "Copyright (c) 2007 - 2013, Intel Corporation  All rights reserved."\r
+__copyright__ = "Copyright (c) 2007 - 2014, Intel Corporation  All rights reserved."\r
 \r
 ## Tool entrance method\r
 #\r
@@ -91,8 +93,12 @@ def main():
             if 'EDK_SOURCE' in os.environ.keys():\r
                 GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE'])\r
             if (Options.debug):\r
-                GenFdsGlobalVariable.VerboseLogger( "Using Workspace:" + Workspace)\r
+                GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace)\r
         os.chdir(GenFdsGlobalVariable.WorkSpaceDir)\r
+        \r
+        # set multiple workspace\r
+        PackagesPath = os.getenv("PACKAGES_PATH")\r
+        mws.setWs(GenFdsGlobalVariable.WorkSpaceDir, PackagesPath)\r
 \r
         if (Options.filename):\r
             FdfFilename = Options.filename\r
@@ -100,12 +106,10 @@ def main():
 \r
             if FdfFilename[0:2] == '..':\r
                 FdfFilename = os.path.realpath(FdfFilename)\r
-            if not os.path.isabs (FdfFilename):\r
-                FdfFilename = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename)\r
+            if not os.path.isabs(FdfFilename):\r
+                FdfFilename = mws.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename)\r
             if not os.path.exists(FdfFilename):\r
                 EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=FdfFilename)\r
-            if os.path.normcase (FdfFilename).find(Workspace) != 0:\r
-                EdkLogger.error("GenFds", FILE_NOT_FOUND, "FdfFile doesn't exist in Workspace!")\r
 \r
             GenFdsGlobalVariable.FdfFile = FdfFilename\r
             GenFdsGlobalVariable.FdfFileTimeStamp = os.path.getmtime(FdfFilename)\r
@@ -130,15 +134,13 @@ def main():
                 ActivePlatform = os.path.realpath(ActivePlatform)\r
 \r
             if not os.path.isabs (ActivePlatform):\r
-                ActivePlatform = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform)\r
+                ActivePlatform = mws.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform)\r
 \r
             if not os.path.exists(ActivePlatform)  :\r
                 EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!")\r
 \r
-            if os.path.normcase (ActivePlatform).find(Workspace) != 0:\r
-                EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist in Workspace!")\r
-\r
-            ActivePlatform = ActivePlatform[len(Workspace):]\r
+            if os.path.normcase (ActivePlatform).find(Workspace) == 0:\r
+                ActivePlatform = mws.relpath(ActivePlatform, Workspace)\r
             if len(ActivePlatform) > 0 :\r
                 if ActivePlatform[0] == '\\' or ActivePlatform[0] == '/':\r
                     ActivePlatform = ActivePlatform[1:]\r
@@ -149,15 +151,36 @@ def main():
 \r
         GenFdsGlobalVariable.ActivePlatform = PathClass(NormPath(ActivePlatform), Workspace)\r
 \r
-        BuildConfigurationFile = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, "Conf/target.txt"))\r
+        if (Options.ConfDirectory):\r
+            # Get alternate Conf location, if it is absolute, then just use the absolute directory name\r
+            ConfDirectoryPath = os.path.normpath(Options.ConfDirectory)\r
+            if ConfDirectoryPath.startswith('"'):\r
+                ConfDirectoryPath = ConfDirectoryPath[1:]\r
+            if ConfDirectoryPath.endswith('"'):\r
+                ConfDirectoryPath = ConfDirectoryPath[:-1]\r
+            if not os.path.isabs(ConfDirectoryPath):\r
+                # Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE\r
+                # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf\r
+                ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath)\r
+        else:\r
+            # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf\r
+            ConfDirectoryPath = mws.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf')\r
+        GenFdsGlobalVariable.ConfDir = ConfDirectoryPath\r
+        BuildConfigurationFile = os.path.normpath(os.path.join(ConfDirectoryPath, "target.txt"))\r
         if os.path.isfile(BuildConfigurationFile) == True:\r
             TargetTxtClassObject.TargetTxtClassObject(BuildConfigurationFile)\r
         else:\r
             EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=BuildConfigurationFile)\r
 \r
+        #Set global flag for build mode\r
+        GlobalData.gIgnoreSource = Options.IgnoreSources\r
+\r
         if Options.Macros:\r
             for Pair in Options.Macros:\r
-                Pair.strip('"')\r
+                if Pair.startswith('"'):\r
+                    Pair = Pair[1:]\r
+                if Pair.endswith('"'):\r
+                    Pair = Pair[:-1]\r
                 List = Pair.split('=')\r
                 if len(List) == 2:\r
                     if List[0].strip() == "EFI_SOURCE":\r
@@ -177,7 +200,8 @@ def main():
         os.environ["WORKSPACE"] = Workspace\r
 \r
         """call Workspace build create database"""\r
-        BuildWorkSpace = WorkspaceDatabase(None)\r
+        GlobalData.gDatabasePath = os.path.normpath(os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath))\r
+        BuildWorkSpace = WorkspaceDatabase(GlobalData.gDatabasePath)\r
         BuildWorkSpace.InitDatabase()\r
         \r
         #\r
@@ -263,7 +287,7 @@ def main():
         GenFds.DisplayFvSpaceInfo(FdfParserObj)\r
 \r
     except FdfParser.Warning, X:\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 FatalError, X:\r
         if Options.debug != None:\r
@@ -276,11 +300,13 @@ def main():
                     "\nPython",\r
                     CODE_ERROR,\r
                     "Tools code failure",\r
-                    ExtraData="Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!\n",\r
+                    ExtraData="Please send email to edk2-devel@lists.01.org for help, attaching following call stack trace!\n",\r
                     RaiseError=False\r
                     )\r
         EdkLogger.quiet(traceback.format_exc())\r
         ReturnCode = CODE_ERROR\r
+    finally:\r
+        ClearDuplicatedInf()\r
     return ReturnCode\r
 \r
 gParamCheck = []\r
@@ -300,7 +326,7 @@ def SingleCheckCallback(option, opt_str, value, parser):
 #\r
 def myOptionParser():\r
     usage = "%prog [options] -f input_file -a arch_list -b build_target -p active_platform -t tool_chain_tag -D \"MacroName [= MacroValue]\""\r
-    Parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(versionNumber))\r
+    Parser = OptionParser(usage=usage, description=__copyright__, version="%prog " + str(versionNumber))\r
     Parser.add_option("-f", "--file", dest="filename", type="string", help="Name of FDF file to convert", action="callback", callback=SingleCheckCallback)\r
     Parser.add_option("-a", "--arch", dest="archList", help="comma separated list containing one or more of: IA32, X64, IPF, ARM, AARCH64 or EBC which should be built, overrides target.txt?s TARGET_ARCH")\r
     Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")\r
@@ -321,6 +347,9 @@ def myOptionParser():
                       action="callback", callback=SingleCheckCallback)\r
     Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")\r
     Parser.add_option("-s", "--specifyaddress", dest="FixedAddress", action="store_true", type=None, help="Specify driver load address.")\r
+    Parser.add_option("--conf", action="store", type="string", dest="ConfDirectory", help="Specify the customized Conf directory.")\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
     (Options, args) = Parser.parse_args()\r
     return Options\r
 \r
@@ -474,8 +503,8 @@ class GenFds :
             if UsedSizeValue == TotalSizeValue:\r
                 Percentage = '100'\r
             else:\r
-                Percentage = str((UsedSizeValue+0.0)/TotalSizeValue)[0:4].lstrip('0.') \r
-            \r
+                Percentage = str((UsedSizeValue + 0.0) / TotalSizeValue)[0:4].lstrip('0.')\r
+\r
             GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + Percentage + '%Full] ' + str(TotalSizeValue) + ' total, ' + str(UsedSizeValue) + ' used, ' + str(FreeSizeValue) + ' free')\r
 \r
     ## PreprocessImage()\r