Close the permission bubble when use clicks 'esc'
[chromium-blink-merge.git] / third_party / opus / convert_rtcd_assembler.py
blobdc63c641f57f4c7ce49bda7f32bf976f87225ec7
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 # Script for converting celt_pitch_xcorr_arm.s -> celt_pitch_xcorr_arm.S
7 # using the arm2gnu.pl script.
9 import os
10 import sys
13 USAGE = ('Usage:\n'
14 './convert_rtcd_assembler.py arm2gnu_script input_file output_file')
17 def main(argv):
18 if len(argv) != 3:
19 print >> sys.stderr, ('Error: You must pass the following arguments:\n'
20 ' * arm2gnu_script_path\n'
21 ' * input_file\n'
22 ' * output_file')
23 print USAGE
24 return 1
26 arm2gnu_script = os.path.abspath(argv[0])
27 if not os.path.exists(arm2gnu_script):
28 print >> sys.stderr, ('Error: Cannot find arm2gnu.pl script at: %s.' %
29 arm2gnu_script)
30 return 2
32 input_file = os.path.abspath(argv[1])
33 if not os.path.exists(input_file):
34 print >> sys.stderr, 'Error: Cannot find input file at: %s.' % input_file
35 return 3
37 output_file = argv[2]
39 # Ensure the output file's directory path exists.
40 output_dir = os.path.dirname(output_file)
41 if not os.path.exists(output_dir):
42 os.makedirs(output_dir)
44 cmd = ('perl %s %s | '
45 'sed "s/OPUS_ARM_MAY_HAVE_[A-Z]*/1/g" | '
46 'sed "/.include/d" '
47 '> %s') % (arm2gnu_script, input_file, output_file)
48 print cmd
49 return os.system(cmd)
51 if __name__ == '__main__':
52 sys.exit(main(sys.argv[1:]))