diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-28 17:54:00 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-28 17:54:00 +0000 |
commit | 5e8aadccef64048b8dd6995b76a046e01059b341 (patch) | |
tree | 37a2c1300a0bfd58974dba694ac4961c63e97f67 | |
parent | d05ca7d65727fe3680abb18ce13b0664d7667c13 (diff) | |
parent | 95b2cbcaedbe3657b4c328b4259d825b3c99c8cf (diff) | |
download | bazel_common_rules-5e8aadccef64048b8dd6995b76a046e01059b341.tar.gz |
Snap for 11641499 from 95b2cbcaedbe3657b4c328b4259d825b3c99c8cf to build-tools-release
Change-Id: I676c72d9a1eac811407e40e7074519dac766e075
-rw-r--r-- | docs/BUILD | 21 | ||||
-rw-r--r-- | docs/docs.bzl | 177 | ||||
-rw-r--r-- | docs/index.html | 112 | ||||
-rwxr-xr-x | docs/insert_resource.py | 41 | ||||
-rw-r--r-- | docs/templates/func.vm | 21 | ||||
-rw-r--r-- | docs/templates/provider.vm | 20 | ||||
-rw-r--r-- | docs/templates/rule.vm | 21 | ||||
-rw-r--r-- | platforms/arch/BUILD | 5 | ||||
-rw-r--r-- | platforms/constants.bzl | 32 | ||||
-rw-r--r-- | platforms/os/BUILD | 5 | ||||
-rw-r--r-- | platforms/os_arch/BUILD.bazel | 32 | ||||
-rw-r--r-- | zip/BUILD | 13 | ||||
-rw-r--r-- | zip/zip.bzl | 53 |
13 files changed, 42 insertions, 511 deletions
diff --git a/docs/BUILD b/docs/BUILD deleted file mode 100644 index 1d032fb..0000000 --- a/docs/BUILD +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2021 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. - -exports_files([ - "index.html", - "insert_resource.py", - "templates/func.vm", - "templates/provider.vm", - "templates/rule.vm", -]) diff --git a/docs/docs.bzl b/docs/docs.bzl deleted file mode 100644 index ed25a45..0000000 --- a/docs/docs.bzl +++ /dev/null @@ -1,177 +0,0 @@ -# Copyright (C) 2021 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. - -"""Generate bare-bones docs with Stardoc""" - -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") -load("//build/bazel_common_rules/dist:dist.bzl", "copy_to_dist_dir") - -def _sanitize_label_as_filename(label): - """Sanitize a Bazel label so it is safe to be used as a filename.""" - label_text = str(label) - return _normalize(label_text) - -def _normalize(s): - """Returns a normalized string by replacing non-letters / non-numbers as underscores.""" - return "".join([c if c.isalnum() else "_" for c in s.elems()]) - -# TODO: Add aspect_template when necessary -def docs( - name, - srcs, - default = None, - deps = None, - func_template = None, - provider_template = None, - rule_template = None, - **kwargs): - """Build docs. - - The following rules are also generated: - - `{name}_dist` is created for distribution - - `{name}_server` is created for seeing docs locally. View with - ``` - bazel run {name}_server - ``` - - Args: - name: name of this rule. - srcs: sources (`*.bzl` files) to generate docs. Docs for definitions in - these files are emitted. - - `srcs` must be a list of real files. Labels to rules are not accepted. - default: An element in `srcs` that's shown in the renderer by default. - deps: additional dependencies of `srcs`. Definitions in these files do - not show up in the final output. - func_template: Template for generating docs for functions. - provider_template: Template for generating docs for providers. - rule_template: Template for generating docs for rules. - **kwargs: kwargs to internal rules - """ - - all_deps = [] - all_deps += srcs - if deps != None: - all_deps += deps - - if func_template == None: - func_template = "//build/bazel_common_rules/docs:templates/func.vm" - if provider_template == None: - provider_template = "//build/bazel_common_rules/docs:templates/provider.vm" - if rule_template == None: - rule_template = "//build/bazel_common_rules/docs:templates/rule.vm" - - private_kwargs = kwargs | { - "visibility": ["//visibility:private"], - } - - bzl_library( - name = name + "_deps", - srcs = all_deps, - **private_kwargs - ) - - # Key: label to bzl. Value: label to markdown. - bzl_md = {} - - for src in srcs: - stardoc_target_name = name + "-" + _sanitize_label_as_filename(src) - stardoc( - name = stardoc_target_name, - out = name + "/" + _sanitize_label_as_filename(src) + ".md", - input = src, - deps = [":" + name + "_deps"], - func_template = func_template, - provider_template = provider_template, - rule_template = rule_template, - **private_kwargs - ) - bzl_md[src] = stardoc_target_name - - default_file_cmd = """touch $@ && """ - for src in srcs: - if default == src: - default_file_cmd += """echo '<div hidden><a href="#{src}" id="default_file">{src}</a></div>' >> $@ &&""".format( - src = src, - ) - break - default_file_cmd += ":" - - native.genrule( - name = name + "_default_file.html.frag", - srcs = [ - ], - outs = [ - name + "/docs_resources/default_file.html.frag", - ], - cmd = default_file_cmd, - **private_kwargs - ) - - native.genrule( - name = name, - srcs = [ - "//build/bazel_common_rules/docs:index.html", - ":{name}_default_file.html.frag".format(name = name), - ] + bzl_md.keys() + bzl_md.values(), - outs = [ - name + "/root/index.html", - ], - cmd = """ - $(location //build/bazel_common_rules/docs:insert_resource.py) \\ - --infile $(location //build/bazel_common_rules/docs:index.html) \\ - --outfile $(location {name}/root/index.html) \\ - default_file.html.frag:$(location :{name}_default_file.html.frag) \\ - {bzl_md} - """.format( - name = name, - bzl_md = " ".join(["$(location {}):$(location {})".format(bzl, md) for bzl, md in bzl_md.items()]), - ), - tools = [ - "//build/bazel_common_rules/docs:insert_resource.py", - ], - **kwargs - ) - - native.genrule( - name = name + "_run_server.sh", - srcs = [], - outs = [ - name + "/run_server.sh", - ], - cmd = """ - cat > $(location {name}/run_server.sh) <<< '#!/usr/bin/env sh -cd $$(dirname $$0)/{name}/root && -python3 -m http.server 8080 -' - chmod +x $(location {name}/run_server.sh) - """.format(name = name), - **private_kwargs - ) - - native.sh_binary( - name = name + "_server", - srcs = [ - ":{name}_run_server.sh".format(name = name), - ], - data = [":" + name], - **kwargs - ) - - copy_to_dist_dir( - name = name + "_dist", - data = [":" + name], - **kwargs - ) diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index c7fff55..0000000 --- a/docs/index.html +++ /dev/null @@ -1,112 +0,0 @@ -<!DOCTYPE html> - -<!-- - ~ Copyright (C) 2021 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. - --> - -<html> -<head> - <script src="https://unpkg.com/showdown@1/dist/showdown.min.js"></script> - <script> - function showMarkdownFile(responseText, file) { - const headerLevelStart = 1; - - var converter = new showdown.Converter(); - converter.setOption("customizedHeaderId", true); - converter.setOption("ghCompatibleHeaderId", true); - converter.setOption("headerLevelStart", headerLevelStart); - converter.setOption("tables", true); - - var divFile = document.getElementById("div-file").cloneNode(true); - divFile.getElementsByClassName("div-file-contents")[0].innerHTML = converter.makeHtml(responseText); - - // Show file name - divFile.getElementsByClassName("headline-file-name")[0].id = file - divFile.getElementsByClassName("headline-file-name")[0].innerText = file; - - // Generate table of contents - var toc = document.getElementById("div-toc-contents") - - // Add link to title - var titleClone = document.getElementById("div-sample-toc-title").cloneNode(true) - var titleLink = titleClone.getElementsByTagName("a")[0] - titleLink.href = "#" + file - titleLink.innerText = file - toc.appendChild(titleClone) - - var h2Elements = divFile.getElementsByClassName("div-file-contents")[0].getElementsByTagName("h" + headerLevelStart) - var sampleTocItem = document.getElementById("div-sample-toc-item") - for (let i = 0; i < h2Elements.length; i++) { - var clone = sampleTocItem.cloneNode(true) - var link = clone.getElementsByTagName("a")[0]; - link.href = "#" + h2Elements[i].id - link.innerText = h2Elements[i].innerText - toc.appendChild(clone) - } - toc.appendChild(document.getElementById("div-sample-toc-break").cloneNode(true)) - - divFile.hidden = false; - document.body.appendChild(divFile) - } - - document.addEventListener("DOMContentLoaded", function () { - resources = document.getElementsByClassName("embedded_resource"); - for (var i = 0; i < resources.length; i++) { - if (!resources[i].id.endsWith("-res")) { - continue; - } - if (resources[i].id === "default_file.html.frag-res") { - continue; - } - file = resources[i].id.substring(0, resources[i].id.length - "-res".length) - console.log(file, resources[i]) - showMarkdownFile(atob(resources[i].innerText), file) - } - - // Decode default_file - document.getElementById("default_file.html.frag-res").innerHTML = atob(document.getElementById("default_file.html.frag-res").innerText); - default_file = document.getElementById("default_file") - if (default_file) { - document.location.href = default_file.href - } - }); - </script> - <style> - #div-float-right { - position: fixed; - right: 0; - top: 0; - } - </style> -</head> -<body> -<div id="div-float-right"> - <h3 id="headline-toc">Table of contents</h3> - <div hidden> - <div id="div-sample-toc-title"><strong><a></a></strong></div> - <div id="div-sample-toc-item"><code><a></a></code></div> - <div id="div-sample-toc-break"><br /></div> - </div> - <div id="div-toc-contents"> - </div> -</div> -<div id="div-file" hidden> - <h2 class="headline-file-name"></h2> - <div class="div-file-contents"> - </div> -</div> -<!--RESOURCE_EMBED_HINT--> -</body> -</html> diff --git a/docs/insert_resource.py b/docs/insert_resource.py deleted file mode 100755 index 09c9ef1..0000000 --- a/docs/insert_resource.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import base64 -import io -import os - -MAGIC = "<!--RESOURCE_EMBED_HINT-->\n" - - -def main(infile, outfile, resources): - """Embed resources into infile at the line `<!--RESOURCE_EMBED_HINT-->`.""" - inlines = infile.readlines() - magic = inlines.index(MAGIC) - - outlines = inlines[:magic] - for resource in resources: - resource_name, path = resource.rsplit(":", 1) - outlines.append('<div hidden class="embedded_resource" id="{}-res">\n'.format(os.path.basename(resource_name))) - with open(path, 'rb') as resource: - # Resources need to be base64 encoded. For example, the resource file may be in - # markdown format: - # `<name>` - # However, this is not valid HTML. So it cannot be embedded in the HTML file directly. - # The HTML renderer converts it to - # <code><name></code> - # This is valid HTML. See index.html. - outlines.append(base64.b64encode(resource.read()).decode()) - outlines.append('</div>\n') - outlines += inlines[magic:] - - outfile.writelines(outlines) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description=main.__doc__) - parser.add_argument("--infile", required=True, type=argparse.FileType('r'), help="input file") - parser.add_argument("--outfile", required=True, type=argparse.FileType('w'), help="output file") - parser.add_argument("resources", metavar="NAME:PATH", nargs='+', help="resource files") - args = parser.parse_args() - main(**vars(args)) diff --git a/docs/templates/func.vm b/docs/templates/func.vm deleted file mode 100644 index 50aafe4..0000000 --- a/docs/templates/func.vm +++ /dev/null @@ -1,21 +0,0 @@ -#[[#]]# `${funcInfo.functionName}` - -<pre> -${util.funcSummary($funcInfo)} -</pre> - -${funcInfo.docString} - -#[[##]]# Parameters - -#if (!$funcInfo.getParameterList().isEmpty()) - -#foreach ($param in $funcInfo.getParameterList()) -<a name="${funcInfo.functionName}-${param.name}"/> **`${param.name}`** -#if(${param.mandatory}) *Required.* #else *Optional.* #end #if(!${param.getDefaultValue().isEmpty()}) *Default is* `${param.getDefaultValue()}`. #end ${param.docString} - -#end -#else -No parameters. - -#end diff --git a/docs/templates/provider.vm b/docs/templates/provider.vm deleted file mode 100644 index ed1804f..0000000 --- a/docs/templates/provider.vm +++ /dev/null @@ -1,20 +0,0 @@ -#[[#]]# `${providerName}` - -<pre> -${util.providerSummary($providerName, $providerInfo)} -</pre> - -${providerInfo.docString} - -#[[##]]# Fields - -#if (!$providerInfo.fieldInfoList.isEmpty()) - -#foreach ($field in $providerInfo.fieldInfoList) -<a name="${providerName}-${field.name}" /> **`${field.name}`** -${field.docString} - -#end -#else -No fields. -#end diff --git a/docs/templates/rule.vm b/docs/templates/rule.vm deleted file mode 100644 index 7ad7e93..0000000 --- a/docs/templates/rule.vm +++ /dev/null @@ -1,21 +0,0 @@ -#[[#]]# `${ruleName}` - -<pre> -${util.ruleSummary($ruleName, $ruleInfo)} -</pre> - -${ruleInfo.docString} - -#[[##]]# Attributes - -#if (!$ruleInfo.getAttributeList().isEmpty()) - -#foreach ($attribute in $ruleInfo.getAttributeList()) -<a name="${ruleName}-${attribute.name}" /> **`${attribute.name}`** -*${util.attributeTypeString($attribute)}.* #if(${attribute.mandatory}) *Required.* #else *Optional.* #end #if(!${attribute.defaultValue.isEmpty()}) *Default is* `${attribute.defaultValue}`. #end $attribute.docString - -#end -#else -No attributes. - -#end diff --git a/platforms/arch/BUILD b/platforms/arch/BUILD index 56ba348..98938f9 100644 --- a/platforms/arch/BUILD +++ b/platforms/arch/BUILD @@ -9,21 +9,25 @@ package( alias( name = "arm", actual = "@platforms//cpu:arm", + deprecation = "Use @platforms//cpu:arm directly.", ) alias( name = "arm64", actual = "@platforms//cpu:arm64", + deprecation = "Use @platforms//cpu:arm64 directly.", ) alias( name = "riscv64", actual = "@platforms//cpu:riscv64", + deprecation = "Use @platforms//cpu:riscv64 directly.", ) alias( name = "x86", actual = "@platforms//cpu:x86_32", + deprecation = "Use @platforms//cpu:x86_32 directly.", ) # Alias to the local_jdk's toolchain constraint to make local_jdk resolve @@ -31,6 +35,7 @@ alias( alias( name = "x86_64", actual = "@platforms//cpu:x86_64", + deprecation = "Use @platforms//cpu:x86_64 directly.", ) constraint_setting( diff --git a/platforms/constants.bzl b/platforms/constants.bzl index 64e80fc..8eb05c5 100644 --- a/platforms/constants.bzl +++ b/platforms/constants.bzl @@ -5,45 +5,45 @@ # here. host_platforms = { "linux_x86": [ - "@//build/bazel_common_rules/platforms/arch:x86", - "@//build/bazel_common_rules/platforms/os:linux", + "@platforms//cpu:x86_32", + "@platforms//os:linux", ], "linux_x86_64": [ - "@//build/bazel_common_rules/platforms/arch:x86_64", - "@//build/bazel_common_rules/platforms/os:linux", + "@platforms//cpu:x86_64", + "@platforms//os:linux", ], "linux_musl_x86": [ - "@//build/bazel_common_rules/platforms/arch:x86", + "@platforms//cpu:x86_32", "@//build/bazel_common_rules/platforms/os:linux_musl", ], "linux_musl_x86_64": [ - "@//build/bazel_common_rules/platforms/arch:x86_64", + "@platforms//cpu:x86_64", "@//build/bazel_common_rules/platforms/os:linux_musl", ], # linux_bionic is the OS for the Linux kernel plus the Bionic libc runtime, # but without the rest of Android. "linux_bionic_arm64": [ - "@//build/bazel_common_rules/platforms/arch:arm64", + "@platforms//cpu:arm64", "@//build/bazel_common_rules/platforms/os:linux_bionic", ], "linux_bionic_x86_64": [ - "@//build/bazel_common_rules/platforms/arch:x86_64", + "@platforms//cpu:x86_64", "@//build/bazel_common_rules/platforms/os:linux_bionic", ], "darwin_arm64": [ - "@//build/bazel_common_rules/platforms/arch:arm64", - "@//build/bazel_common_rules/platforms/os:darwin", + "@platforms//cpu:arm64", + "@platforms//os:macos", ], "darwin_x86_64": [ - "@//build/bazel_common_rules/platforms/arch:x86_64", - "@//build/bazel_common_rules/platforms/os:darwin", + "@platforms//cpu:x86_64", + "@platforms//os:macos", ], "windows_x86": [ - "@//build/bazel_common_rules/platforms/arch:x86", - "@//build/bazel_common_rules/platforms/os:windows", + "@platforms//cpu:x86_32", + "@platforms//os:windows", ], "windows_x86_64": [ - "@//build/bazel_common_rules/platforms/arch:x86_64", - "@//build/bazel_common_rules/platforms/os:windows", + "@platforms//cpu:x86_64", + "@platforms//os:windows", ], } diff --git a/platforms/os/BUILD b/platforms/os/BUILD index 9b0464e..88fbf0a 100644 --- a/platforms/os/BUILD +++ b/platforms/os/BUILD @@ -11,6 +11,7 @@ package( alias( name = "android", actual = "@platforms//os:android", + deprecation = "Use @platforms//os:android directly.", ) config_setting( @@ -25,11 +26,13 @@ config_setting( alias( name = "linux", actual = "@platforms//os:linux", + deprecation = "Use @platforms//os:linux directly.", ) alias( name = "linux_glibc", actual = "@platforms//os:linux", + deprecation = "Use @platforms//os:linux directly.", ) constraint_value( @@ -52,11 +55,13 @@ config_setting( alias( name = "windows", actual = "@platforms//os:windows", + deprecation = "Use @platforms//os:windows directly.", ) alias( name = "darwin", actual = "@platforms//os:macos", + deprecation = "Use @platforms//os:macos directly.", ) selects.config_setting_group( diff --git a/platforms/os_arch/BUILD.bazel b/platforms/os_arch/BUILD.bazel index 56360f0..21b6a81 100644 --- a/platforms/os_arch/BUILD.bazel +++ b/platforms/os_arch/BUILD.bazel @@ -3,40 +3,40 @@ load("//build/bazel_common_rules/platforms:constants.bzl", "host_platforms") config_setting( name = "android_arm", constraint_values = [ - "//build/bazel_common_rules/platforms/arch:arm", - "//build/bazel_common_rules/platforms/os:android", + "@platforms//cpu:arm", + "@platforms//os:android", ], ) config_setting( name = "android_arm64", constraint_values = [ - "//build/bazel_common_rules/platforms/arch:arm64", - "//build/bazel_common_rules/platforms/os:android", + "@platforms//cpu:arm64", + "@platforms//os:android", ], ) config_setting( name = "android_riscv64", constraint_values = [ - "//build/bazel_common_rules/platforms/arch:riscv64", - "//build/bazel_common_rules/platforms/os:android", + "@platforms//cpu:riscv64", + "@platforms//os:android", ], ) config_setting( name = "android_x86", constraint_values = [ - "//build/bazel_common_rules/platforms/arch:x86", - "//build/bazel_common_rules/platforms/os:android", + "@platforms//cpu:x86_32", + "@platforms//os:android", ], ) config_setting( name = "android_x86_64", constraint_values = [ - "//build/bazel_common_rules/platforms/arch:x86_64", - "//build/bazel_common_rules/platforms/os:android", + "@platforms//cpu:x86_64", + "@platforms//os:android", ], ) @@ -52,23 +52,23 @@ config_setting( config_setting( name = "linux_glibc_x86", constraint_values = [ - "//build/bazel_common_rules/platforms/arch:x86", - "//build/bazel_common_rules/platforms/os:linux_glibc", + "@platforms//cpu:x86_32", + "@platforms//os:linux", ], ) config_setting( name = "linux_glibc_x86_64", constraint_values = [ - "//build/bazel_common_rules/platforms/arch:x86_64", - "//build/bazel_common_rules/platforms/os:linux_glibc", + "@platforms//cpu:x86_64", + "@platforms//os:linux", ], ) config_setting( name = "linux_musl_arm", constraint_values = [ - "//build/bazel_common_rules/platforms/arch:arm", + "@platforms//cpu:arm", "//build/bazel_common_rules/platforms/os:linux_musl", ], ) @@ -76,7 +76,7 @@ config_setting( config_setting( name = "linux_musl_arm64", constraint_values = [ - "//build/bazel_common_rules/platforms/arch:arm64", + "@platforms//cpu:arm64", "//build/bazel_common_rules/platforms/os:linux_musl", ], ) diff --git a/zip/BUILD b/zip/BUILD deleted file mode 100644 index 3b1f000..0000000 --- a/zip/BUILD +++ /dev/null @@ -1,13 +0,0 @@ -# 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 deleted file mode 100644 index 3dee689..0000000 --- a/zip/zip.bzl +++ /dev/null @@ -1,53 +0,0 @@ -# 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", - ), - }, -) |