[edk2-devel] [PATCH V5] BaseTools:GuidedSectionTools.txt is not generated correctly

Fan, ZhijuX posted 1 patch 4 years ago
Failed in applying to current master (apply log)
There is a newer version of this series
BaseTools/Source/Python/AutoGen/PlatformAutoGen.py |  3 ++-
BaseTools/Source/Python/build/build.py             | 13 +++----------
2 files changed, 5 insertions(+), 11 deletions(-)
[edk2-devel] [PATCH V5] BaseTools:GuidedSectionTools.txt is not generated correctly
Posted by Fan, ZhijuX 4 years ago
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2538

For LzmaCompress or BrotliCompress, the platform may use the different
options and add their batch file, such as LzmaCompressPlatform.
Then, specify it in platform.dsc [BuildOptions] to override the default
one in tools_def.txt.

*_*_*_LZMA_PATH = LzmaCompressPlatform

This override tool will be used. But, its name is not specified in the
generated GuidedSectionTools.txt.

Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
---

A judgment condition was removed
if self.Workspace.ToolDef.ToolsDefTxtDictionary.get(Def):

 BaseTools/Source/Python/AutoGen/PlatformAutoGen.py |  3 ++-
 BaseTools/Source/Python/build/build.py             | 13 +++----------
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
index d32178b00c93..af66c48c7d6a 100644
--- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
@@ -866,7 +866,8 @@ class PlatformAutoGen(AutoGen):
                             Value += " " + self._BuildOptionWithToolDef(RetVal)[Tool][Attr]
                         else:
                             Value = self._BuildOptionWithToolDef(RetVal)[Tool][Attr]
-
+                            Def = '_'.join([self.BuildTarget, self.ToolChain, self.Arch, Tool, Attr])
+                            self.Workspace.ToolDef.ToolsDefTxtDictionary[Def] = Value
                 if Attr == "PATH":
                     # Don't put MAKE definition in the file
                     if Tool != "MAKE":
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index d841fefdc502..6dbe05f0a93e 100755
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -2363,16 +2363,9 @@ class Build():
         if os.path.exists(tool):
             return os.path.realpath(tool)
         else:
-            # We need to search for the tool using the
-            # PATH environment variable.
-            for dirInPath in os.environ['PATH'].split(os.pathsep):
-                foundPath = os.path.join(dirInPath, tool)
-                if os.path.exists(foundPath):
-                    return os.path.realpath(foundPath)
-
-        # If the tool was not found in the path then we just return
-        # the input tool.
-        return tool
+            # If the tool was not found in the path then we just return
+            # the input tool.
+            return tool
 
     ## Launch the module or platform build
     #
-- 
2.14.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56377): https://edk2.groups.io/g/devel/message/56377
Mute This Topic: https://groups.io/mt/72559525/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH V5] BaseTools:GuidedSectionTools.txt is not generated correctly
Posted by Bob Feng 4 years ago
Zhiju,

I have 2 comments on the code style. Inline.

On Thu, Mar 26, 2020 at 03:57 PM, Fan, ZhijuX wrote:

> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2538
> 
> For LzmaCompress or BrotliCompress, the platform may use the different
> options and add their batch file, such as LzmaCompressPlatform.
> Then, specify it in platform.dsc [BuildOptions] to override the default
> one in tools_def.txt.
> 
> *_*_*_LZMA_PATH = LzmaCompressPlatform
> 
> This override tool will be used. But, its name is not specified in the
> generated GuidedSectionTools.txt.
> 
> Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Bob Feng <bob.c.feng@intel.com>
> ---
> 
> A judgment condition was removed
> if self.Workspace.ToolDef.ToolsDefTxtDictionary.get(Def):
> 
> BaseTools/Source/Python/AutoGen/PlatformAutoGen.py | 3 ++-
> BaseTools/Source/Python/build/build.py | 13 +++----------
> 2 files changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
> b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
> index d32178b00c93..af66c48c7d6a 100644
> --- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
> +++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
> @@ -866,7 +866,8 @@ class PlatformAutoGen(AutoGen):
> Value += " " + self._BuildOptionWithToolDef(RetVal)[Tool][Attr]
> else:
> Value = self._BuildOptionWithToolDef(RetVal)[Tool][Attr]
> -
> + Def = '_'.join([self.BuildTarget, self.ToolChain, self.Arch, Tool,
> Attr])
> + self.Workspace.ToolDef.ToolsDefTxtDictionary[Def] = Value
> if Attr == "PATH":
> # Don't put MAKE definition in the file
> if Tool != "MAKE":
> diff --git a/BaseTools/Source/Python/build/build.py
> b/BaseTools/Source/Python/build/build.py
> index d841fefdc502..6dbe05f0a93e 100755
> --- a/BaseTools/Source/Python/build/build.py
> +++ b/BaseTools/Source/Python/build/build.py
> @@ -2363,16 +2363,9 @@ class Build():
> if os.path.exists(tool):
> return os.path.realpath(tool)
> else:

Remove this else block would make the code more clear.

> 
> - # We need to search for the tool using the
> - # PATH environment variable.
> - for dirInPath in os.environ['PATH'].split(os.pathsep):
> - foundPath = os.path.join(dirInPath, tool)
> - if os.path.exists(foundPath):
> - return os.path.realpath(foundPath)
> -
> - # If the tool was not found in the path then we just return
> - # the input tool.
> - return tool
> + # If the tool was not found in the path then we just return
> + # the input tool.

These 2 line comments are not necessary, since this function logical is simple.

> 
> + return tool
> 
> ## Launch the module or platform build
> #
> --
> 2.14.1.windows.1

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56383): https://edk2.groups.io/g/devel/message/56383
Mute This Topic: https://groups.io/mt/72559525/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-