| # Copyright (C) 2025 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 | |
| # | |
| # https://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. | |
| """Perfetto Bazel module configuration for bzlmod.""" | |
| module( | |
| name = "perfetto", | |
| version = "0.0.0", | |
| ) | |
| bazel_dep(name = "abseil-cpp", version = "20250512.1", repo_name = "com_google_absl") | |
| bazel_dep(name = "bazel_skylib", version = "1.8.0") | |
| bazel_dep(name = "platforms", version = "0.0.11") | |
| bazel_dep(name = "protobuf", version = "31.1", repo_name = "com_google_protobuf") | |
| bazel_dep(name = "re2", version = "2024-07-02.bcr.1") | |
| bazel_dep(name = "rules_python", version = "1.0.0") | |
| bazel_dep(name = "rules_android", version = "0.7.3") | |
| bazel_dep(name = "rules_cc", version = "0.2.19") | |
| bazel_dep(name = "zstd", version = "1.5.7.bcr.1") | |
| # The Android SDK/NDK repositories, their toolchains and the Maven deps are | |
| # dev dependencies: they are only set up when Perfetto is the root module. | |
| # Modules depending on Perfetto can build the C++ targets without an Android | |
| # SDK/NDK installation, but cannot build the Android (Java SDK) targets. | |
| remote_android_extensions = use_extension( | |
| "@rules_android//bzlmod_extensions:android_extensions.bzl", | |
| "remote_android_tools_extensions", | |
| dev_dependency = True, | |
| ) | |
| use_repo(remote_android_extensions, "android_tools") | |
| android_sdk_repository_extension = use_extension( | |
| "@rules_android//rules/android_sdk_repository:rule.bzl", | |
| "android_sdk_repository_extension", | |
| dev_dependency = True, | |
| ) | |
| # When built using 'tools/bazel', 'ANDROID_HOME' environment variable points | |
| # to the hermetic Android SDK installation, that should be downloaded first | |
| # with 'tools/install-build-deps --android' | |
| android_sdk_repository_extension.configure( | |
| api_level = 35, | |
| build_tools_version = "35.0.1", | |
| ) | |
| use_repo(android_sdk_repository_extension, "androidsdk") | |
| register_toolchains( | |
| "@androidsdk//:sdk-toolchain", | |
| "@androidsdk//:all", | |
| dev_dependency = True, | |
| ) | |
| bazel_dep(name = "rules_jvm_external", version = "6.9", dev_dependency = True) | |
| bazel_dep(name = "rules_android_ndk", version = "0.1.3", dev_dependency = True) | |
| android_ndk_repository_extension = use_extension( | |
| "@rules_android_ndk//:extension.bzl", | |
| "android_ndk_repository_extension", | |
| dev_dependency = True, | |
| ) | |
| # When built using 'tools/bazel', 'ANDROID_NDK_HOME' environment variable points | |
| # to the hermetic Android NDK installation, that should be downloaded first | |
| # with 'tools/install-build-deps --android' | |
| android_ndk_repository_extension.configure( | |
| api_level = 26, | |
| ) | |
| use_repo(android_ndk_repository_extension, "androidndk") | |
| register_toolchains( | |
| "@androidndk//:all", | |
| dev_dependency = True, | |
| ) | |
| # Perfetto configuration repository extension. | |
| # This creates @perfetto_cfg which provides PERFETTO_CONFIG struct. | |
| perfetto_cfg_ext = use_extension( | |
| "//bazel:perfetto_cfg_ext.bzl", | |
| "perfetto_cfg_ext", | |
| ) | |
| use_repo(perfetto_cfg_ext, "perfetto_cfg") | |
| # Perfetto third-party dependencies extension. | |
| # These are the same deps defined in //bazel:deps.bzl for WORKSPACE users. | |
| perfetto_deps = use_extension( | |
| "//bazel:perfetto_deps.bzl", | |
| "perfetto_deps", | |
| ) | |
| use_repo( | |
| perfetto_deps, | |
| "perfetto_dep_expat", | |
| "perfetto_dep_linenoise", | |
| "perfetto_dep_llvm_demangle", | |
| "perfetto_dep_open_csd", | |
| "perfetto_dep_sqlite", | |
| "perfetto_dep_sqlite_src", | |
| "perfetto_dep_zlib", | |
| ) | |
| # Maven dependencies for Android instrumentation tests. | |
| # Use a unique name to avoid conflicts with other modules (e.g., bazel_worker_java). | |
| maven = use_extension( | |
| "@rules_jvm_external//:extensions.bzl", | |
| "maven", | |
| dev_dependency = True, | |
| ) | |
| maven.install( | |
| name = "perfetto_maven", | |
| # Use rules_android's aar_import to avoid toolchain type mismatch. | |
| aar_import_bzl_label = "@rules_android//rules:rules.bzl", | |
| artifacts = [ | |
| "androidx.test:runner:1.6.2", | |
| "androidx.test:monitor:1.7.2", | |
| "com.google.truth:truth:1.4.4", | |
| "junit:junit:4.13.2", | |
| "androidx.test.ext:junit:1.2.1", | |
| "com.google.errorprone:error_prone_annotations:2.36.0", | |
| ], | |
| repositories = [ | |
| "https://maven.google.com", | |
| "https://repo1.maven.org/maven2", | |
| ], | |
| ) | |
| use_repo(maven, "perfetto_maven") |