OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import re | 10 import re |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 # 2. A single .java file results in multiple .class files when it contains | 76 # 2. A single .java file results in multiple .class files when it contains |
77 # nested classes. | 77 # nested classes. |
78 # Here's an example: | 78 # Here's an example: |
79 # source path: ../../base/android/java/src/org/chromium/Foo.java | 79 # source path: ../../base/android/java/src/org/chromium/Foo.java |
80 # jar paths: org/chromium/Foo.class, org/chromium/Foo$Inner.class | 80 # jar paths: org/chromium/Foo.class, org/chromium/Foo$Inner.class |
81 # To extract only .class files not related to the given .java files, we strip | 81 # To extract only .class files not related to the given .java files, we strip |
82 # off ".class" and "$*.class" and use a substring match against java_files. | 82 # off ".class" and "$*.class" and use a substring match against java_files. |
83 def extract_predicate(path): | 83 def extract_predicate(path): |
84 if not path.endswith('.class'): | 84 if not path.endswith('.class'): |
85 return False | 85 return False |
86 path_without_suffix = re.sub(r'(?:\$|\.)[^/]+class$', '', path) | 86 path_without_suffix = re.sub(r'(?:\$|\.)[^/]*class$', '', path) |
87 partial_java_path = path_without_suffix + '.java' | 87 partial_java_path = path_without_suffix + '.java' |
88 return not any(p.endswith(partial_java_path) for p in java_files) | 88 return not any(p.endswith(partial_java_path) for p in java_files) |
89 | 89 |
90 build_utils.ExtractAll(jar_path, path=dest_dir, predicate=extract_predicate) | 90 build_utils.ExtractAll(jar_path, path=dest_dir, predicate=extract_predicate) |
91 for path in build_utils.FindInDirectory(dest_dir, '*.class'): | 91 for path in build_utils.FindInDirectory(dest_dir, '*.class'): |
92 shutil.copystat(jar_path, path) | 92 shutil.copystat(jar_path, path) |
93 | 93 |
94 | 94 |
95 def _ConvertToJMakeArgs(javac_cmd, pdb_path): | 95 def _ConvertToJMakeArgs(javac_cmd, pdb_path): |
96 new_args = ['bin/jmake', '-pdb', pdb_path] | 96 new_args = ['bin/jmake', '-pdb', pdb_path] |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 options, | 408 options, |
409 input_paths=input_paths, | 409 input_paths=input_paths, |
410 input_strings=javac_cmd, | 410 input_strings=javac_cmd, |
411 output_paths=output_paths, | 411 output_paths=output_paths, |
412 force=force, | 412 force=force, |
413 pass_changes=True) | 413 pass_changes=True) |
414 | 414 |
415 | 415 |
416 if __name__ == '__main__': | 416 if __name__ == '__main__': |
417 sys.exit(main(sys.argv[1:])) | 417 sys.exit(main(sys.argv[1:])) |
OLD | NEW |