aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-08 01:10:15 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-08 01:10:15 +0000
commitde359a353d123c21e67156496282f7e09718889c (patch)
treedec953318ec716d8257efbffabe1bc168d5ab5b9
parent4216cd005f68ae9e74d2c5b9e758f385d09e04d3 (diff)
parent53490f9ecf6af8717c26c3abfc826f26985a095f (diff)
downloadbazel_common_rules-simpleperf-release.tar.gz
Snap for 11421525 from 53490f9ecf6af8717c26c3abfc826f26985a095f to simpleperf-releasesimpleperf-release
Change-Id: I4d5086842e4bf67dd026d18db61d93c6914d6ba6
-rw-r--r--zip/BUILD13
-rw-r--r--zip/zip.bzl53
2 files changed, 66 insertions, 0 deletions
diff --git a/zip/BUILD b/zip/BUILD
new file mode 100644
index 0000000..3b1f000
--- /dev/null
+++ b/zip/BUILD
@@ -0,0 +1,13 @@
+# Copyright (C) 2023 The Android Open Source Project
+#
+# 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.
diff --git a/zip/zip.bzl b/zip/zip.bzl
new file mode 100644
index 0000000..3dee689
--- /dev/null
+++ b/zip/zip.bzl
@@ -0,0 +1,53 @@
+# Copyright (C) 2023 The Android Open Source Project
+#
+# 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.
+
+"""Creates a zip archive from the specified targets."""
+
+def _zip_archive_impl(ctx):
+ out_filename = ctx.attr.out if ctx.attr.out else ctx.attr.name + ".zip"
+ out = ctx.actions.declare_file(out_filename)
+ srcs_depset = depset(transitive = [target.files for target in ctx.attr.srcs])
+
+ args = ctx.actions.args()
+ args.add("-symlinks=false")
+ args.add("-o", out)
+ args.add_all(srcs_depset, before_each = "-f")
+
+ ctx.actions.run(
+ inputs = srcs_depset,
+ outputs = [out],
+ executable = ctx.executable._soong_zip,
+ arguments = [args],
+ mnemonic = "Zip",
+ progress_message = "Zipping %s" % (out_filename),
+ )
+ return [DefaultInfo(files = depset([out]))]
+
+zip_archive = rule(
+ implementation = _zip_archive_impl,
+ doc = "A rule to create a zip archive from specified targets",
+ attrs = {
+ "srcs": attr.label_list(
+ mandatory = True,
+ allow_files = True,
+ doc = "the targets with outputs to put in the generated archive",
+ ),
+ "out": attr.string(doc = "the output file name. Will use basename+\".zip\" if not specified"),
+ "_soong_zip": attr.label(
+ default = "//prebuilts/build-tools:soong_zip",
+ executable = True,
+ cfg = "exec",
+ ),
+ },
+)