Fixed multi-thread build issue in Linux due to scheduler started more than once
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Sun, 4 May 2008 08:59:12 +0000 (08:59 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Sun, 4 May 2008 08:59:12 +0000 (08:59 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1191 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/build/build.py

index b2870f8..4b8b40c 100644 (file)
@@ -79,7 +79,7 @@ def IsToolInPath(tool):
 def CheckEnvVariable():\r
     # check WORKSPACE\r
     if "WORKSPACE" not in os.environ:\r
-        EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", \r
+        EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",\r
                         ExtraData="WORKSPACE")\r
 \r
     WorkspaceDir = os.path.normpath(os.environ["WORKSPACE"])\r
@@ -89,7 +89,7 @@ def CheckEnvVariable():
 \r
     #\r
     # Check EFI_SOURCE (R8 build convention). EDK_SOURCE will always point to ECP\r
-    # \r
+    #\r
     os.environ["EDK_SOURCE"] = os.path.join(WorkspaceDir, GlobalData.gEdkCompatibilityPkg)\r
     if "EFI_SOURCE" not in os.environ:\r
         os.environ["EFI_SOURCE"] = os.environ["EDK_SOURCE"]\r
@@ -103,22 +103,22 @@ def CheckEnvVariable():
 \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
+        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
+        EdkLogger.error("build", PARAMETER_INVALID, "EDK_SOURCE is not under WORKSPACE",\r
                         ExtraData="WORKSPACE = %s\n    EDK_SOURCE = %s" % (WorkspaceDir, EdkSourceDir))\r
     EfiSourceDir = EfiSourceDir[len(WorkspaceDir)+1:]\r
     EdkSourceDir = EdkSourceDir[len(WorkspaceDir)+1:]\r
 \r
     # check EDK_TOOLS_PATH\r
     if "EDK_TOOLS_PATH" not in os.environ:\r
-        EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", \r
+        EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",\r
                         ExtraData="EDK_TOOLS_PATH")\r
 \r
     # check PATH\r
     if "PATH" not in os.environ:\r
-        EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", \r
+        EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",\r
                         ExtraData="PATH")\r
 \r
     PathString = os.environ["PATH"]\r
@@ -385,6 +385,9 @@ class BuildTask:
         SchedulerThread.setName("Build-Task-Scheduler")\r
         SchedulerThread.setDaemon(False)\r
         SchedulerThread.start()\r
+        # wait for the scheduler to be started, especially useful in Linux\r
+        while not BuildTask.IsOnGoing():\r
+            time.sleep(0.01)\r
 \r
     ## Scheduler method\r
     #\r
@@ -631,8 +634,8 @@ class Build():
     #   @param  SpawnMode           Indicate multi-thread build mode\r
     #   @param  ThreadNumber        The maximum number of thread if in multi-thread build mode\r
     #\r
-    def __init__(self, Target, WorkspaceDir, Platform, Module, Arch, ToolChain, \r
-                 BuildTarget, FlashDefinition, FdList=[], FvList=[], \r
+    def __init__(self, Target, WorkspaceDir, Platform, Module, Arch, ToolChain,\r
+                 BuildTarget, FlashDefinition, FdList=[], FvList=[],\r
                  MakefileType="nmake", SpawnMode=False, ThreadNumber=2,\r
                  SkipAutoGen=False, Reparse=False, SkuId=None):\r
 \r
@@ -760,7 +763,7 @@ class Build():
                 FileList = glob.glob(os.path.normpath(os.path.join(WorkingDirectory, '*.dsc')))\r
                 FileNum = len(FileList)\r
                 if FileNum >= 2:\r
-                    EdkLogger.error("build", OPTION_MISSING, \r
+                    EdkLogger.error("build", OPTION_MISSING,\r
                                     ExtraData="There are %d DSC files in %s. Use '-p' to specify one.\n" % (FileNum, WorkingDirectory))\r
                 elif FileNum == 1:\r
                     self.PlatformFile = NormFile(FileList[0], self.WorkspaceDir)\r
@@ -857,7 +860,7 @@ class Build():
                 self.Progress.Stop("done!")\r
             if Target == "genc":\r
                 return True\r
-    \r
+\r
             if not self.SkipAutoGen or Target == 'genmake':\r
                 self.Progress.Start("Generating makefile")\r
                 AutoGenObject.CreateMakeFile(CreateDepsMakeFile)\r
@@ -920,7 +923,7 @@ class Build():
                         self.FdList,\r
                         self.FvList,\r
                         self.SkuId\r
-                        )                \r
+                        )\r
                 Wa.CreateMakeFile(False)\r
                 self.Progress.Stop("done!")\r
                 MaList = []\r
@@ -955,7 +958,7 @@ class Build():
                         self.FdList,\r
                         self.FvList,\r
                         self.SkuId\r
-                        )                \r
+                        )\r
                 Wa.CreateMakeFile(False)\r
 \r
                 # multi-thread exit flag\r
@@ -1032,7 +1035,7 @@ class Build():
                                 'FV'\r
                                 )\r
                     if not os.path.exists(FvDir):\r
-                        continue \r
+                        continue\r
                     # Build up the list of supported architectures for this build\r
                     prefix = '%s_%s_%s_' % (BuildTarget, ToolChain, Arch)\r
 \r
@@ -1108,7 +1111,7 @@ class Build():
             Utils.gFileTimeStampCache = Utils.DataRestore(FilePath)\r
             if Utils.gFileTimeStampCache == None:\r
                 Utils.gFileTimeStampCache = {}\r
-        \r
+\r
         FilePath = os.path.join(self.WorkspaceDir, gBuildCacheDir, "gDependencyDatabase")\r
         if Utils.gDependencyDatabase == {} and os.path.isfile(FilePath):\r
             Utils.gDependencyDatabase = Utils.DataRestore(FilePath)\r
@@ -1228,11 +1231,11 @@ def Main():
                             ExtraData="Please select one of: %s" %(' '.join(gSupportedTarget)))\r
         else:\r
             Target = Target[0].lower()\r
-    \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
-    \r
+\r
         # GlobalData.gGlobalDefines = ParseDefines(Option.Defines)\r
         #\r
         # Check environment variable: EDK_TOOLS_PATH, WORKSPACE, PATH\r
@@ -1257,10 +1260,10 @@ def Main():
         if Option.FdfFile != None:\r
             Option.FdfFile = NormFile(Option.FdfFile, Workspace)\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
-                        Option.MakefileType, Option.SpawnMode, Option.ThreadNumber, \r
+        MyBuild = Build(Target, Workspace, Option.PlatformFile, Option.ModuleFile,\r
+                        Option.TargetArch, Option.ToolChain, Option.BuildTarget,\r
+                        Option.FdfFile, Option.RomImage, Option.FvImage,\r
+                        Option.MakefileType, Option.SpawnMode, Option.ThreadNumber,\r
                         Option.SkipAutoGen, Option.Reparse, Option.SkuId)\r
         MyBuild.Launch()\r
         MyBuild.DumpBuildData()\r