aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-22 02:02:01 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-22 02:02:01 +0000
commit85f367cb94c60c4fdb315a8f653c31ea7a3c068a (patch)
treed36dcfe7e0eb690f1db3254ba5d18921d2788d2c
parent308d2be0b43f9a7f618837c3babb47fb43a49e91 (diff)
parentb4f0919269ec78d28ec32a34ca90e107c3a41f4e (diff)
downloadbazel_common_rules-common-android14-6.1-2023-05-exp-release.tar.gz
Snap for 11203489 from b4f0919269ec78d28ec32a34ca90e107c3a41f4e to common-android14-6.1-2023-05-exp-releasecommon-android14-6.1-2023-05-exp-release
Change-Id: Ifb92d739ba8bdc4258bcaf776ed0806c0fbe0a80
-rw-r--r--OWNERS2
-rw-r--r--zip/BUILD13
-rw-r--r--zip/zip.bzl53
3 files changed, 67 insertions, 1 deletions
diff --git a/OWNERS b/OWNERS
index 4de1e69..a9c7465 100644
--- a/OWNERS
+++ b/OWNERS
@@ -5,4 +5,4 @@ include platform/build/soong:/OWNERS
#
# The kernel follows a different branching model than that of platform, which
# needs the 'master' branch to be explicitly declared.
-include kernel/build:master:/kleaf/OWNERS
+include kernel/build:main:/OWNERS
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",
+ ),
+ },
+)