public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Evan Lloyd <Evan.Lloyd@arm.com>
To: Chris Co <Christopher.Co@microsoft.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: Liming Gao <liming.gao@intel.com>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	Sami Mujawar <Sami.Mujawar@arm.com>
Subject: Re: [PATCH v1 1/1] BaseTools/Trim: Canonicalize filepaths to fix comparison
Date: Wed, 27 Jun 2018 11:35:00 +0000	[thread overview]
Message-ID: <DB6PR08MB2806528E67C2F4BA6B4E9DD38B480@DB6PR08MB2806.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <20180627035753.49848-2-christopher.co@microsoft.com>

Hi Chris.
Firstly, thank you: this is a useful, pragmatic solution to an major annoyance.
I personally think it unfortunate that the GCC guys can't be bothered to fix their compiler, but ...

> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Chris Co
> Sent: 27 June 2018 04:58
> To: edk2-devel@lists.01.org
> Cc: Liming Gao <liming.gao@intel.com>
> Subject: [edk2] [PATCH v1 1/1] BaseTools/Trim: Canonicalize filepaths to fix
> comparison
>
> When using Linaro GCC5+ arm-eabi toolchain on Windows, the generated
> DSDT.iii contains a canonicalized ("\.\" removed and lower case) filepath for
> the preprocessed DSDT.i file in the first line.
> Due to this, when Trim.exe is called to generate DSDT.iiii, future filepath
> comparisons against this canonicalized filepath, which should match, actually
> fail the comparison which results in an empty DSDT.iiii.
>
> Issue was first reported to Linaro here:
> https://bugs.linaro.org/show_bug.cgi?id=2909
> where the recommendation was to address the issue in Trim.exe.
>
> This patch canonicalizes and lower cases all file paths encountered during
> trim execution on preprocessed files.  Since file paths are standarized, the
> comparison succeeds for files that should match regardless of the presence
> of upper case or "\.\" characters in the file path.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Christopher Co <christopher.co@microsoft.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> ---
>  BaseTools/Source/Python/Trim/Trim.py | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/BaseTools/Source/Python/Trim/Trim.py
> b/BaseTools/Source/Python/Trim/Trim.py
> index a74075859148..cca4e5c9694a 100644
> --- a/BaseTools/Source/Python/Trim/Trim.py
> +++ b/BaseTools/Source/Python/Trim/Trim.py
> @@ -166,6 +166,8 @@ def TrimPreprocessedFile(Source, Target, ConvertHex,
> TrimLong):
>              if len(MatchList) == 2:
>                  LineNumber = int(MatchList[0], 0)
>                  InjectedFile = MatchList[1]
> +                InjectedFile = InjectedFile.replace("\\.\\","")

[[Evan Lloyd]] I've not actually tried this yet, but it looks surprizing.  I'd have expected InjectedFile.replace("\\.\\","\\").
          Can I ask how it works, please?  Have I missed something?
[[Evan Lloyd]] Would it be possible to achieve the same effect with os.path.normpath (see Common/LongFilePathOsPath.py imported via line 17)?

> +                InjectedFile = InjectedFile.lower()
[[Evan Lloyd]] Similarly, there is "os.path.normcase" - but that may not get the comparison working (because it converts '/' to '\' on Windows).

>                  # The first injetcted file must be the preprocessed file itself
>                  if PreprocessedFile == "":
>                      PreprocessedFile = InjectedFile
> --
> 2.16.2.gvfs.1.33.gf5370f1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


  parent reply	other threads:[~2018-06-27 11:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-27  3:58 [PATCH v1 0/1] BaseTools/Trim: Canonicalize filepaths to fix comparison Chris Co
2018-06-27  3:58 ` [PATCH v1 1/1] " Chris Co
2018-06-27  6:59   ` Gao, Liming
2018-06-27  9:43   ` Leif Lindholm
2018-06-27 11:35   ` Evan Lloyd [this message]
2018-06-27 18:13     ` Chris Co
2018-06-27 18:23       ` Chris Co
2018-06-27 20:03         ` Chris Co
2018-06-28 10:35           ` Evan Lloyd
2018-06-28 13:40             ` Gao, Liming

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=DB6PR08MB2806528E67C2F4BA6B4E9DD38B480@DB6PR08MB2806.eurprd08.prod.outlook.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