aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/android
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-10-24 14:37:07 +0200
committerGravatar Dmitry Lomov <dslomov@google.com>2017-10-24 15:38:47 +0200
commit527ff1faeec309e5c5fd105ff13b2cb4c20dd4ef (patch)
tree10f8e47dc7cc98f18aa5d97e4a871421d3b21302 /tools/android
parent6a4247b10f5cf040c1a7176498bef69c75b1b286 (diff)
Android,Windows: longpath support in tool
Update aar_native_libs_zip_creator.py to support long paths by using junctions. See https://github.com/bazelbuild/bazel/issues/3955 Change-Id: Iafa9ceca9f2a9076f220bd6326c95e5fb8b27f63 PiperOrigin-RevId: 173244903
Diffstat (limited to 'tools/android')
-rw-r--r--tools/android/BUILD1
-rw-r--r--tools/android/aar_native_libs_zip_creator.py30
2 files changed, 23 insertions, 8 deletions
diff --git a/tools/android/BUILD b/tools/android/BUILD
index 302fa607f3..e5379e87f8 100644
--- a/tools/android/BUILD
+++ b/tools/android/BUILD
@@ -90,6 +90,7 @@ py_binary(
"aar_native_libs_zip_creator.py",
],
deps = [
+ ":junction_lib",
"//third_party/py/gflags",
],
)
diff --git a/tools/android/aar_native_libs_zip_creator.py b/tools/android/aar_native_libs_zip_creator.py
index 9b8e33dc4b..0195d01cad 100644
--- a/tools/android/aar_native_libs_zip_creator.py
+++ b/tools/android/aar_native_libs_zip_creator.py
@@ -1,3 +1,4 @@
+# pylint: disable=g-direct-third-party-import
# Copyright 2016 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,10 +20,12 @@ are converted from the AAR directory structure of /jni/<cpu>/foo.so to the APK
directory structure of /lib/<cpu>/foo.so.
"""
+import os
import re
import sys
import zipfile
+from tools.android import junction
from third_party.py import gflags
FLAGS = gflags.FLAGS
@@ -36,8 +39,7 @@ gflags.MarkFlagAsRequired("output_zip")
class UnsupportedArchitectureException(Exception):
- """Exception thrown when an AAR does not support the requested CPU.
- """
+ """Exception thrown when an AAR does not support the requested CPU."""
pass
@@ -55,17 +57,29 @@ def CreateNativeLibsZip(aar, cpu, native_libs_zip):
native_libs_zip.writestr(new_filename, aar.read(lib))
-def main():
- with zipfile.ZipFile(FLAGS.input_aar, "r") as input_aar:
- with zipfile.ZipFile(FLAGS.output_zip, "w") as native_libs_zip:
+def Main(input_aar_path, output_zip_path, cpu, input_aar_path_for_error_msg):
+ with zipfile.ZipFile(input_aar_path, "r") as input_aar:
+ with zipfile.ZipFile(output_zip_path, "w") as native_libs_zip:
try:
- CreateNativeLibsZip(input_aar, FLAGS.cpu, native_libs_zip)
+ CreateNativeLibsZip(input_aar, cpu, native_libs_zip)
except UnsupportedArchitectureException:
- print ("AAR " + FLAGS.input_aar +
- " missing native libs for requested architecture: " + FLAGS.cpu)
+ print("AAR " + input_aar_path_for_error_msg +
+ " missing native libs for requested architecture: " + cpu)
sys.exit(1)
+def main():
+ if os.name == "nt":
+ with junction.TempJunction(os.path.dirname(FLAGS.input_aar)) as j_in:
+ with junction.TempJunction(os.path.dirname(FLAGS.output_zip)) as j_out:
+ Main(
+ os.path.join(j_in, os.path.basename(FLAGS.input_aar)),
+ os.path.join(j_out, os.path.basename(FLAGS.output_zip)), FLAGS.cpu,
+ FLAGS.input_aar)
+ else:
+ Main(FLAGS.input_aar, FLAGS.output_zip, FLAGS.cpu, FLAGS.input_aar)
+
+
if __name__ == "__main__":
FLAGS(sys.argv)
main()