Skip to content

Commit 995d7b6

Browse files
committed
Address cmake build failures on Windows in powershell and pwsh
Signed-off-by: javrin <[email protected]>
1 parent db5027f commit 995d7b6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/rez/tests/test_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _test_build_sup_world(self):
135135
stdout = proc.communicate()[0]
136136
self.assertEqual('hola amigo', stdout.strip())
137137

138-
@per_available_shell(include=["cmd", "gitbash"])
138+
@per_available_shell()
139139
@program_dependent("cmake", "make")
140140
@platform_dependent(["windows"])
141141
@install_dependent()

src/rezplugins/shell/_utils/powershell_base.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ def normalize_path(self, path):
248248
249249
This isn't explicitely necessary on Windows since around Windows 7,
250250
PowerShell has supported mixed slashes as a path separator. However,
251-
we can still call this method to normalize paths for consistency.
251+
we can still call this method to normalize paths for consistency, and
252+
have better interoperability with some software such as cmake which
253+
prefer forward slashes e.g. GH issue #1321.
252254
253255
Args:
254256
path (str): Path to normalize.
@@ -261,7 +263,8 @@ def normalize_path(self, path):
261263
return path
262264

263265
if platform_.name == "windows":
264-
normalized_path = path.replace("/", "\\")
266+
path = os.path.normpath(path)
267+
normalized_path = path.replace("\\", "/")
265268
if path != normalized_path:
266269
log("PowerShellBase normalize_path()")
267270
log("Path normalized: {!r} -> {!r}".format(path, normalized_path))
@@ -352,6 +355,8 @@ def join(cls, command):
352355
if isinstance(command, six.string_types):
353356
return command
354357

358+
find_unsafe = re.compile(r'[^\w@%+`:,./-]').search
359+
355360
replacements = [
356361
# escape ` as ``
357362
('`', "``"),
@@ -360,7 +365,7 @@ def join(cls, command):
360365
('"', '`"')
361366
]
362367

363-
joined = shlex_join(command, replacements=replacements)
368+
joined = shlex_join(command, unsafe_regex=find_unsafe, replacements=replacements)
364369

365370
# add call operator in case executable gets quotes applied
366371
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.1#call-operator-

0 commit comments

Comments
 (0)