Relocate libc++ libraries to keep Soong happy.
These were removed from sources/ in the NDK because they're duplicate
bloat. Rather than fixing up Soong to handle this, just relocate them
to the place Soong expects them. This directory should be gone soon
anyway.
Bug: None
Test: None
Change-Id: I2ae26513bfbda2f0b206ea24a8a8904ee85de5d8
diff --git a/update.py b/update.py
index aa6be42..398a68b 100755
--- a/update.py
+++ b/update.py
@@ -89,6 +89,13 @@
LIBUNWIND_GLOB = "toolchains/llvm/prebuilt/*/lib64/clang/*/lib/linux/*/libunwind.a"
+LIBCXX_SHARED_GLOB = (
+ "toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/*/libc++_shared.so"
+)
+LIBCXX_STATIC_GLOB = (
+ "toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/*/libc++_static.a"
+)
+LIBCXXABI_GLOB = "toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/*/libc++abi.a"
def unzip_single_directory(artifact: Path, destination: Path) -> None:
@@ -106,6 +113,9 @@
"*/sources/cxx-stl/*",
"*/source.properties",
os.path.join("*", LIBUNWIND_GLOB),
+ os.path.join("*", LIBCXX_SHARED_GLOB),
+ os.path.join("*", LIBCXX_STATIC_GLOB),
+ os.path.join("*", LIBCXXABI_GLOB),
]
check_call(cmd)
@@ -116,6 +126,32 @@
child.rename(destination / child.name)
+def relocate_libcxx(install_dir: Path) -> None:
+ """Copies the libc++ libraries from the toolchain to sources.
+
+ New versions of the NDK have removed the libraries in the sources directory because
+ they are duplicates and they aren't needed in typical builds. Soong still expects to
+ find them in that directory though. We could fix Soong, but since this whole
+ directory should be dead soon we'll just fix-up the install for now.
+ """
+ dest_base = install_dir / "sources/cxx-stl/llvm-libc++/libs"
+ for glob in {LIBCXX_SHARED_GLOB, LIBCXX_STATIC_GLOB, LIBCXXABI_GLOB}:
+ file_name = Path(glob).name
+ for file_path in install_dir.glob(glob):
+ triple = file_path.parent.name
+ abi = {
+ "arm-linux-androideabi": "armeabi-v7a",
+ "aarch64-linux-android": "arm64-v8a",
+ "i686-linux-android": "x86",
+ "x86_64-linux-android": "x86_64",
+ }[triple]
+ dest_dir = dest_base / abi
+ dest_dir.mkdir(parents=True, exist_ok=True)
+ dest = dest_dir / file_name
+ logger().info("Relocating %s to %s", file_path, dest)
+ file_path.rename(dest)
+
+
def relocate_libunwind(install_dir: Path) -> None:
dest_base = install_dir / "sources/cxx-stl/llvm-libc++/libs"
for libunwind in install_dir.glob(LIBUNWIND_GLOB):
@@ -152,6 +188,7 @@
logger().info("Extracting release")
unzip_single_directory(artifact, install_dir)
+ relocate_libcxx(install_dir)
relocate_libunwind(install_dir)
delete_android_mks(install_dir)
finally: