public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Carsey, Jaben" <jaben.carsey@intel.com>
To: "Rodriguez, Christian" <christian.rodriguez@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Feng, Bob C" <bob.c.feng@intel.com>,
	"Gao, Liming" <liming.gao@intel.com>,
	"Zhu, Yonghong" <yonghong.zhu@intel.com>
Subject: Re: [edk2-devel] [PATCH] BaseTools: Include headers not mentioned in inf are not hashed
Date: Fri, 10 May 2019 16:14:48 +0000	[thread overview]
Message-ID: <CB6E33457884FA40993F35157061515CBCC2DDE0@FMSMSX103.amr.corp.intel.com> (raw)
In-Reply-To: <3A7DCC9A944C6149BF832E1C9B718ABC01EDA27B@ORSMSX112.amr.corp.intel.com>

Inline.

tldr: good answers. 

If change list to set in name of set object:
Reviewed-by: jaben carsey <Jaben.carsey@intel.com>

> -----Original Message-----
> From: Rodriguez, Christian
> Sent: Friday, May 10, 2019 8:28 AM
> To: Carsey, Jaben <jaben.carsey@intel.com>; devel@edk2.groups.io
> Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
> Subject: RE: [edk2-devel] [PATCH] BaseTools: Include headers not
> mentioned in inf are not hashed
> Importance: High
> 
> Replies inline.
> 
> >-----Original Message-----
> >From: Carsey, Jaben
> >Sent: Thursday, May 9, 2019 4:39 PM
> >To: devel@edk2.groups.io; Rodriguez, Christian
> ><christian.rodriguez@intel.com>
> >Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming
> ><liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
> >Subject: RE: [edk2-devel] [PATCH] BaseTools: Include headers not
> mentioned
> >in inf are not hashed
> >
> >Some questions inline.
> >
> >> -----Original Message-----
> >> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> >> Christian Rodriguez
> >> Sent: Thursday, May 09, 2019 2:27 PM
> >> To: devel@edk2.groups.io
> >> Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming
> >> <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
> >> Subject: [edk2-devel] [PATCH] BaseTools: Include headers not mentioned
> >> in inf are not hashed
> >>
> >> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1787
> >>
> >> Get a list of local header files that are not present in the MetaFile
> >> for this module. Add those local header files into the hashing
> >> algorithm for a module. If a local header file is not present in the
> >> MetaFile, the module will still build correctly though the hashing
> >> system didn't know about it before.
> >>
> >> Signed-off-by: Christian Rodriguez <christian.rodriguez@intel.com>
> >> Cc: Bob Feng <bob.c.feng@intel.com>
> >> Cc: Liming Gao <liming.gao@intel.com>
> >> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> >> ---
> >>  BaseTools/Source/Python/AutoGen/AutoGen.py | 24
> >> ++++++++++++++++++++++++
> >>  1 file changed, 24 insertions(+)
> >>
> >> diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
> >> b/BaseTools/Source/Python/AutoGen/AutoGen.py
> >> index 31721a6f9f..bd282d3ec1 100644
> >> --- a/BaseTools/Source/Python/AutoGen/AutoGen.py
> >> +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
> >> @@ -4098,8 +4098,10 @@ class ModuleAutoGen(AutoGen):
> >>          if self.Name in GlobalData.gModuleHash[self.Arch] and
> >> GlobalData.gBinCacheSource and self.AttemptModuleCacheCopy():
> >>              return False
> >>          m = hashlib.md5()
> >> +
> >>          # Add Platform level hash
> >>          m.update(GlobalData.gPlatformHash.encode('utf-8'))
> >> +
> >>          # Add Package level hash
> >>          if self.DependentPackageList:
> >>              for Pkg in sorted(self.DependentPackageList, key=lambda x:
> >> x.PackageName):
> >> @@ -4118,14 +4120,36 @@ class ModuleAutoGen(AutoGen):
> >>          Content = f.read()
> >>          f.close()
> >>          m.update(Content)
> >> +
> >>          # Add Module's source files
> >> +        localSourceFileList = set()
> >>          if self.SourceFileList:
> >>              for File in sorted(self.SourceFileList, key=lambda x: str(x)):
> >> +                localSourceFileList.add(str(File))
> >>                  f = open(str(File), 'rb')
> >>                  Content = f.read()
> >>                  f.close()
> >>                  m.update(Content)
> >>
> >> +        # Get a list of Module's local header files not included in metaFile
> >> +        localHeaderList = set()
> >> +        if self.SourceDir:
> >> +            for root, dirs, files in os.walk(self.SourceDir):
> >> +                for aFile in files:
> >> +                    filePath = os.path.join(self.WorkspaceDir,
> >> + os.path.join(root,
> >> aFile))
> >> +                    if not filePath.endswith(('.h', '.H')):
> >> +                        continue
> >> +                    if filePath not in localSourceFileList:
> >
> >Confused about localSourceFileList.
> >Why is it a set and named list?
> >Why not just use self.SourceFileList?
> >
> The naming convention could be better and I can address that in a different
> patch, if we decide to go forward with this idea overall.
> It should probably be named a set.
> The reason to using this new set is for a few reasons:
> 1. self.SourceFileList contains source file paths of class PathClass and not type
> str
> 2. If we want to use self.SourceFileList you must convert PathClass to a str for
> string comparison
> The set just allows for a unique list of objects and theoretically faster to
> check existence.

I agree and really prefer the set datatype for this operation, the name is confusing.  I wonder what the ROI is for the custom PathClass sometimes.  Seems confusing often.

> 
> >> +                        localHeaderList.add(filePath)
> >> +
> >> +        # Add Module's local header files
> >> +        localHeaderList = list(localHeaderList)
> >> +        for File in sorted(localHeaderList):
> >> +            f = open(str(File), 'rb')
> >> +            Content = f.read()
> >
> >Can you use 'with open(...) as...:' syntax to make sure the file is always
> closed?
> I just used the same implementation as the above existing code. I can
> definitely change it to use 'with open(...)'.
> Though explicitly calling f.close() as below should be making sure the file is
> always closed.

Agreed, except if something raises an exception.  I think we should change all the code myself.

> >
> >> +            f.close()
> >> +            m.update(Content)
> >> +
> >>          ModuleHashFile = path.join(self.BuildDir, self.Name + ".hash")
> >>          if self.Name not in GlobalData.gModuleHash[self.Arch]:
> >>              GlobalData.gModuleHash[self.Arch][self.Name] =
> >> m.hexdigest()
> >> --
> >> 2.19.1.windows.1
> >>
> >>
> >> 


  reply	other threads:[~2019-05-10 16:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09 21:27 [PATCH] BaseTools: Include headers not mentioned in inf are not hashed Christian Rodriguez
2019-05-09 23:39 ` [edk2-devel] " Carsey, Jaben
2019-05-10 15:28   ` Christian Rodriguez
2019-05-10 16:14     ` Carsey, Jaben [this message]
2019-05-09 23:53 ` Laszlo Ersek
2019-05-10 13:41   ` Felix Polyudov
2019-05-10 19:13     ` Christian Rodriguez
2019-05-10 19:32       ` Felix Polyudov
2019-05-10 19:45         ` Christian Rodriguez
2019-05-13 11:39           ` Laszlo Ersek
2019-05-13 12:23             ` Bob Feng
2019-05-13 18:41               ` Christian Rodriguez
2019-05-14  2:52                 ` Bob Feng
2019-05-13 18:53             ` Christian Rodriguez
2019-05-13 20:19               ` Laszlo Ersek
2019-05-13 20:23                 ` Christian Rodriguez
     [not found]             ` <159E52DAFBF01090.24406@groups.io>
2019-05-13 19:39               ` Christian Rodriguez
2019-05-13 11:41           ` Bob Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CB6E33457884FA40993F35157061515CBCC2DDE0@FMSMSX103.amr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox