Tianjie Xu | a5dcb7c | 2018-09-25 12:25:15 -0700 | [diff] [blame] | 1 | import fnmatch |
| 2 | import os |
| 3 | import os.path |
| 4 | from shutil import copyfile |
| 5 | |
| 6 | print('Searching for manifests...') |
| 7 | |
| 8 | matches = [] |
| 9 | for root, dirnames, filenames in os.walk('bazel-bin\\org\\brotli'): |
| 10 | for filename in fnmatch.filter(filenames, '*.runfiles_manifest'): |
| 11 | matches.append(os.path.join(root, filename)) |
| 12 | |
| 13 | for match in matches: |
| 14 | print('Scanning manifest ' + match) |
| 15 | runfiles = match[:-len('_manifest')] |
| 16 | with open(match) as manifest: |
| 17 | for entry in manifest: |
| 18 | entry = entry.strip() |
| 19 | if not entry.startswith("org_brotli_java"): |
| 20 | continue |
| 21 | if entry.startswith('org_brotli_java/external'): |
| 22 | continue |
| 23 | (alias, space, link) = entry.partition(' ') |
| 24 | if alias.endswith('.jar') or alias.endswith('.exe'): |
| 25 | continue |
| 26 | link = link.replace('/', '\\') |
| 27 | alias = alias.replace('/', '\\') |
| 28 | dst = os.path.join(runfiles, alias) |
| 29 | if not os.path.exists(dst): |
| 30 | print(link + ' -> ' + dst) |
| 31 | parent = os.path.dirname(dst) |
| 32 | if not os.path.exists(parent): |
| 33 | os.makedirs(parent) |
| 34 | copyfile(link, dst) |
| 35 | |
| 36 | print('Finished resolving symlinks') |