xref: /aosp_15_r20/build/bazel/rules/android/debug_signing_key.bzl (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1# Copyright (C) 2023 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load(":android_app_certificate.bzl", "android_app_certificate_with_default_cert")
16load(":android_app_keystore.bzl", "android_app_keystore")
17
18def debug_signing_key(name, certificate, certificate_name):
19    if not certificate and not certificate_name:
20        return []
21    if certificate and certificate_name:
22        fail("Cannot use both certificate_name and certificate attributes together. Use only one of them.")
23    if certificate_name:
24        app_cert_name = name + "_app_certificate"
25        android_app_certificate_with_default_cert(
26            name = app_cert_name,
27            cert_name = certificate_name,
28        )
29        certificate = ":" + app_cert_name
30
31    app_keystore_name = name + "_keystore"
32    android_app_keystore(
33        name = app_keystore_name,
34        certificate = certificate,
35    )
36
37    return [app_keystore_name]
38