]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/build/build.py
License header updated to match correct format.
[mirror_edk2.git] / BaseTools / Source / Python / build / build.py
index 2f8bfb42b123d7fa0badf9ff04b7b03358825704..a5bb70d45645b146184508ae8831881d783d2029 100644 (file)
@@ -57,9 +57,8 @@ __copyright__ = "Copyright (c) 2007 - 2014, Intel Corporation  All rights reserv
 gSupportedTarget = ['all', 'genc', 'genmake', 'modules', 'libraries', 'fds', 'clean', 'cleanall', 'cleanlib', 'run']\r
 \r
 ## build configuration file\r
-gBuildConfiguration = "Conf/target.txt"\r
-gBuildCacheDir = "Conf/.cache"\r
-gToolsDefinition = "Conf/tools_def.txt"\r
+gBuildConfiguration = "target.txt"\r
+gToolsDefinition = "tools_def.txt"\r
 \r
 TemporaryTablePattern = re.compile(r'^_\d+_\d+_[a-fA-F0-9]+$')\r
 TmpTableDict = {}\r
@@ -630,7 +629,8 @@ class BuildTask:
     #\r
     def AddDependency(self, Dependency):\r
         for Dep in Dependency:\r
-            self.DependencyList.append(BuildTask.New(Dep))    # BuildTask list\r
+            if not Dep.BuildObject.IsBinaryModule:\r
+                self.DependencyList.append(BuildTask.New(Dep))    # BuildTask list\r
 \r
     ## The thread wrapper of LaunchCommand function\r
     #\r
@@ -732,18 +732,34 @@ class Build():
         self.SkipAutoGen    = BuildOptions.SkipAutoGen\r
         self.Reparse        = BuildOptions.Reparse\r
         self.SkuId          = BuildOptions.SkuId\r
+        self.ConfDirectory = BuildOptions.ConfDirectory\r
         self.SpawnMode      = True\r
         self.BuildReport    = BuildReport(BuildOptions.ReportFile, BuildOptions.ReportType)\r
         self.TargetTxt      = TargetTxtClassObject()\r
         self.ToolDef        = ToolDefClassObject()\r
         #Set global flag for build mode\r
         GlobalData.gIgnoreSource = BuildOptions.IgnoreSources\r
+\r
+        if self.ConfDirectory:\r
+            # Get alternate Conf location, if it is absolute, then just use the absolute directory name\r
+            ConfDirectoryPath = os.path.normpath(self.ConfDirectory)\r
+\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(self.WorkspaceDir, ConfDirectoryPath)\r
+        else:\r
+            # Get standard WORKSPACE/Conf use the absolute path to the WORKSPACE/Conf\r
+            ConfDirectoryPath = os.path.join(self.WorkspaceDir, 'Conf')\r
+        GlobalData.gConfDirectory = ConfDirectoryPath\r
+        GlobalData.gDatabasePath = os.path.normpath(os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath))\r
+\r
         if BuildOptions.DisableCache:\r
             self.Db         = WorkspaceDatabase(":memory:")\r
         else:\r
-            self.Db         = WorkspaceDatabase(None, self.Reparse)\r
-        self.BuildDatabase  = self.Db.BuildObject\r
-        self.Platform       = None\r
+            self.Db = WorkspaceDatabase(GlobalData.gDatabasePath, self.Reparse)\r
+        self.BuildDatabase = self.Db.BuildObject\r
+        self.Platform = None\r
         self.LoadFixAddress = 0\r
         self.UniFlag        = BuildOptions.Flag\r
         self.BuildModules = []\r
@@ -772,14 +788,14 @@ class Build():
         #\r
         # Check target.txt and tools_def.txt and Init them\r
         #\r
-        BuildConfigurationFile = os.path.normpath(os.path.join(self.WorkspaceDir, gBuildConfiguration))\r
+        BuildConfigurationFile = os.path.normpath(os.path.join(GlobalData.gConfDirectory, gBuildConfiguration))\r
         if os.path.isfile(BuildConfigurationFile) == True:\r
             StatusCode = self.TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)\r
 \r
             ToolDefinitionFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
             if ToolDefinitionFile == '':\r
                 ToolDefinitionFile = gToolsDefinition\r
-            ToolDefinitionFile = os.path.normpath(os.path.join(self.WorkspaceDir, ToolDefinitionFile))\r
+                ToolDefinitionFile = os.path.normpath(os.path.join(self.WorkspaceDir, 'Conf', ToolDefinitionFile))\r
             if os.path.isfile(ToolDefinitionFile) == True:\r
                 StatusCode = self.ToolDef.LoadToolDefFile(ToolDefinitionFile)\r
             else:\r
@@ -1079,7 +1095,7 @@ class Build():
                 # First should close DB.\r
                 #\r
                 self.Db.Close()\r
-                RemoveDirectory(gBuildCacheDir, True)\r
+                RemoveDirectory(os.path.dirname(GlobalData.gDatabasePath), True)\r
             except WindowsError, X:\r
                 EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X))\r
         return True\r
@@ -1804,19 +1820,19 @@ class Build():
         EdkLogger.SetLevel(OldLogLevel)\r
 \r
     def DumpBuildData(self):\r
-        CacheDirectory = os.path.join(self.WorkspaceDir, gBuildCacheDir)\r
+        CacheDirectory = os.path.dirname(GlobalData.gDatabasePath)\r
         Utils.CreateDirectory(CacheDirectory)\r
         Utils.DataDump(Utils.gFileTimeStampCache, os.path.join(CacheDirectory, "gFileTimeStampCache"))\r
         Utils.DataDump(Utils.gDependencyDatabase, os.path.join(CacheDirectory, "gDependencyDatabase"))\r
 \r
     def RestoreBuildData(self):\r
-        FilePath = os.path.join(self.WorkspaceDir, gBuildCacheDir, "gFileTimeStampCache")\r
+        FilePath = os.path.join(os.path.dirname(GlobalData.gDatabasePath), "gFileTimeStampCache")\r
         if Utils.gFileTimeStampCache == {} and os.path.isfile(FilePath):\r
             Utils.gFileTimeStampCache = Utils.DataRestore(FilePath)\r
             if Utils.gFileTimeStampCache == None:\r
                 Utils.gFileTimeStampCache = {}\r
 \r
-        FilePath = os.path.join(self.WorkspaceDir, gBuildCacheDir, "gDependencyDatabase")\r
+        FilePath = os.path.join(os.path.dirname(GlobalData.gDatabasePath), "gDependencyDatabase")\r
         if Utils.gDependencyDatabase == {} and os.path.isfile(FilePath):\r
             Utils.gDependencyDatabase = Utils.DataRestore(FilePath)\r
             if Utils.gDependencyDatabase == None:\r
@@ -1905,6 +1921,8 @@ def MyOptionParser():
              "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
     Parser.add_option("-N", "--no-cache", action="store_true", dest="DisableCache", default=False, help="Disable build cache mechanism")\r
+    Parser.add_option("--conf", action="store", type="string", dest="ConfDirectory", help="Specify the customized Conf directory.")\r
+    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
@@ -2064,13 +2082,14 @@ def Main():
                     "\nbuild",\r
                     CODE_ERROR,\r
                     "Unknown fatal error when processing [%s]" % MetaFile,\r
-                    ExtraData="\n(Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!)\n",\r
+                    ExtraData="\n(Please send email to edk2-devel@lists.sourceforge.net 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
         ReturnCode = CODE_ERROR\r
     finally:\r
         Utils.Progressor.Abort()\r
+        Utils.ClearDuplicatedInf()\r
 \r
     if ReturnCode == 0:\r
         Conclusion = "Done"\r