aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/zip
diff options
context:
space:
mode:
authorGravatar Adam Michael <ajmichael@google.com>2016-09-14 15:07:50 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-09-14 16:56:25 +0000
commitf8a675231680c4ed9d1ca8801268e1afe64b2ac9 (patch)
treeac6225a6d1e239ada155b52fa562990afbb93124 /tools/zip
parent03b9cfd3f9117fc22bf8ae129c316cf606b46a00 (diff)
Adds aar_import rule to Bazel along with tools needed to implement it. Currently only uses AndroidManifest.xml, classes.jar and res/ from AARs. This is sufficient for many of the AARs of Google Play Services and Android Support Repository.
The next step will be for AndroidSdkRepositoryRule to scan the SDK and generate aar_import rules for the AARs within. The rule is not yet documented because it is not intended for end users to use it yet. We should probably support more of the features of AARs before that time. See http://tools.android.com/tech-docs/new-build-system/aar-format for all of the files that can be included in AARs. Also note that R.txt from the AAR is intentionally ignored and regenerated based on the contents of res/. This is more correct, because the R.txt inside of an AAR can contain ids for dependencies of the AAR that are not included in res/. See https://github.com/bazelbuild/bazel/issues/564 for discussion of supporting AARs and https://github.com/bazelbuild/bazel/issues/1745 for motivation to get it done soon. -- MOS_MIGRATED_REVID=133127933
Diffstat (limited to 'tools/zip')
-rw-r--r--tools/zip/BUILD12
-rwxr-xr-xtools/zip/unzip.sh20
-rwxr-xr-xtools/zip/zip_manifest_creator.sh30
3 files changed, 61 insertions, 1 deletions
diff --git a/tools/zip/BUILD b/tools/zip/BUILD
index 30fd8c09bc..09951bfa72 100644
--- a/tools/zip/BUILD
+++ b/tools/zip/BUILD
@@ -3,7 +3,7 @@ package(default_visibility = ["//visibility:public"])
filegroup(
name = "srcs",
- srcs = ["BUILD"],
+ srcs = glob(["**"]),
)
# zipper will be added when creating the @bazel_tools repository.
@@ -11,3 +11,13 @@ filegroup(
name = "zipper",
srcs = glob(["zipper/*"]),
)
+
+sh_binary(
+ name = "unzip",
+ srcs = ["unzip.sh"],
+)
+
+sh_binary(
+ name = "zip_manifest_creator",
+ srcs = ["zip_manifest_creator.sh"],
+)
diff --git a/tools/zip/unzip.sh b/tools/zip/unzip.sh
new file mode 100755
index 0000000000..12efdbd9aa
--- /dev/null
+++ b/tools/zip/unzip.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Copyright 2016 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This exists so that unzip can be invoked by a SpawnAction. It relies on unzip
+# existing in the user's path.
+
+unzip "$@"
diff --git a/tools/zip/zip_manifest_creator.sh b/tools/zip/zip_manifest_creator.sh
new file mode 100755
index 0000000000..2331a2a6e8
--- /dev/null
+++ b/tools/zip/zip_manifest_creator.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+# Copyright 2016 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This script takes in a regular expression and a zip file and writes a file
+# containing the names of all files in the zip file that match the regular
+# expression with one per line. Names of directories are not included.
+
+if [ "$#" -ne 3 ]; then
+ echo "Usage: zip_manifest_creator.sh <regexp> <input zip> <output manifest>"
+ exit 1
+fi
+
+REGEX="$1"
+INPUT_ZIP="$2"
+OUTPUT_MANIFEST="$3"
+
+zipinfo -1 "$INPUT_ZIP" -x "*/" | grep -x "$REGEX" > "$OUTPUT_MANIFEST"