Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repos.bzl refers to repositories before they're defined #42

Open
CodingCanuck opened this issue Apr 28, 2022 · 1 comment
Open

repos.bzl refers to repositories before they're defined #42

CodingCanuck opened this issue Apr 28, 2022 · 1 comment

Comments

@CodingCanuck
Copy link
Contributor

Stout's repos.bzl refers to other repos' repos.bzl files by using a repository label, e.g. the use of @com_github_3rdparty_stout_atomic_backoff in:

load("@com_github_3rdparty_stout_atomic_backoff//bazel:repos.bzl", stout_atomic_backoff_repos = "repos")

This works because stout's WORKSPACE.bazel file defines these repo labels before they're used, e.g.:

local_repository(
    name = "com_github_3rdparty_stout_atomic_backoff",
    path = "stout-atomic-backoff",
)

But this does not work when using stout in another repo by following the advice on https://github.com/3rdparty/stout#bazel to call stout's repos.bzl from the other repo's repos.bzl: in order for this to work, we need to avoid referring to already-defined repo labels in our repos.bzl file.

Other repositories accomplish this by not referring to repos.bzl files in dependencies' labeled repos, but instead copying those repos.bzl files into a 3rdparty top-level folder e.g. https://github.com/3rdparty/eventuals/blob/main/bazel/repos.bzl#L15-L18 :

load("//3rdparty/bazel-rules-asio:repos.bzl", asio_repos = "repos")
load("//3rdparty/bazel-rules-curl:repos.bzl", curl_repos = "repos")
load("//3rdparty/bazel-rules-jemalloc:repos.bzl", jemalloc_repos = "repos")
load("//3rdparty/bazel-rules-libuv:repos.bzl", libuv_repos = "repos")

I suspect we should follow the same pattern here.

Concretely, I think we should remove all repo references in the style of @repo_name from our repos.bzl file (except @bazel_tools which seem both safe and commonly used across repos) and instead add new subfolders of 3rdparty/ for each repo.

@CodingCanuck
Copy link
Contributor Author

From a chat with @benh this issue might have it backwards: we might be moving away from this pattern of repos.bzl and this new style might in fact be the way forward!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant