2015-10-28 23:14:13 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
# This tool is used to generate the version scripts for libc and libm
|
|
|
|
# for every architecture.
|
|
|
|
|
|
|
|
import atexit
|
|
|
|
import os.path
|
|
|
|
import shutil
|
|
|
|
import tempfile
|
2016-03-03 22:10:23 +01:00
|
|
|
import sys
|
2015-10-28 23:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
all_arches = ["arm", "arm64", "mips", "mips64", "x86", "x86_64"]
|
|
|
|
bionic_libc_root = os.path.join(os.environ["ANDROID_BUILD_TOP"], "bionic/libc")
|
|
|
|
bionic_libm_root = os.path.join(os.environ["ANDROID_BUILD_TOP"], "bionic/libm")
|
2015-10-31 01:43:27 +01:00
|
|
|
bionic_libdl_root = os.path.join(os.environ["ANDROID_BUILD_TOP"], "bionic/libdl")
|
2015-10-28 23:14:13 +01:00
|
|
|
libc_script = os.path.join(bionic_libc_root, "libc.map.txt")
|
|
|
|
libm_script = os.path.join(bionic_libm_root, "libm.map.txt")
|
2015-10-31 01:43:27 +01:00
|
|
|
libdl_script = os.path.join(bionic_libdl_root, "libdl.map.txt")
|
2015-10-28 23:14:13 +01:00
|
|
|
|
2016-03-03 22:10:23 +01:00
|
|
|
script_name = os.path.basename(sys.argv[0])
|
|
|
|
|
2015-10-28 23:14:13 +01:00
|
|
|
# TODO (dimity): generate architecture-specific version scripts as part of build
|
|
|
|
|
|
|
|
# temp directory where we store all intermediate files
|
|
|
|
bionic_temp = tempfile.mkdtemp(prefix="bionic_genversionscripts")
|
|
|
|
# Make sure the directory is deleted when the script exits.
|
|
|
|
atexit.register(shutil.rmtree, bionic_temp)
|
|
|
|
|
|
|
|
bionic_libc_root = os.path.join(os.environ["ANDROID_BUILD_TOP"], "bionic/libc")
|
|
|
|
|
2016-03-03 22:10:23 +01:00
|
|
|
warning = "Generated by %s. Do not edit." % script_name
|
2015-10-28 23:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
class VersionScriptGenerator(object):
|
|
|
|
|
|
|
|
def run(self):
|
2015-10-31 01:43:27 +01:00
|
|
|
for script in [libc_script, libm_script, libdl_script]:
|
2015-10-28 23:14:13 +01:00
|
|
|
basename = os.path.basename(script)
|
|
|
|
dirname = os.path.dirname(script)
|
|
|
|
for arch in all_arches:
|
2015-12-14 23:07:52 +01:00
|
|
|
for brillo in [False, True]:
|
|
|
|
has_nobrillo = False
|
|
|
|
name = basename.split(".")[0] + "." + arch + (".brillo" if brillo else "") + ".map"
|
|
|
|
tmp_path = os.path.join(bionic_temp, name)
|
|
|
|
dest_path = os.path.join(dirname, name)
|
|
|
|
with open(tmp_path, "w") as fout:
|
|
|
|
with open(script, "r") as fin:
|
|
|
|
fout.write("# %s\n" % warning)
|
|
|
|
for line in fin:
|
|
|
|
index = line.find("#")
|
|
|
|
if index != -1:
|
|
|
|
tags = line[index+1:].split()
|
|
|
|
if arch not in tags:
|
|
|
|
continue
|
|
|
|
if brillo and "nobrillo" in tags:
|
|
|
|
has_nobrillo = True
|
|
|
|
continue
|
|
|
|
fout.write(line)
|
|
|
|
if not brillo or has_nobrillo:
|
|
|
|
shutil.copyfile(tmp_path, dest_path)
|
2015-10-28 23:14:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
generator = VersionScriptGenerator()
|
|
|
|
generator.run()
|
|
|
|
|