+ def PerformAutoGen(self,BuildTarget,ToolChain):\r
+ WorkspaceAutoGenTime = time.time()\r
+ Wa = WorkspaceAutoGen(\r
+ self.WorkspaceDir,\r
+ self.PlatformFile,\r
+ BuildTarget,\r
+ ToolChain,\r
+ self.ArchList,\r
+ self.BuildDatabase,\r
+ self.TargetTxt,\r
+ self.ToolDef,\r
+ self.Fdf,\r
+ self.FdList,\r
+ self.FvList,\r
+ self.CapList,\r
+ self.SkuId,\r
+ self.UniFlag,\r
+ self.Progress\r
+ )\r
+ self.Fdf = Wa.FdfFile\r
+ self.LoadFixAddress = Wa.Platform.LoadFixAddress\r
+ self.BuildReport.AddPlatformReport(Wa)\r
+ Wa.CreateMakeFile(False)\r
+\r
+ # Add ffs build to makefile\r
+ CmdListDict = {}\r
+ if GlobalData.gEnableGenfdsMultiThread and self.Fdf:\r
+ CmdListDict = self._GenFfsCmd(Wa.ArchList)\r
+\r
+ self.AutoGenTime += int(round((time.time() - WorkspaceAutoGenTime)))\r
+ BuildModules = []\r
+ for Arch in Wa.ArchList:\r
+ PcdMaList = []\r
+ AutoGenStart = time.time()\r
+ GlobalData.gGlobalDefines['ARCH'] = Arch\r
+ Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch)\r
+ if Pa is None:\r
+ continue\r
+ ModuleList = []\r
+ for Inf in Pa.Platform.Modules:\r
+ ModuleList.append(Inf)\r
+ # Add the INF only list in FDF\r
+ if GlobalData.gFdfParser is not None:\r
+ for InfName in GlobalData.gFdfParser.Profile.InfList:\r
+ Inf = PathClass(NormPath(InfName), self.WorkspaceDir, Arch)\r
+ if Inf in Pa.Platform.Modules:\r
+ continue\r
+ ModuleList.append(Inf)\r
+ Pa.DataPipe.DataContainer = {"FfsCommand":CmdListDict}\r
+ Pa.DataPipe.DataContainer = {"Workspace_timestamp": Wa._SrcTimeStamp}\r
+ Pa.DataPipe.DataContainer = {"CommandTarget": self.Target}\r
+ Pa.CreateLibModuelDirs()\r
+ Pa.DataPipe.DataContainer = {"LibraryBuildDirectoryList":Pa.LibraryBuildDirectoryList}\r
+ Pa.DataPipe.DataContainer = {"ModuleBuildDirectoryList":Pa.ModuleBuildDirectoryList}\r
+ Pa.DataPipe.DataContainer = {"FdsCommandDict": Wa.GenFdsCommandDict}\r
+ # Prepare the cache share data for multiprocessing\r
+ Pa.DataPipe.DataContainer = {"gPlatformHashFile":GlobalData.gPlatformHashFile}\r
+ ModuleCodaFile = {}\r
+ for ma in Pa.ModuleAutoGenList:\r
+ ModuleCodaFile[(ma.MetaFile.File,ma.MetaFile.Root,ma.Arch,ma.MetaFile.Path)] = [item.Target for item in ma.CodaTargetList]\r
+ Pa.DataPipe.DataContainer = {"ModuleCodaFile":ModuleCodaFile}\r
+ # ModuleList contains all driver modules only\r
+ for Module in ModuleList:\r
+ # Get ModuleAutoGen object to generate C code file and makefile\r
+ Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile,Pa.DataPipe)\r
+ if Ma is None:\r
+ continue\r
+ if Ma.PcdIsDriver:\r
+ Ma.PlatformInfo = Pa\r
+ Ma.Workspace = Wa\r
+ PcdMaList.append(Ma)\r
+ self.AllDrivers.add(Ma)\r
+ self.AllModules.add(Ma)\r
+\r
+ mqueue = mp.Queue()\r
+ cqueue = mp.Queue()\r
+ for m in Pa.GetAllModuleInfo:\r
+ mqueue.put(m)\r
+ module_file,module_root,module_path,module_basename,\\r
+ module_originalpath,module_arch,IsLib = m\r
+ Ma = ModuleAutoGen(Wa, PathClass(module_path, Wa), BuildTarget,\\r
+ ToolChain, Arch, self.PlatformFile,Pa.DataPipe)\r
+ self.AllModules.add(Ma)\r
+ data_pipe_file = os.path.join(Pa.BuildDir, "GlobalVar_%s_%s.bin" % (str(Pa.Guid),Pa.Arch))\r
+ Pa.DataPipe.dump(data_pipe_file)\r
+\r
+ autogen_rt, errorcode = self.StartAutoGen(mqueue, Pa.DataPipe, self.SkipAutoGen, PcdMaList, cqueue)\r
+\r
+ if not autogen_rt:\r
+ self.AutoGenMgr.TerminateWorkers()\r
+ self.AutoGenMgr.join(1)\r
+ raise FatalError(errorcode)\r
+\r
+ if GlobalData.gUseHashCache:\r
+ for item in GlobalData.gModuleAllCacheStatus:\r
+ (MetaFilePath, Arch, CacheStr, Status) = item\r
+ Ma = ModuleAutoGen(Wa, PathClass(MetaFilePath, Wa), BuildTarget,\\r
+ ToolChain, Arch, self.PlatformFile,Pa.DataPipe)\r
+ if CacheStr == "PreMakeCache" and Status == False:\r
+ self.PreMakeCacheMiss.add(Ma)\r
+ if CacheStr == "PreMakeCache" and Status == True:\r
+ self.PreMakeCacheHit.add(Ma)\r
+ GlobalData.gModuleCacheHit.add(Ma)\r
+ if CacheStr == "MakeCache" and Status == False:\r
+ self.MakeCacheMiss.add(Ma)\r
+ if CacheStr == "MakeCache" and Status == True:\r
+ self.MakeCacheHit.add(Ma)\r
+ GlobalData.gModuleCacheHit.add(Ma)\r
+ self.AutoGenTime += int(round((time.time() - AutoGenStart)))\r
+ AutoGenIdFile = os.path.join(GlobalData.gConfDirectory,".AutoGenIdFile.txt")\r
+ with open(AutoGenIdFile,"w") as fw:\r
+ fw.write("Arch=%s\n" % "|".join((Wa.ArchList)))\r
+ fw.write("BuildDir=%s\n" % Wa.BuildDir)\r
+ fw.write("PlatformGuid=%s\n" % str(Wa.AutoGenObjectList[0].Guid))\r
+\r
+ if GlobalData.gBinCacheSource:\r
+ BuildModules.extend(self.MakeCacheMiss)\r
+ elif GlobalData.gUseHashCache and not GlobalData.gBinCacheDest:\r
+ BuildModules.extend(self.PreMakeCacheMiss)\r
+ else:\r
+ BuildModules.extend(self.AllDrivers)\r
+\r
+ self.Progress.Stop("done!")\r
+ return Wa, BuildModules\r
+\r