blob: 1e1307472621a144540999adb06236893f630b2b [file]
# Copyright 2023 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
def _chromite_impl(repo_ctx):
# Callers can use checked-out Chromite by invoking bazel with
# `USE_PINNED_CHROMITE=false`
use_pinned_chromite = repo_ctx.os.environ.get("USE_PINNED_CHROMITE") not in ["false", "False"]
if use_pinned_chromite:
repo_ctx.download_and_extract(
url = "https://storage.googleapis.com/chromeos-localmirror/chromite-bundles/chromite-20240716_155425-a379f4a61652f5a60d8025abb1a79ff9bddb6a07.tar.zst",
sha256 = "7ee2a4cfa9bb87e6ad19cb2bb6f1081329e48730df18f29af570812065c28516",
)
else:
# While most repo rules would inject BUILD.project-chromite during the repo
# rule, since we perform a symlink, doing so would add it to the real
# chromite directory.
realpath = str(repo_ctx.workspace_root.realpath).rsplit("/", 1)[0]
out = repo_ctx.path(".")
repo_ctx.symlink(realpath + "/chromite", out)
chromite = repository_rule(
implementation = _chromite_impl,
environ = ["USE_PINNED_CHROMITE"],
)