mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #82166 from Steelskin/fabrice/6.2-line-directive
🍒 [6.2] line-directive: Stop expanding response files
This commit is contained in:
@@ -208,11 +208,8 @@ def map_line_from_source_file(source_filename, source_line_num,
|
||||
|
||||
def read_response_file(file_path):
|
||||
with open(file_path, 'r') as files:
|
||||
# "Make an iterator out of shlex.shlex.get_token, then consume items
|
||||
# until it returns None." (Then eagerly convert the result to a list so
|
||||
# that we can close the file.)
|
||||
return list(iter(shlex.shlex(files, file_path, posix=True).get_token,
|
||||
None))
|
||||
# Read a response file and return a list of files (one per line).
|
||||
return [line.strip() for line in files if line.strip()]
|
||||
|
||||
|
||||
def expand_response_files(files):
|
||||
@@ -683,16 +680,21 @@ def run():
|
||||
# delegates to the Win32 CreateProcess API. Unix systems handle
|
||||
# non-normalized paths, so don't have this problem.
|
||||
# Arguments passed to the process are normalized by the process.
|
||||
command_args = expand_response_files(sys.argv[dashes + 1:])
|
||||
command_args = sys.argv[dashes + 1:]
|
||||
command_args[0] = os.path.normpath(command_args[0])
|
||||
|
||||
command = subprocess.Popen(
|
||||
command_args,
|
||||
stderr=subprocess.STDOUT,
|
||||
stdout=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
encoding='UTF-8'
|
||||
)
|
||||
try:
|
||||
command = subprocess.Popen(
|
||||
command_args,
|
||||
stderr=subprocess.STDOUT,
|
||||
stdout=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
encoding='UTF-8'
|
||||
)
|
||||
except Exception as e:
|
||||
sys.stderr.write(f"Error executing command: {e}\n")
|
||||
sys.stderr.write(f"Command: {' '.join(shlex.quote(arg) for arg in command_args)}\n")
|
||||
sys.exit(1)
|
||||
|
||||
sources = '(?P<file>' + '|'.join(re.escape(s) for s in sources) + ')'
|
||||
|
||||
@@ -731,7 +733,12 @@ def run():
|
||||
m.group('tail'))
|
||||
sys.stdout.write(output)
|
||||
|
||||
sys.exit(command.wait())
|
||||
exit_code = command.wait()
|
||||
if exit_code != 0:
|
||||
sys.stderr.write(f"Command failed with exit code {exit_code}\n")
|
||||
sys.stderr.write(f"Command: {' '.join(shlex.quote(arg) for arg in command_args)}\n")
|
||||
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user