blob: 7a9b21198dfeb81be098559b4da078fc38aa0691 [file] [log] [blame]
Tianjie Xua5dcb7c2018-09-25 12:25:15 -07001import fnmatch
2import os
3import os.path
4from shutil import copyfile
5
6print('Searching for manifests...')
7
8matches = []
9for 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
13for 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
36print('Finished resolving symlinks')