Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # usage: rule_binding.py INPUT CPPDIR HDIR -- INPUTS -- OPTIONS | 7 # usage: rule_binding.py INPUT CPPDIR HDIR -- INPUTS -- OPTIONS |
| 8 # | 8 # |
| 9 # INPUT is an IDL file, such as Whatever.idl. | 9 # INPUT is an IDL file, such as Whatever.idl. |
| 10 # | 10 # |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 for perl_module in perl_modules: | 66 for perl_module in perl_modules: |
| 67 include_dir = os.path.dirname(perl_module) | 67 include_dir = os.path.dirname(perl_module) |
| 68 if not include_dir in include_dirs: | 68 if not include_dir in include_dirs: |
| 69 include_dirs.append(include_dir) | 69 include_dirs.append(include_dir) |
| 70 | 70 |
| 71 # Build up the command. | 71 # Build up the command. |
| 72 command = ['perl', '-w'] | 72 command = ['perl', '-w'] |
| 73 for include_dir in include_dirs: | 73 for include_dir in include_dirs: |
| 74 command.extend(['-I', include_dir]) | 74 command.extend(['-I', include_dir]) |
| 75 command.append(generate_bindings) | 75 command.append(generate_bindings) |
| 76 command.extend(options) | 76 # Remove any qouble qoutes that may have gotten in here. We know that none of |
| 77 # the options will have meaningful double qoutes. | |
|
Ben Laurie
2009/07/06 16:11:20
To defend against the possibility of a define that
| |
| 78 command.extend([option.replace('"', '') for option in options]) | |
| 77 command.extend(['--outputDir', cppdir, input]) | 79 command.extend(['--outputDir', cppdir, input]) |
| 78 | 80 |
| 79 # Do it. check_call is new in 2.5, so simulate its behavior with call and | 81 # Do it. check_call is new in 2.5, so simulate its behavior with call and |
| 80 # assert. | 82 # assert. |
| 81 return_code = subprocess.call(command) | 83 return_code = subprocess.call(command) |
| 82 assert return_code == 0 | 84 assert return_code == 0 |
| 83 | 85 |
| 84 # Both the .cpp and .h were generated in cppdir, but if hdir is different, | 86 # Both the .cpp and .h were generated in cppdir, but if hdir is different, |
| 85 # the .h needs to move. Copy it instead of using os.rename for maximum | 87 # the .h needs to move. Copy it instead of using os.rename for maximum |
| 86 # portability in all cases. | 88 # portability in all cases. |
| 87 if cppdir != hdir: | 89 if cppdir != hdir: |
| 88 input_basename = os.path.basename(input) | 90 input_basename = os.path.basename(input) |
| 89 (root, ext) = os.path.splitext(input_basename) | 91 (root, ext) = os.path.splitext(input_basename) |
| 90 hname = 'V8%s.h' % root | 92 hname = 'V8%s.h' % root |
| 91 hsrc = os.path.join(cppdir, hname) | 93 hsrc = os.path.join(cppdir, hname) |
| 92 hdst = os.path.join(hdir, hname) | 94 hdst = os.path.join(hdir, hname) |
| 93 shutil.copyfile(hsrc, hdst) | 95 shutil.copyfile(hsrc, hdst) |
| 94 os.unlink(hsrc) | 96 os.unlink(hsrc) |
| 95 | 97 |
| 96 return return_code | 98 return return_code |
| 97 | 99 |
| 98 | 100 |
| 99 if __name__ == '__main__': | 101 if __name__ == '__main__': |
| 100 sys.exit(main(sys.argv)) | 102 sys.exit(main(sys.argv)) |
| OLD | NEW |