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