blob: 21d23e8b760ea82a6451b4205775d53750a02e78 [file] [log] [blame]
Yang Guo2fd941d2019-03-05 11:30:15 +01001#!/usr/bin/env python
2
3# Copyright 2019 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7'''
8Converts a given file in clang assembly syntax to a corresponding
9representation in inline assembly. Specifically, this is used for
10Windows clang builds.
11'''
12
13import argparse
14import sys
15
16def asm_to_inl_asm(in_filename, out_filename):
17 with open(in_filename, 'r') as infile, open(out_filename, 'wb') as outfile:
18 outfile.write('__asm__(\n')
19 for line in infile:
20 # Escape " in .S file before outputing it to inline asm file.
21 line = line.replace('"', '\\"')
22 outfile.write(' "%s\\n"\n' % line.rstrip())
23 outfile.write(');\n')
24 return 0
25
26if __name__ == '__main__':
27 parser = argparse.ArgumentParser(description=__doc__)
28 parser.add_argument('input', help='Name of the input assembly file')
29 parser.add_argument('output', help='Name of the target CC file')
30 args = parser.parse_args()
31 sys.exit(asm_to_inl_asm(args.input, args.output))