File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import bisect
2020import re
2121import subprocess
2222import sys
23+ import os
2324
2425line_pattern = re .compile (
2526 r'^// ###sourceLocation\(file:\s*"([^"]+)",\s*line:\s*([0-9]+)\s*\)' )
@@ -244,8 +245,18 @@ def run():
244245 dashes = sys .argv .index ('--' )
245246 sources = sys .argv [1 :dashes ]
246247
248+ # The first argument of command_args is the process to open.
249+ # subprocess.Popen doesn't normalise arguments. This means that trying
250+ # to open a non-normalised file (e.g. C:/swift/./bin/swiftc.exe) on
251+ # Windows results in file/directory not found errors, as Popen delegates
252+ # to the Win32 CreateProcess API. Unix systems handle non-normalised
253+ # paths, so don't have this problem.
254+ # Arguments passed to the process are normalised by the process.
255+ command_args = sys .argv [dashes + 1 :]
256+ command_args [0 ] = os .path .normpath (command_args [0 ])
257+
247258 command = subprocess .Popen (
248- sys . argv [ dashes + 1 :] ,
259+ command_args ,
249260 stderr = subprocess .STDOUT ,
250261 stdout = subprocess .PIPE ,
251262 universal_newlines = True
You can’t perform that action at this time.
0 commit comments