blob: fab46b9343cd30a26bafc5f02fdcce46f38bd1a0 [file] [log] [blame]
Elliott Hughes6b586e72021-04-15 13:39:08 -07001#!/usr/bin/env python3
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002
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
8import sys
9
10def has_arch_tags(tags):
Elliott Hughes28a64452022-10-05 20:17:41 +000011 for arch in ["arm", "arm64", "riscv64", "x86", "x86_64"]:
Elliott Hughesd19b3c52018-09-06 16:04:08 -070012 if arch in tags:
13 return True
14 return False
15
16def 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
27arch = sys.argv[1]
28in_filename = sys.argv[2]
29out_filename = sys.argv[3]
30GenerateVersionScript(arch, in_filename, out_filename)