Skip to content

Commit

Permalink
Address cmake build failures on Windows in powershell and pwsh
Browse files Browse the repository at this point in the history
Signed-off-by: javrin <jawabiscuit@users.noreply.github.com>
  • Loading branch information
Jawabiscuit committed Sep 15, 2023
1 parent d0958cd commit 76cb8cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/rez/tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _test_build_sup_world(self):
stdout = proc.communicate()[0]
self.assertEqual('hola amigo', stdout.strip())

@per_available_shell(include=["cmd", "gitbash"])
@per_available_shell()
@program_dependent("cmake", "make")
@platform_dependent(["windows"])
@install_dependent()
Expand Down
11 changes: 8 additions & 3 deletions src/rezplugins/shell/_utils/powershell_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ def normalize_path(self, path):
This isn't explicitely necessary on Windows since around Windows 7,
PowerShell has supported mixed slashes as a path separator. However,
we can still call this method to normalize paths for consistency.
we can still call this method to normalize paths for consistency, and
have better interoperability with some software such as cmake which
prefer forward slashes e.g. GH issue #1321.
Args:
path (str): Path to normalize.
Expand All @@ -261,7 +263,8 @@ def normalize_path(self, path):
return path

if platform_.name == "windows":
normalized_path = path.replace("/", "\\")
path = os.path.normpath(path)
normalized_path = path.replace("\\", "/")
if path != normalized_path:
log("PowerShellBase normalize_path()")
log("Path normalized: {!r} -> {!r}".format(path, normalized_path))
Expand Down Expand Up @@ -354,6 +357,8 @@ def join(cls, command):
if isinstance(command, six.string_types):
return command

find_unsafe = re.compile(r'[^\w@%+`:,./-]').search

replacements = [
# escape ` as ``
('`', "``"),
Expand All @@ -362,7 +367,7 @@ def join(cls, command):
('"', '`"')
]

joined = shlex_join(command, replacements=replacements)
joined = shlex_join(command, unsafe_regex=find_unsafe, replacements=replacements)

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

0 comments on commit 76cb8cb

Please sign in to comment.