public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch V2] BaseTools: Fix bug for GUIDED tool path override by DSC [BuildOptions]
@ 2017-02-15 15:07 Yonghong Zhu
  2017-02-16  1:26 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2017-02-15 15:07 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao

Current the GUIDED tool path can't be override to the different path in
the [BuildOptions] of DSC file. This patch fix the bug.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=283
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 24 ++++++++---
 BaseTools/Source/Python/GenFds/GenFds.py   | 66 ++++++++++++++++++++++--------
 2 files changed, 68 insertions(+), 22 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index c35f0b2..06e674a 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1716,11 +1716,14 @@ class PlatformAutoGen(AutoGen):
                     if Tool in self.BuildOption and Attr in self.BuildOption[Tool]:
                         # check if override is indicated
                         if self.BuildOption[Tool][Attr].startswith('='):
                             Value = self.BuildOption[Tool][Attr][1:]
                         else:
-                            Value += " " + self.BuildOption[Tool][Attr]
+                            if Attr != 'PATH':
+                                Value += " " + self.BuildOption[Tool][Attr]
+                            else:
+                                Value = self.BuildOption[Tool][Attr]
 
                     if Attr == "PATH":
                         # Don't put MAKE definition in the file
                         if Tool == "MAKE":
                             MakePath = Value
@@ -2379,12 +2382,15 @@ class PlatformAutoGen(AutoGen):
                         if Tool not in BuildOptions:
                             BuildOptions[Tool] = {}
                         if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or Options[Key].startswith('='):
                             BuildOptions[Tool][Attr] = Options[Key]
                         else:
-                            # append options for the same tool
-                            BuildOptions[Tool][Attr] += " " + Options[Key]
+                            # append options for the same tool except PATH
+                            if Attr != 'PATH':
+                                BuildOptions[Tool][Attr] += " " + Options[Key]
+                            else:
+                                BuildOptions[Tool][Attr] = Options[Key]
         # Build Option Family has been checked, which need't to be checked again for family.
         if FamilyMatch or FamilyIsNull:
             return BuildOptions
 
         for Key in Options:
@@ -2411,12 +2417,15 @@ class PlatformAutoGen(AutoGen):
                         if Tool not in BuildOptions:
                             BuildOptions[Tool] = {}
                         if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or Options[Key].startswith('='):
                             BuildOptions[Tool][Attr] = Options[Key]
                         else:
-                            # append options for the same tool
-                            BuildOptions[Tool][Attr] += " " + Options[Key]
+                            # append options for the same tool except PATH
+                            if Attr != 'PATH':
+                                BuildOptions[Tool][Attr] += " " + Options[Key]
+                            else:
+                                BuildOptions[Tool][Attr] = Options[Key]
         return BuildOptions
 
     ## Append build options in platform to a module
     #
     #   @param  Module  The module to which the build options will be appened
@@ -2471,11 +2480,14 @@ class PlatformAutoGen(AutoGen):
                         ToolPath = Value[1:]
                         ToolPath = mws.handleWsMacro(ToolPath)
                         BuildOptions[Tool][Attr] = ToolPath
                     else:
                         Value = mws.handleWsMacro(Value)
-                        BuildOptions[Tool][Attr] += " " + Value
+                        if Attr != 'PATH':
+                            BuildOptions[Tool][Attr] += " " + Value
+                        else:
+                            BuildOptions[Tool][Attr] = Value
         if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag != None:
             #
             # Override UNI flag only for EDK module.
             #
             if 'BUILD' not in BuildOptions:
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index c2e9418..a8a68da 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -1,9 +1,9 @@
 ## @file
 # generate flash image
 #
-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 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 distribution.  The full text of the license may be found at
 #  http://opensource.org/licenses/bsd-license.php
@@ -28,11 +28,11 @@ from Workspace.BuildClassObject import ModuleBuildClassObject
 import RuleComplexFile
 from EfiSection import EfiSection
 import StringIO
 import Common.TargetTxtClassObject as TargetTxtClassObject
 import Common.ToolDefClassObject as ToolDefClassObject
-import Common.DataType
+from Common.DataType import *
 import Common.GlobalData as GlobalData
 from Common import EdkLogger
 from Common.String import *
 from Common.Misc import DirCache, PathClass
 from Common.Misc import SaveFileOnChange
@@ -43,11 +43,11 @@ from Common.BuildVersion import gBUILD_VERSION
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 
 ## Version and Copyright
 versionNumber = "1.0" + ' ' + gBUILD_VERSION
 __version__ = "%prog Version " + versionNumber
-__copyright__ = "Copyright (c) 2007 - 2016, Intel Corporation  All rights reserved."
+__copyright__ = "Copyright (c) 2007 - 2017, Intel Corporation  All rights reserved."
 
 ## Tool entrance method
 #
 # This method mainly dispatch specific methods per the command line options.
 # If no error found, return zero value so the caller of this tool can know
@@ -422,15 +422,15 @@ def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Val
 #  @param  KeyStringList    Filter for inputs of section generation
 #  @param  CurrentArchList  Arch list
 #  @param  NameGuid         The Guid name
 #
 def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
+    ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase
     # if user not specify filter, try to deduce it from global data.
     if KeyStringList == None or KeyStringList == []:
         Target = GenFdsGlobalVariable.TargetName
         ToolChain = GenFdsGlobalVariable.ToolChainTag
-        ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase
         if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:
             EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)
         KeyStringList = [Target + '_' + ToolChain + '_' + CurrentArchList[0]]
         for Arch in CurrentArchList:
             if Target + '_' + ToolChain + '_' + Arch not in KeyStringList:
@@ -441,37 +441,71 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
             return GenFdsGlobalVariable.GuidToolDefinition[NameGuid]
 
     ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary
     ToolPathTmp = None
     ToolOption = None
+    ToolPathKey = None
+    ToolOptionKey = None
+    KeyList = None
     for ToolDef in ToolDefinition.items():
         if NameGuid == ToolDef[1]:
             KeyList = ToolDef[0].split('_')
             Key = KeyList[0] + \
                   '_' + \
                   KeyList[1] + \
                   '_' + \
                   KeyList[2]
             if Key in KeyStringList and KeyList[4] == 'GUID':
-
-                ToolPath = ToolDefinition.get(Key + \
-                                               '_' + \
-                                               KeyList[3] + \
-                                               '_' + \
-                                               'PATH')
-
-                ToolOption = ToolDefinition.get(Key + \
-                                                '_' + \
-                                                KeyList[3] + \
-                                                '_' + \
-                                                'FLAGS')
+                ToolPathKey   = Key + '_' + KeyList[3] + '_PATH'
+                ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
+                ToolPath = ToolDefinition.get(ToolPathKey)
+                ToolOption = ToolDefinition.get(ToolOptionKey)
                 if ToolPathTmp == None:
                     ToolPathTmp = ToolPath
                 else:
                     if ToolPathTmp != ToolPath:
                         EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))
 
+    BuildOption = {}
+    for Arch in CurrentArchList:
+        Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+        # key is (ToolChainFamily, ToolChain, CodeBase)
+        for item in Platform.BuildOptions:
+            if '_PATH' in item[1] or '_FLAGS' in item[1] or '_GUID' in item[1]:
+                if not item[0] or (item[0] and GenFdsGlobalVariable.ToolChainFamily== item[0]):
+                    if item[1] not in BuildOption:
+                        BuildOption[item[1]] = Platform.BuildOptions[item]
+        if BuildOption:
+            ToolList = [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG, TAB_TOD_DEFINES_TARGET_ARCH]
+            for Index in range(2, -1, -1):
+                for Key in dict(BuildOption):
+                    List = Key.split('_')
+                    if List[Index] == '*':
+                        for String in ToolDb[ToolList[Index]]:
+                            if String in [Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]:
+                                List[Index] = String
+                                NewKey = '%s_%s_%s_%s_%s' % tuple(List)
+                                if NewKey not in BuildOption:
+                                    BuildOption[NewKey] = BuildOption[Key]
+                                    continue
+                                del BuildOption[Key]
+                    elif List[Index] not in ToolDb[ToolList[Index]]:
+                        del BuildOption[Key]
+    if BuildOption:
+        if not KeyList:
+            for Op in BuildOption:
+                if NameGuid == BuildOption[Op]:
+                    KeyList = Op.split('_')
+                    Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2]
+                    if Key in KeyStringList and KeyList[4] == 'GUID':
+                        ToolPathKey   = Key + '_' + KeyList[3] + '_PATH'
+                        ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
+        if ToolPathKey in BuildOption.keys():
+            ToolPathTmp = BuildOption.get(ToolPathKey)
+        if ToolOptionKey in BuildOption.keys():
+            ToolOption = BuildOption.get(ToolOptionKey)
+
     GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)
     return ToolPathTmp, ToolOption
 
 ## Parse command line options
 #
-- 
2.6.1.windows.1



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

end of thread, other threads:[~2017-02-16  1:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-15 15:07 [Patch V2] BaseTools: Fix bug for GUIDED tool path override by DSC [BuildOptions] Yonghong Zhu
2017-02-16  1:26 ` Gao, Liming

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