| # Copyright (C) 2019 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. | |
| """Perfetto third-party dependencies for WORKSPACE-based builds. | |
| This file defines external repository rules for Perfetto's dependencies. | |
| It is used by embedders who include Perfetto via WORKSPACE. For bzlmod users, | |
| the equivalent dependencies are defined in perfetto_deps.bzl as a module | |
| extension. | |
| This file must be kept in sync with: | |
| - tools/install-build-deps (for version consistency) | |
| - bazel/perfetto_deps.bzl (for bzlmod compatibility) | |
| """ | |
| load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository") | |
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | |
| # To generate shallow_since fields for git repos, use: | |
| # git show --date=raw COMMIT | |
| def perfetto_deps(): | |
| """Loads Perfetto's third-party dependencies. | |
| Call this function from your WORKSPACE file after loading this file. | |
| For bzlmod users, use the perfetto_deps module extension instead. | |
| TODO: WORKSPACE-based embedder builds are currently broken because | |
| bazel/rules.bzl unconditionally loads @rules_android (added in | |
| b177135eeb, Feb 2025), which requires rules_android, rules_android_ndk, | |
| and their transitive deps (rules_java, etc.) to be provided by the | |
| embedder's WORKSPACE. Fixing this requires either: | |
| (a) Adding rules_android + full transitive chain here, or | |
| (b) Making the load in bazel/rules.bzl conditional. | |
| Standalone builds use bzlmod (MODULE.bazel) and are not affected. | |
| """ | |
| # For bzlmod users, protobuf is provided via MODULE.bazel. | |
| # For non-bzlmod users, this provides protobuf v31.1. | |
| _add_repo_if_not_existing( | |
| http_archive, | |
| name = "com_google_protobuf", | |
| strip_prefix = "protobuf-31.1", | |
| url = "https://github.com/protocolbuffers/protobuf/archive/v31.1.tar.gz", | |
| sha256 = "c3a0a9ece8932e31c3b736e2db18b1c42e7070cd9b881388b26d01aa71e24ca2", | |
| ) | |
| _add_repo_if_not_existing( | |
| http_archive, | |
| name = "perfetto_dep_sqlite", | |
| url = "https://storage.googleapis.com/perfetto/sqlite-amalgamation-3530400.zip", | |
| sha256 = "1e71ddf93849c6a6ecf58b827c0692073d2dd7ee40196158068f7b29f422e87d", | |
| strip_prefix = "sqlite-amalgamation-3530400", | |
| build_file = "//bazel:sqlite.BUILD", | |
| ) | |
| _add_repo_if_not_existing( | |
| new_git_repository, | |
| name = "perfetto_dep_linenoise", | |
| remote = "https://fuchsia.googlesource.com/third_party/linenoise.git", | |
| commit = "c894b9e59f02203dbe4e2be657572cf88c4230c3", | |
| build_file = "//bazel:linenoise.BUILD", | |
| ) | |
| _add_repo_if_not_existing( | |
| new_git_repository, | |
| name = "perfetto_dep_expat", | |
| remote = "https://github.com/libexpat/libexpat", | |
| commit = "fa75b96546c069d17b8f80d91e0f4ef0cde3790d", # R_2_6_2 | |
| build_file = "//bazel:expat.BUILD", | |
| ) | |
| _add_repo_if_not_existing( | |
| new_git_repository, | |
| name = "perfetto_dep_zlib", | |
| remote = "https://chromium.googlesource.com/chromium/src/third_party/zlib.git", | |
| commit = "6f9b4e61924021237d474569027cfb8ac7933ee6", | |
| build_file = "//bazel:zlib.BUILD", | |
| ) | |
| # Zstd, for the legacy WORKSPACE path (bzlmod uses the BCR module, see | |
| # MODULE.bazel). Upstream ships no Bazel BUILD (facebook/zstd#3123). | |
| _add_repo_if_not_existing( | |
| new_git_repository, | |
| name = "zstd", | |
| remote = "https://chromium.googlesource.com/external/github.com/facebook/zstd.git", | |
| commit = "ac66b19e6bd6b83238bf008eecc1298105298532", # refs/tags/upstream/v1.5.7 | |
| build_file = "//bazel:zstd.BUILD", | |
| ) | |
| _add_repo_if_not_existing( | |
| http_archive, | |
| name = "perfetto_dep_llvm_demangle", | |
| url = "https://storage.googleapis.com/perfetto/llvm-project-3b4c59c156919902c785ce3cbae0eee2ee53064d.tgz", | |
| sha256 = "f4a52e7f36edd7cacc844d5ae0e5f60b6f57c5afc40683e99f295886c9ce8ff4", | |
| strip_prefix = "llvm-project", | |
| build_file = "//bazel:llvm_demangle.BUILD", | |
| ) | |
| # Without this protobuf.bzl fails. This seems a bug in protobuf_deps(). | |
| _add_repo_if_not_existing( | |
| http_archive, | |
| name = "bazel_skylib", | |
| sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", | |
| urls = [ | |
| "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", | |
| "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", | |
| ] | |
| ) | |
| _add_repo_if_not_existing( | |
| new_git_repository, | |
| name = "perfetto_dep_open_csd", | |
| remote = "https://android.googlesource.com/platform/external/OpenCSD.git", | |
| commit = "0ce01e934f95efb6a216a6efa35af1245151c779", | |
| build_file = "//bazel:open_csd.BUILD", | |
| ) | |
| # RE2 regex library, used by perfetto's base::Regex backend. | |
| _add_repo_if_not_existing( | |
| git_repository, | |
| name = "re2", | |
| remote = "https://chromium.googlesource.com/external/github.com/google/re2.git", | |
| commit = "927f5d53caf8111721e734cf24724686bb745f55", | |
| ) | |
| # Abseil, required by RE2. | |
| _add_repo_if_not_existing( | |
| git_repository, | |
| name = "com_google_absl", | |
| remote = "https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp.git", | |
| commit = "76bb24329e8bf5f39704eb10d21b9a80befa7c81", | |
| ) | |
| def _add_repo_if_not_existing(repo_rule, name, **kwargs): | |
| if name not in native.existing_rules(): | |
| repo_rule(name = name, **kwargs) | |