+ def GenModuleHash(self):\r
+ if self.Arch not in GlobalData.gModuleHash:\r
+ GlobalData.gModuleHash[self.Arch] = {}\r
+ m = hashlib.md5()\r
+ # Add Platform level hash\r
+ m.update(GlobalData.gPlatformHash)\r
+ # Add Package level hash\r
+ if self.DependentPackageList:\r
+ for Pkg in self.DependentPackageList:\r
+ if Pkg.PackageName in GlobalData.gPackageHash[self.Arch]:\r
+ m.update(GlobalData.gPackageHash[self.Arch][Pkg.PackageName])\r
+\r
+ # Add Library hash\r
+ if self.LibraryAutoGenList:\r
+ for Lib in self.LibraryAutoGenList:\r
+ if Lib.Name not in GlobalData.gModuleHash[self.Arch]:\r
+ Lib.GenModuleHash()\r
+ m.update(GlobalData.gModuleHash[self.Arch][Lib.Name])\r
+\r
+ # Add Module self\r
+ f = open(str(self.MetaFile), 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+ # Add Module's source files\r
+ if self.SourceFileList:\r
+ for File in self.SourceFileList:\r
+ f = open(str(File), 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+\r
+ ModuleHashFile = path.join(self.BuildDir, self.Name + ".hash")\r
+ if self.Name not in GlobalData.gModuleHash[self.Arch]:\r
+ GlobalData.gModuleHash[self.Arch][self.Name] = m.hexdigest()\r
+ if GlobalData.gBinCacheSource:\r
+ CacheValid = self.AttemptModuleCacheCopy()\r
+ if CacheValid:\r
+ return False\r
+ return SaveFileOnChange(ModuleHashFile, m.hexdigest(), True)\r
+\r
+ ## Decide whether we can skip the ModuleAutoGen process\r
+ def CanSkipbyHash(self):\r
+ if GlobalData.gUseHashCache:\r
+ return not self.GenModuleHash()\r
+\r
+ ## Decide whether we can skip the ModuleAutoGen process\r
+ # If any source file is newer than the module than we cannot skip\r
+ #\r
+ def CanSkip(self):\r
+ if not os.path.exists(self.GetTimeStampPath()):\r
+ return False\r
+ #last creation time of the module\r
+ DstTimeStamp = os.stat(self.GetTimeStampPath())[8]\r
+\r
+ SrcTimeStamp = self.Workspace._SrcTimeStamp\r
+ if SrcTimeStamp > DstTimeStamp:\r
+ return False\r
+\r
+ with open(self.GetTimeStampPath(),'r') as f:\r
+ for source in f:\r
+ source = source.rstrip('\n')\r
+ if not os.path.exists(source):\r
+ return False\r
+ if source not in ModuleAutoGen.TimeDict :\r
+ ModuleAutoGen.TimeDict[source] = os.stat(source)[8]\r
+ if ModuleAutoGen.TimeDict[source] > DstTimeStamp:\r
+ return False\r
+ return True\r
+\r
+ def GetTimeStampPath(self):\r
+ if self._TimeStampPath == None:\r
+ self._TimeStampPath = os.path.join(self.MakeFileDir, 'AutoGenTimeStamp')\r
+ return self._TimeStampPath\r
+ def CreateTimeStamp(self, Makefile):\r
+\r
+ FileSet = set()\r
+\r
+ FileSet.add (self.MetaFile.Path)\r
+\r
+ for SourceFile in self.Module.Sources:\r
+ FileSet.add (SourceFile.Path)\r
+\r
+ for Lib in self.DependentLibraryList:\r
+ FileSet.add (Lib.MetaFile.Path)\r
+\r
+ for f in self.AutoGenDepSet:\r
+ FileSet.add (f.Path)\r
+\r
+ if os.path.exists (self.GetTimeStampPath()):\r
+ os.remove (self.GetTimeStampPath())\r
+ with open(self.GetTimeStampPath(), 'w+') as file:\r
+ for f in FileSet:\r
+ print >> file, f\r
+\r