blob: 8ddb0af738383a7c1aa976c0c63d197a32a61f5c [file]
# Copyright 2025 The Bazel Authors. All rights reserved.
#
# 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.
"""Module extension to enable building com.android.dex."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//rules:visibility.bzl", "PROJECT_VISIBILITY")
visibility(PROJECT_VISIBILITY)
def com_android_dex(mctx = None):
# NOTE(b/317109605): Cannot depend on a stable sha256 hash for googlesource repositories.
http_archive(
name = "com_android_dex",
urls = [
# Original download URL. Does not always return stable sha256sums, and can flake out.
# "https://android.googlesource.com/platform/dalvik/+archive/5a81c499a569731e2395f7c8d13c0e0d4e17a2b6.tar.gz",
"https://mirror.bazel.build/android.googlesource.com/platform/dalvik/+archive/5a81c499a569731e2395f7c8d13c0e0d4e17a2b6.tar.gz",
],
build_file = Label("//bzlmod_extensions:com_android_dex.BUILD"),
sha256 = "86b4848c038bf687fadc812239cb01fb8d1d15cef3125b480a0448360992b95d",
)
# NOTE: 'watch' is the best approximation for the extension_metadata
# function accepting the reproducible paramater
if mctx and hasattr(mctx, "watch"):
return mctx.extension_metadata(reproducible = True)
return None
com_android_dex_extension = module_extension(
implementation = com_android_dex,
)