OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Extracts native methods from a Java file and generates the JNI bindings. | 6 """Extracts native methods from a Java file and generates the JNI bindings. |
7 If you change this, please run and update the tests.""" | 7 If you change this, please run and update the tests.""" |
8 | 8 |
9 import collections | 9 import collections |
10 import errno | 10 import errno |
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 if not os.path.exists(os.path.dirname(os.path.abspath(output_file))): | 1436 if not os.path.exists(os.path.dirname(os.path.abspath(output_file))): |
1437 os.makedirs(os.path.dirname(os.path.abspath(output_file))) | 1437 os.makedirs(os.path.dirname(os.path.abspath(output_file))) |
1438 if options.optimize_generation and os.path.exists(output_file): | 1438 if options.optimize_generation and os.path.exists(output_file): |
1439 with file(output_file, 'r') as f: | 1439 with file(output_file, 'r') as f: |
1440 existing_content = f.read() | 1440 existing_content = f.read() |
1441 if existing_content == content: | 1441 if existing_content == content: |
1442 return | 1442 return |
1443 with file(output_file, 'w') as f: | 1443 with file(output_file, 'w') as f: |
1444 f.write(content) | 1444 f.write(content) |
1445 else: | 1445 else: |
1446 print output | 1446 print content |
1447 | 1447 |
1448 | 1448 |
1449 def GetScriptName(): | 1449 def GetScriptName(): |
1450 script_components = os.path.abspath(sys.argv[0]).split(os.path.sep) | 1450 script_components = os.path.abspath(sys.argv[0]).split(os.path.sep) |
1451 base_index = 0 | 1451 base_index = 0 |
1452 for idx, value in enumerate(script_components): | 1452 for idx, value in enumerate(script_components): |
1453 if value == 'base' or value == 'third_party': | 1453 if value == 'base' or value == 'third_party': |
1454 base_index = idx | 1454 base_index = idx |
1455 break | 1455 break |
1456 return os.sep.join(script_components[base_index:]) | 1456 return os.sep.join(script_components[base_index:]) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 GenerateJNIHeader(input_file, output_file, options) | 1548 GenerateJNIHeader(input_file, output_file, options) |
1549 | 1549 |
1550 if options.depfile: | 1550 if options.depfile: |
1551 build_utils.WriteDepfile( | 1551 build_utils.WriteDepfile( |
1552 options.depfile, | 1552 options.depfile, |
1553 build_utils.GetPythonDependencies()) | 1553 build_utils.GetPythonDependencies()) |
1554 | 1554 |
1555 | 1555 |
1556 if __name__ == '__main__': | 1556 if __name__ == '__main__': |
1557 sys.exit(main(sys.argv)) | 1557 sys.exit(main(sys.argv)) |
OLD | NEW |