]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/UPT: Fix UNI file name issue
authorHess Chen <hesheng.chen@intel.com>
Wed, 23 Aug 2017 05:53:36 +0000 (13:53 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Thu, 24 Aug 2017 13:39:50 +0000 (21:39 +0800)
Fix the issue of creating duplicate UNI file names
Fix the issue of removing packages

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/UPT/Core/DependencyRules.py
BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
BaseTools/Source/Python/UPT/Library/String.py
BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py

index 909c584e4ec2a93eefdb6dfa71abae60eb1c2549..26c5a97da80fc16ca60eb8b7794b8fbf28093b92 100644 (file)
@@ -55,6 +55,8 @@ class DependencyRules(object):
         self.PkgsToBeDepend.extend(self.GenToBeInstalledPkgList(ToBeInstalledPkgList))\r
         \r
     def GenToBeInstalledPkgList(self, ToBeInstalledPkgList):\r
         self.PkgsToBeDepend.extend(self.GenToBeInstalledPkgList(ToBeInstalledPkgList))\r
         \r
     def GenToBeInstalledPkgList(self, ToBeInstalledPkgList):\r
+        if not ToBeInstalledPkgList:\r
+            return []\r
         RtnList = []\r
         for Dist in ToBeInstalledPkgList:\r
             for Package in Dist.PackageSurfaceArea:\r
         RtnList = []\r
         for Dist in ToBeInstalledPkgList:\r
             for Package in Dist.PackageSurfaceArea:\r
index a376f56fcfa80fc0d162e73402bc553f8b0dc187..d7eaf3ea1d12d1bd210110970114c923d58b51ef 100644 (file)
@@ -140,7 +140,9 @@ def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None):
     #\r
     FileHeader = GenHeaderCommentSection(ModuleAbstract, ModuleDescription, ModuleCopyright, ModuleLicense, False, \\r
                                          DT.TAB_COMMENT_EDK1_SPLIT)\r
     #\r
     FileHeader = GenHeaderCommentSection(ModuleAbstract, ModuleDescription, ModuleCopyright, ModuleLicense, False, \\r
                                          DT.TAB_COMMENT_EDK1_SPLIT)\r
-    GenModuleUNIEncodeFile(ModuleObject, FileHeader)\r
+    ModuleUniFile = GenModuleUNIEncodeFile(ModuleObject, FileHeader)\r
+    if ModuleUniFile:\r
+        ModuleObject.SetModuleUniFile(os.path.basename(ModuleUniFile))\r
 \r
     #\r
     # Judge whether the INF file is an AsBuild INF.\r
 \r
     #\r
     # Judge whether the INF file is an AsBuild INF.\r
@@ -310,7 +312,7 @@ def GenDefines(ModuleObject):
     # TAB_INF_DEFINES_VERSION_STRING\r
     if ModuleObject.UNIFlag:\r
         Statement = (u'%s ' % DT.TAB_INF_DEFINES_MODULE_UNI_FILE).ljust(LeftOffset) + \\r
     # TAB_INF_DEFINES_VERSION_STRING\r
     if ModuleObject.UNIFlag:\r
         Statement = (u'%s ' % DT.TAB_INF_DEFINES_MODULE_UNI_FILE).ljust(LeftOffset) + \\r
-                    u'= %s' % ModuleObject.GetBaseName() + '.uni'\r
+                    u'= %s' % ModuleObject.GetModuleUniFile()\r
         SpecialStatementList.append(Statement)\r
 \r
     # TAB_INF_DEFINES_MODULE_TYPE\r
         SpecialStatementList.append(Statement)\r
 \r
     # TAB_INF_DEFINES_MODULE_TYPE\r
index 89371dbdbf562e70a3471c3fbf36a7a6a437ae50..278073e4a379786ba26c5f1b832bec32f1fb7049 100644 (file)
@@ -969,6 +969,7 @@ def GetUniFileName(FilePath, FileName):
         pass\r
 \r
     LargestIndex = -1\r
         pass\r
 \r
     LargestIndex = -1\r
+    IndexNotFound = True\r
     for File in Files:\r
         if File.upper().startswith(FileName.upper()) and File.upper().endswith('.UNI'):\r
             Index = File.upper().replace(FileName.upper(), '').replace('.UNI', '')\r
     for File in Files:\r
         if File.upper().startswith(FileName.upper()) and File.upper().endswith('.UNI'):\r
             Index = File.upper().replace(FileName.upper(), '').replace('.UNI', '')\r
@@ -978,11 +979,12 @@ def GetUniFileName(FilePath, FileName):
                 except Exception:\r
                     Index = -1\r
             else:\r
                 except Exception:\r
                     Index = -1\r
             else:\r
+                IndexNotFound = False\r
                 Index = 0\r
             if Index > LargestIndex:\r
                 LargestIndex = Index + 1\r
 \r
                 Index = 0\r
             if Index > LargestIndex:\r
                 LargestIndex = Index + 1\r
 \r
-    if LargestIndex > -1:\r
+    if LargestIndex > -1 and not IndexNotFound:\r
         return os.path.normpath(os.path.join(FilePath, FileName + str(LargestIndex) + '.uni'))\r
     else:\r
         return os.path.normpath(os.path.join(FilePath, FileName + '.uni'))\r
         return os.path.normpath(os.path.join(FilePath, FileName + str(LargestIndex) + '.uni'))\r
     else:\r
         return os.path.normpath(os.path.join(FilePath, FileName + '.uni'))\r
index e85b8fa010ab6c727d84e0048d4ea5c4b3f671c3..4052d2883596d01971984428f491441a7fb6db7c 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to define a class object to describe a module\r
 #\r
 ## @file\r
 # This file is used to define a class object to describe a module\r
 #\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials are licensed and made available \r
 # under the terms and conditions of the BSD License which accompanies this \r
 #\r
 # This program and the accompanying materials are licensed and made available \r
 # under the terms and conditions of the BSD License which accompanies this \r
@@ -105,6 +105,7 @@ class ModuleHeaderObject(IdentificationObject, CommonHeaderObject, BinaryHeaderO
         self.PiSpecificationVersion = ''\r
         self.UefiSpecificationVersion = ''\r
         self.UNIFlag = False\r
         self.PiSpecificationVersion = ''\r
         self.UefiSpecificationVersion = ''\r
         self.UNIFlag = False\r
+        self.ModuleUniFile = ''\r
         #\r
         # SpecObject\r
         #\r
         #\r
         # SpecObject\r
         #\r
@@ -208,6 +209,11 @@ class ModuleHeaderObject(IdentificationObject, CommonHeaderObject, BinaryHeaderO
     def GetSupArchList(self):\r
         return self.SupArchList\r
 \r
     def GetSupArchList(self):\r
         return self.SupArchList\r
 \r
+    def SetModuleUniFile(self, ModuleUniFile):\r
+        self.ModuleUniFile = ModuleUniFile\r
+\r
+    def GetModuleUniFile(self):\r
+        return self.ModuleUniFile\r
 ##\r
 # SourceFileObject\r
 #\r
 ##\r
 # SourceFileObject\r
 #\r