]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/GenFds.py
License header updated to match correct format.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GenFds.py
index c5ccda677b0cd83d18e14386512226fe53f8c5be..c4e433d42530d979594c1852ff2ce2074aa010bc 100644 (file)
@@ -36,6 +36,7 @@ from Common import EdkLogger
 from Common.String import *\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
 \r
@@ -149,15 +150,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 = os.path.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 = 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 +199,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
@@ -276,11 +299,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.sourceforge.net 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
@@ -321,6 +346,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