Elliott Hughes | 6b586e7 | 2021-04-15 13:39:08 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Elliott Hughes | d19b3c5 | 2018-09-06 16:04:08 -0700 | [diff] [blame] | 2 | |
| 3 | # This tool is used to generate the version scripts for libc, libm, libdl, |
| 4 | # and libstdc++ for every architecture. |
| 5 | |
| 6 | # usage: generate-version-script.py ARCH INPUT OUTPUT |
| 7 | |
| 8 | import sys |
| 9 | |
| 10 | def has_arch_tags(tags): |
Elliott Hughes | 28a6445 | 2022-10-05 20:17:41 +0000 | [diff] [blame^] | 11 | for arch in ["arm", "arm64", "riscv64", "x86", "x86_64"]: |
Elliott Hughes | d19b3c5 | 2018-09-06 16:04:08 -0700 | [diff] [blame] | 12 | if arch in tags: |
| 13 | return True |
| 14 | return False |
| 15 | |
| 16 | def GenerateVersionScript(arch, in_filename, out_filename): |
| 17 | with open(out_filename, "w") as fout: |
| 18 | with open(in_filename, "r") as fin: |
| 19 | for line in fin: |
| 20 | index = line.find("#") |
| 21 | if index != -1: |
| 22 | tags = line[index+1:].split() |
| 23 | if arch not in tags and has_arch_tags(tags): |
| 24 | continue |
| 25 | fout.write(line) |
| 26 | |
| 27 | arch = sys.argv[1] |
| 28 | in_filename = sys.argv[2] |
| 29 | out_filename = sys.argv[3] |
| 30 | GenerateVersionScript(arch, in_filename, out_filename) |