diff options
author | Pierre Gondois <pierre.gondois@arm.com> | 2025-04-30 14:31:24 +0200 |
---|---|---|
committer | Liming Gao <gaoliming@byosoft.com.cn> | 2025-07-01 09:51:38 +0800 |
commit | ac9dc333965804e128945c28482c1b76199d6968 (patch) | |
tree | 63a49a996057e54946b943764cadff6a32084b05 /BaseTools/Source | |
parent | f79717aac2345568f46d69e125972342850ebd1e (diff) | |
download | edk2-ac9dc333965804e128945c28482c1b76199d6968.zip edk2-ac9dc333965804e128945c28482c1b76199d6968.tar.gz edk2-ac9dc333965804e128945c28482c1b76199d6968.tar.bz2 |
BaseTools: build: Remove unnecessary code
Running the vulture tool on the build folder gave the following
report. Remove the unnecessary code.
- build/build.py:79:
unused function 'IsToolInPath' (60% confidence)
- build/build.py:396:
unused class 'PlatformMakeUnit' (60% confidence)
- build/build.py:570:
unused method 'GetErrorMessage' (60% confidence)
- build/build.py:806:
unused attribute 'HashSkipModules' (60% confidence)
- build/build.py:807:
unused attribute 'Db_Flag' (60% confidence)
- build/build.py:1048:
unused attribute 'Db_Flag' (60% confidence)
- build/build.py:2500:
unused method 'GetRealPathOfTool' (60% confidence)
- build/BuildReport.py:1497:
unused method 'StrtoHex' (60% confidence)
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Diffstat (limited to 'BaseTools/Source')
-rw-r--r-- | BaseTools/Source/Python/build/BuildReport.py | 30 | ||||
-rwxr-xr-x | BaseTools/Source/Python/build/build.py | 55 |
2 files changed, 0 insertions, 85 deletions
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index a11195b..2eeaf4f 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -1494,36 +1494,6 @@ class PcdReport(object): else:
FileWrite(File, ' %-*s = %s' % (self.MaxLen + 4, '.' + Key, Value[0]))
- def StrtoHex(self, value):
- try:
- value = hex(int(value))
- return value
- except:
- if value.startswith("L\"") and value.endswith("\""):
- valuelist = []
- for ch in value[2:-1]:
- valuelist.append(hex(ord(ch)))
- valuelist.append('0x00')
- return valuelist
- elif value.startswith("\"") and value.endswith("\""):
- return hex(ord(value[1:-1]))
- elif value.startswith("{") and value.endswith("}"):
- valuelist = []
- if ',' not in value:
- return value[1:-1]
- for ch in value[1:-1].split(','):
- ch = ch.strip()
- if ch.startswith('0x') or ch.startswith('0X'):
- valuelist.append(ch)
- continue
- try:
- valuelist.append(hex(int(ch.strip())))
- except:
- pass
- return valuelist
- else:
- return value
-
def IsStructurePcd(self, PcdToken, PcdTokenSpaceGuid):
if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd) and ((PcdToken, PcdTokenSpaceGuid) in GlobalData.gStructurePcd[self.Arch]):
return True
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index a78d4e9..0ca71e5 100755 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -71,22 +71,6 @@ gSupportedTarget = ['all', 'genc', 'genmake', 'modules', 'libraries', 'fds', 'cl TemporaryTablePattern = re.compile(r'^_\d+_\d+_[a-fA-F0-9]+$')
TmpTableDict = {}
-## Check environment PATH variable to make sure the specified tool is found
-#
-# If the tool is found in the PATH, then True is returned
-# Otherwise, False is returned
-#
-def IsToolInPath(tool):
- if 'PATHEXT' in os.environ:
- extns = os.environ['PATHEXT'].split(os.path.pathsep)
- else:
- extns = ('',)
- for pathDir in os.environ['PATH'].split(os.path.pathsep):
- for ext in extns:
- if os.path.exists(os.path.join(pathDir, tool + ext)):
- return True
- return False
-
## Check environment variables
#
# Check environment variables that must be set for build. Currently they are
@@ -385,26 +369,6 @@ class ModuleMakeUnit(BuildUnit): if Target in [None, "", "all"]:
self.Target = "tbuild"
-## The smallest platform unit that can be built by nmake/make command in multi-thread build mode
-#
-# This class is for platform build by nmake/make build system. The "Obj" parameter
-# must provide __str__(), __eq__() and __hash__() methods. Otherwise there could
-# be make units missing build.
-#
-# Currently the "Obj" should be only PlatformAutoGen object.
-#
-class PlatformMakeUnit(BuildUnit):
- ## The constructor
- #
- # @param self The object pointer
- # @param Obj The PlatformAutoGen object the build is working on
- # @param Target The build target name, one of gSupportedTarget
- #
- def __init__(self, Obj, BuildCommand, Target):
- Dependency = [ModuleMakeUnit(Lib, BuildCommand, Target) for Lib in self.BuildObject.LibraryAutoGenList]
- Dependency.extend([ModuleMakeUnit(Mod, BuildCommand,Target) for Mod in self.BuildObject.ModuleAutoGenList])
- BuildUnit.__init__(self, Obj, BuildCommand, Target, Dependency, Obj.MakeFileDir)
-
## The class representing the task of a module build or platform build
#
# This class manages the build tasks in multi-thread build mode. Its jobs include
@@ -562,15 +526,6 @@ class BuildTask: def HasError():
return BuildTask._ErrorFlag.is_set()
- ## Get error message in running thread
- #
- # Since the main thread cannot catch exceptions in other thread, we have to
- # use a static variable to communicate this message to main thread.
- #
- @staticmethod
- def GetErrorMessage():
- return BuildTask._ErrorMessage
-
## Factory method to create a BuildTask object
#
# This method will check if a module is building or has been built. And if
@@ -803,8 +758,6 @@ class Build(): self.LoadFixAddress = 0
self.UniFlag = BuildOptions.Flag
self.BuildModules = []
- self.HashSkipModules = []
- self.Db_Flag = False
self.LaunchPrebuildFlag = False
self.PlatformBuildPath = os.path.join(GlobalData.gConfDirectory, '.cache', '.PlatformBuild')
if BuildOptions.CommandLength:
@@ -1045,7 +998,6 @@ class Build(): if 'PREBUILD' in GlobalData.gCommandLineDefines:
self.Prebuild = GlobalData.gCommandLineDefines.get('PREBUILD')
else:
- self.Db_Flag = True
Platform = self.Db.MapPlatform(str(self.PlatformFile))
self.Prebuild = str(Platform.Prebuild)
if self.Prebuild:
@@ -2495,13 +2447,6 @@ class Build(): print(' '.join(guidedSectionTool), file=toolsFile)
toolsFile.close()
- ## Returns the real path of the tool.
- #
- def GetRealPathOfTool (self, tool):
- if os.path.exists(tool):
- return os.path.realpath(tool)
- return tool
-
## Launch the module or platform build
#
def Launch(self):
|