Add Flag option for Build tool to specify the specific option when parse EDK uni...
authorlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Tue, 16 Mar 2010 08:24:57 +0000 (08:24 +0000)
committerlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Tue, 16 Mar 2010 08:24:57 +0000 (08:24 +0000)
git-svn-id: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/trunk/BaseTools@1932 c2973edb-eda0-4c78-bc6a-9341b269661f

Source/Python/AutoGen/AutoGen.py
Source/Python/build/build.py

index 4755e31..fa434e8 100755 (executable)
@@ -138,7 +138,7 @@ class WorkspaceAutoGen(AutoGen):
     #   @param  SkuId                   SKU id from command line\r
     #\r
     def _Init(self, WorkspaceDir, ActivePlatform, Target, Toolchain, ArchList, MetaFileDb,\r
-              BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=[], Fvs=[], SkuId=''):\r
+              BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=[], Fvs=[], SkuId='', UniFlag=None):\r
         self.MetaFile       = ActivePlatform.MetaFile\r
         self.WorkspaceDir   = WorkspaceDir\r
         self.Platform       = ActivePlatform\r
@@ -146,6 +146,7 @@ class WorkspaceAutoGen(AutoGen):
         self.ToolChain      = Toolchain\r
         self.ArchList       = ArchList\r
         self.SkuId          = SkuId\r
+        self.UniFlag        = UniFlag\r
 \r
         self.BuildDatabase  = MetaFileDb\r
         self.TargetTxt      = BuildConfig\r
@@ -1191,6 +1192,13 @@ class PlatformAutoGen(AutoGen):
                         BuildOptions[Tool][Attr] = Value[1:]\r
                     else:\r
                         BuildOptions[Tool][Attr] += " " + Value\r
+        if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag != None:\r
+            #\r
+            # Override UNI flag only for EDK module.\r
+            #\r
+            if 'BUILD' not in BuildOptions:\r
+                BuildOptions['BUILD'] = {}\r
+            BuildOptions['BUILD']['FLAGS'] = self.Workspace.UniFlag\r
         return BuildOptions\r
 \r
     Platform            = property(_GetPlatform)\r
index 9df4c7e..525f077 100644 (file)
@@ -704,7 +704,7 @@ class Build():
                  BuildTarget, FlashDefinition, FdList=[], FvList=[],\r
                  MakefileType="nmake", SilentMode=False, ThreadNumber=2,\r
                  SkipAutoGen=False, Reparse=False, SkuId=None, \r
-                 ReportFile=None, ReportType=None):\r
+                 ReportFile=None, ReportType=None, UniFlag=None):\r
 \r
         self.WorkspaceDir = WorkspaceDir\r
         self.Target         = Target\r
@@ -731,6 +731,7 @@ class Build():
         self.BuildDatabase  = self.Db.BuildObject\r
         self.Platform       = None\r
         self.LoadFixAddress = 0\r
+        self.UniFlag        = UniFlag\r
 \r
         # print dot charater during doing some time-consuming work\r
         self.Progress = Utils.Progressor()\r
@@ -1291,7 +1292,8 @@ class Build():
                         self.Fdf,\r
                         self.FdList,\r
                         self.FvList,\r
-                        self.SkuId\r
+                        self.SkuId,\r
+                        self.UniFlag\r
                         )\r
                 self.BuildReport.AddPlatformReport(Wa)\r
                 self.Progress.Stop("done!")\r
@@ -1358,7 +1360,8 @@ class Build():
                         self.Fdf,\r
                         self.FdList,\r
                         self.FvList,\r
-                        self.SkuId\r
+                        self.SkuId,\r
+                        self.UniFlag\r
                         )\r
                 Wa.CreateMakeFile(False)\r
                 self.Progress.Stop("done!")\r
@@ -1435,7 +1438,8 @@ class Build():
                         self.Fdf,\r
                         self.FdList,\r
                         self.FvList,\r
-                        self.SkuId\r
+                        self.SkuId,\r
+                        self.UniFlag\r
                         )\r
                 self.BuildReport.AddPlatformReport(Wa)\r
                 Wa.CreateMakeFile(False)\r
@@ -1710,6 +1714,10 @@ def MyOptionParser():
     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
+        help="Specify the specific option to parse EDK UNI file. Must be one of: [-c, -s]. -c is for EDK framework UNI file, and -s is for EDK UEFI UNI file. "\\r
+             "This option can also be specified by setting *_*_*_BUILD_FLAGS in [BuildOptions] section of platform DSC. If they are both specified, this value "\\r
+             "will override the setting in [BuildOptions] section of platform DSC.")\r
 \r
     (Opt, Args)=Parser.parse_args()\r
     return (Opt, Args)\r
@@ -1821,12 +1829,15 @@ def Main():
             if ErrorCode != 0:\r
                 EdkLogger.error("build", ErrorCode, ExtraData=ErrorInfo)\r
 \r
+        if Option.Flag != None and Option.Flag not in ['-c', '-s']:\r
+            EdkLogger.error("build", OPTION_VALUE_INVALID, "UNI flag must be one of -c or -s")\r
+\r
         MyBuild = Build(Target, Workspace, Option.PlatformFile, Option.ModuleFile,\r
                         Option.TargetArch, Option.ToolChain, Option.BuildTarget,\r
                         Option.FdfFile, Option.RomImage, Option.FvImage,\r
                         None, Option.SilentMode, Option.ThreadNumber,\r
                         Option.SkipAutoGen, Option.Reparse, Option.SkuId, \r
-                        Option.ReportFile, Option.ReportType)\r
+                        Option.ReportFile, Option.ReportType, Option.Flag)\r
         MyBuild.Launch()\r
         #MyBuild.DumpBuildData()\r
     except FatalError, X:\r