Skip to content

Fix line-directive-tool not being able to invoke swiftc.exe on Windows #6824

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

Merged
merged 1 commit into from
Jan 15, 2017
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
13 changes: 12 additions & 1 deletion utils/line-directive
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import bisect
import re
import subprocess
import sys
import os

line_pattern = re.compile(
r'^// ###sourceLocation\(file:\s*"([^"]+)",\s*line:\s*([0-9]+)\s*\)')
Expand Down Expand Up @@ -244,8 +245,18 @@ def run():
dashes = sys.argv.index('--')
sources = sys.argv[1:dashes]

# The first argument of command_args is the process to open.
# subprocess.Popen doesn't normalise arguments. This means that trying
# to open a non-normalised file (e.g. C:/swift/./bin/swiftc.exe) on
# Windows results in file/directory not found errors, as Popen delegates
# to the Win32 CreateProcess API. Unix systems handle non-normalised
# paths, so don't have this problem.
# Arguments passed to the process are normalised by the process.
command_args = sys.argv[dashes + 1:]
command_args[0] = os.path.normpath(command_args[0])

command = subprocess.Popen(
sys.argv[dashes + 1:],
command_args,
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE,
universal_newlines=True
Expand Down