public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch] BaseTools/UPT: Fix UNI file name issue
@ 2017-08-23  5:53 hesschen
  2017-08-24 13:37 ` Zhu, Yonghong
  0 siblings, 1 reply; 2+ messages in thread
From: hesschen @ 2017-08-23  5:53 UTC (permalink / raw)
  To: edk2-devel

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: hesschen <hesheng.chen@intel.com>
---
 BaseTools/Source/Python/UPT/Core/DependencyRules.py    | 2 ++
 BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py  | 6 ++++--
 BaseTools/Source/Python/UPT/Library/String.py          | 4 +++-
 BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py | 8 +++++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] BaseTools/UPT: Fix UNI file name issue
  2017-08-23  5:53 [patch] BaseTools/UPT: Fix UNI file name issue hesschen
@ 2017-08-24 13:37 ` Zhu, Yonghong
  0 siblings, 0 replies; 2+ messages in thread
From: Zhu, Yonghong @ 2017-08-24 13:37 UTC (permalink / raw)
  To: Chen, Hesheng, edk2-devel@lists.01.org

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 
Best Regards,
Zhu Yonghong


-----Original Message-----
From: Chen, Hesheng 
Sent: Wednesday, August 23, 2017 1:54 PM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [patch] BaseTools/UPT: Fix UNI file name issue

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: hesschen <hesheng.chen@intel.com>
---
 BaseTools/Source/Python/UPT/Core/DependencyRules.py    | 2 ++
 BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py  | 6 ++++--
 BaseTools/Source/Python/UPT/Library/String.py          | 4 +++-
 BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py | 8 +++++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-24 13:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-23  5:53 [patch] BaseTools/UPT: Fix UNI file name issue hesschen
2017-08-24 13:37 ` Zhu, Yonghong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox