From a74fe97ac99bdf8ccd29f975f2e7a0d0c24237c5 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 9 Jul 2021 23:00:26 -0700 Subject: [PATCH] scons: Eliminate the SourceFile.basename property. This value is used in only two places, and can be calculated in place to avoid complexity. Change-Id: I1e59b92521250b3f5a3e2cba599236ededf1761d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48124 Reviewed-by: Daniel Carvalho Reviewed-by: Bobby R. Bruce Maintainer: Bobby R. Bruce Tested-by: kokoro --- src/SConscript | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/SConscript b/src/SConscript index 53df4f54a2..df879500ca 100644 --- a/src/SConscript +++ b/src/SConscript @@ -48,7 +48,7 @@ import re import sys import zlib -from os.path import basename, dirname, exists, isdir, isfile, join as joinpath +from os.path import dirname, exists, isdir, isfile, join as joinpath import SCons @@ -275,10 +275,6 @@ class SourceFile(object, metaclass=SourceMeta): self.shared_objs[key] = env.SharedObject(self.tnode) return self.shared_objs[key] - @property - def basename(self): - return basename(self.filename) - def __lt__(self, other): return self.filename < other.filename def __le__(self, other): return self.filename <= other.filename def __gt__(self, other): return self.filename > other.filename @@ -375,7 +371,8 @@ class PySource(SourceFile): '''specify the python package, the source file, and any tags''' super(PySource, self).__init__(source, tags, add_tags) - modname, ext = os.path.splitext(self.basename) + basename = os.path.basename(self.filename) + modname, ext = os.path.splitext(basename) assert ext == '.py' if package: @@ -388,7 +385,7 @@ class PySource(SourceFile): modpath += [ modname ] modpath = '.'.join(modpath) - arcpath = path + [ self.basename ] + arcpath = path + [ basename ] abspath = self.snode.abspath if not exists(abspath): abspath = self.tnode.abspath @@ -461,7 +458,8 @@ class ProtoBuf(SourceFile): error('Got protobuf to build, but lacks support!') # Get the file name and the extension - modname, ext = os.path.splitext(self.basename) + basename = os.path.basename(self.filename) + modname, ext = os.path.splitext(basename) assert ext == '.proto' self.cc_file, self.hh_file = env.ProtoBufCC(source=source)