From b9a8be97bc445edac024a35d644d5c86419a7f3a Mon Sep 17 00:00:00 2001 From: Martin Konicek Date: Wed, 20 Jan 2016 11:20:25 -0800 Subject: [PATCH] Build code depending on resources from the appcompat library with both Buck and Gradle Reviewed By: sdwilsh Differential Revision: D2844961 fb-gh-sync-id: 686a9f253eb370a9dc8cc33ca1c4e8453f89210a --- .../v7/appcompat/res-unpacker.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ReactAndroid/src/main/third-party/android-support-for-standalone-apps/v7/appcompat/res-unpacker.py diff --git a/ReactAndroid/src/main/third-party/android-support-for-standalone-apps/v7/appcompat/res-unpacker.py b/ReactAndroid/src/main/third-party/android-support-for-standalone-apps/v7/appcompat/res-unpacker.py new file mode 100644 index 000000000..145d09b02 --- /dev/null +++ b/ReactAndroid/src/main/third-party/android-support-for-standalone-apps/v7/appcompat/res-unpacker.py @@ -0,0 +1,20 @@ +import contextlib +import os +import shutil +import sys +import tempfile +import zipfile + +# Helper that unpacks the contents of the res folder of an .aar file +# into given destination. + +@contextlib.contextmanager +def cleanup(path): + yield path + shutil.rmtree(path) + +if __name__ == '__main__': + with zipfile.ZipFile(sys.argv[1], 'r') as z: + with cleanup(tempfile.mkdtemp()) as temp_path: + z.extractall(temp_path, filter(lambda n: n.startswith('res/'), z.namelist())) + shutil.move(os.path.join(temp_path, 'res'), sys.argv[2])