Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(msvs): fix paths again in action command arguments #121

Merged
merged 3 commits into from
Aug 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _NormalizedSource(source):
return source


def _FixPath(path):
def _FixPath(path, separator="\\"):
"""Convert paths to a form that will make sense in a vcproj file.

Arguments:
Expand All @@ -168,9 +168,12 @@ def _FixPath(path):
and not _IsWindowsAbsPath(path)
):
path = os.path.join(fixpath_prefix, path)
path = path.replace("/", "\\")
if separator == "\\":
path = path.replace("/", "\\")
path = _NormalizedSource(path)
if path and path[-1] == "\\":
if separator == "/":
path = path.replace("\\", "/")
if path and path[-1] == separator:
path = path[:-1]
return path

Expand All @@ -185,9 +188,9 @@ def _IsWindowsAbsPath(path):
return path.startswith("c:") or path.startswith("C:")


def _FixPaths(paths):
def _FixPaths(paths, separator="\\"):
"""Fix each of the paths of the list."""
return [_FixPath(i) for i in paths]
return [_FixPath(i, separator) for i in paths]


def _ConvertSourcesToFilterHierarchy(
Expand Down Expand Up @@ -418,7 +421,15 @@ def _BuildCommandLineForRuleRaw(
# file out of the raw command string, and some commands (like python) are
# actually batch files themselves.
command.insert(0, "call")
arguments = [i.replace("$(InputDir)", "%INPUTDIR%") for i in cmd[1:]]
# Fix the paths
# TODO(quote): This is a really ugly heuristic, and will miss path fixing
# for arguments like "--arg=path" or "/opt:path".
# If the argument starts with a slash or dash, it's probably a command line
# switch
# Return the path with forward slashes because the command using it might
# not support backslashes.
arguments = [i if (i[:1] in "/-") else _FixPath(i, "/") for i in cmd[1:]]
arguments = [i.replace("$(InputDir)", "%INPUTDIR%") for i in arguments]
arguments = [MSVSSettings.FixVCMacroSlashes(i) for i in arguments]
if quote_cmd:
# Support a mode for using cmd directly.
Expand Down