diff options
author | Adam Michael <ajmichael@google.com> | 2016-09-30 21:01:07 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-10-04 08:53:15 +0000 |
commit | 954c8abcf7e11ac491059cfbaa968bc6a64b4772 (patch) | |
tree | 1de460214f3b4ae2dec4b56528405fa91f19b07a /tools/zip | |
parent | 3c0d64886d2f7f6b2015780f1628b1391c320d0f (diff) |
Use ijar:zipper instead of zipinfo for zip_manifest_creator.sh.
Also, explicitly puts tools/zip:zipper and tools/zip:zip_manifest_creator.sh into BUILD.tools because they are only used from within @build_tools.
--
MOS_MIGRATED_REVID=134824173
Diffstat (limited to 'tools/zip')
-rw-r--r-- | tools/zip/BUILD | 13 | ||||
-rw-r--r-- | tools/zip/BUILD.tools | 17 | ||||
-rwxr-xr-x | tools/zip/zip_manifest_creator.sh | 19 | ||||
-rwxr-xr-x | tools/zip/zip_manifest_creator_test.sh | 5 |
4 files changed, 39 insertions, 15 deletions
diff --git a/tools/zip/BUILD b/tools/zip/BUILD index 0703d7f3bb..cfb986b993 100644 --- a/tools/zip/BUILD +++ b/tools/zip/BUILD @@ -1,4 +1,3 @@ -# Build file to expose zipper to the @bazel_tools repository. package(default_visibility = ["//visibility:public"]) filegroup( @@ -6,20 +5,10 @@ filegroup( srcs = glob(["**"]), ) -# zipper will be added when creating the @bazel_tools repository. -filegroup( - name = "zipper", - srcs = glob(["zipper/*"]), -) - -sh_binary( - name = "unzip", - srcs = ["unzip.sh"], -) - sh_binary( name = "zip_manifest_creator", srcs = ["zip_manifest_creator.sh"], + data = ["//third_party/ijar:zipper"], ) sh_test( diff --git a/tools/zip/BUILD.tools b/tools/zip/BUILD.tools new file mode 100644 index 0000000000..c7b69d5b4e --- /dev/null +++ b/tools/zip/BUILD.tools @@ -0,0 +1,17 @@ +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "zipper", + srcs = glob(["zipper/*"]), +) + +sh_binary( + name = "unzip", + srcs = ["unzip.sh"], +) + +sh_binary( + name = "zip_manifest_creator", + srcs = ["zip_manifest_creator.sh"], + data = [":zipper"], +) diff --git a/tools/zip/zip_manifest_creator.sh b/tools/zip/zip_manifest_creator.sh index bc80b82557..2ab6543402 100755 --- a/tools/zip/zip_manifest_creator.sh +++ b/tools/zip/zip_manifest_creator.sh @@ -27,5 +27,22 @@ REGEX="$1" INPUT_ZIP="$2" OUTPUT_MANIFEST="$3" -zipinfo -1 "$INPUT_ZIP" -x "*/" | grep -x "$REGEX" > "$OUTPUT_MANIFEST" +RUNFILES=${RUNFILES:-$0.runfiles} + +# For the sh_binary in BUILD.tools, zipper is here. +ZIPPER=$RUNFILES/bazel_tools/tools/zip/zipper/zipper +if [ ! -x $ZIPPER ]; then + # For the sh_test in BUILD.oss, zipper is here. + ZIPPER=$RUNFILES/third_party/ijar/zipper +fi +if [ ! -x $ZIPPER ]; then + echo "zip_manifest_creator could not find zipper executable" + exit 1 +fi + +$ZIPPER v "$INPUT_ZIP" \ + | cut -d ' ' -f3 \ + | grep -v \/$ \ + | grep -x "$REGEX" \ + > "$OUTPUT_MANIFEST" exit 0 diff --git a/tools/zip/zip_manifest_creator_test.sh b/tools/zip/zip_manifest_creator_test.sh index 05dffd97a1..3c3d09b42b 100755 --- a/tools/zip/zip_manifest_creator_test.sh +++ b/tools/zip/zip_manifest_creator_test.sh @@ -14,7 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -CUT=$(dirname "{BASH_SOURCE[0]}")/tools/zip/zip_manifest_creator.sh +export RUNFILES=${RUNFILES:-$($(cd $(dirname ${BASH_SOURCE[0]})); pwd)} +CUT=$RUNFILES/tools/zip/zip_manifest_creator touch classes.jar touch AndroidManifest.xml @@ -29,7 +30,7 @@ zip -q foo.zip res/values/baz.xml $CUT 'res/.*' foo.zip actual.manifest -cat <<EOT >> expected.manifest +cat > expected.manifest <<EOT res/values/bar.xml res/values/baz.xml EOT |