Yocto Project Discussions
 help / color / mirror / Atom feed
From: Muhammad Hamza <muhammad_hamza@mentor.com>
To: <yocto@lists.yoctoproject.org>
Cc: <jpewhacker@gmail.com>, Muhammad Hamza <muhammad_hamza@mentor.com>
Subject: [meta-mingw][kirkstone][PATCH] toolchain-scripts-mingw32.bbclass: Remove trailing slash in SDKROOT
Date: Mon, 24 Oct 2022 11:02:30 +0500	[thread overview]
Message-ID: <20221024060230.946830-1-muhammad_hamza@mentor.com> (raw)

Modify toolchain-scripts-mingw32.bbclass to add a check in
environment-setup script which removes trailing slash in
path of SDKROOT.
This is needed to avoid multiple adjacent slashes in paths
which are produced by appending to SDKROOT.
In reference to https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN
naming convention used for paths and disk drives in windows
should use a single backslash. Even though in some cases windows
ignores double slashes in paths and it might work but it isn't
documented as a right naming convention and does fail in some
cases eg. dir command cannot interpret double slashes and fails.

For example if my SDK is located in D: drive, the environment
setup scripts sets "SDKROOT=D:\" and hence SDKTARGETSYSROOT
gets set as "SDKTARGETSYSROOT=D:\\sysroots\armv8a-oe-linux"
The introduced check removes additional slash in SDKROOT to
set it as "SDKROOT=D:" so all other variables using SDKROOT
get set without additional slash.

Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com>
---
 classes/toolchain-scripts-mingw32.bbclass | 1 +
 1 file changed, 1 insertion(+)

diff --git a/classes/toolchain-scripts-mingw32.bbclass b/classes/toolchain-scripts-mingw32.bbclass
index d96cb40..8cb426a 100644
--- a/classes/toolchain-scripts-mingw32.bbclass
+++ b/classes/toolchain-scripts-mingw32.bbclass
@@ -12,6 +12,7 @@ toolchain_create_sdk_env_script:sdkmingw32 () {
 	touch $script
 	# Be sure to use the 'short' path, so we can have deeper directories.
 	echo 'set SDKROOT=%~sdp0%' >> $script
+	echo 'IF %SDKROOT:~-1%==\ set SDKROOT=%SDKROOT:~0,-1%' >> $script
 
 	# Convert to mingw32 subpaths
 	sysroot='%SDKROOT%'${sysroot##${SDKPATH}}
-- 
2.25.1



             reply	other threads:[~2022-10-24  6:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24  6:02 Muhammad Hamza [this message]
2022-10-28 12:00 ` [meta-mingw][kirkstone][PATCH] toolchain-scripts-mingw32.bbclass: Remove trailing slash in SDKROOT Hamza, Muhammad
2022-10-28 12:44   ` Joshua Watt
2022-10-28 12:49     ` Hamza, Muhammad

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-all 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=20221024060230.946830-1-muhammad_hamza@mentor.com \
    --to=muhammad_hamza@mentor.com \
    --cc=jpewhacker@gmail.com \
    --cc=yocto@lists.yoctoproject.org \
    /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