-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Return values in module extensions #17048
Comments
@Wyverald I can't appear to assign the feature request to you, but since it's a module extension FR I assume you should be the one triaging? |
Previous discussion on this topic: https://gist.github.com/fmeum/c87c183ad6ffc55add0ca04232761ea1
can't quite work since tags in But as far as I understand the implementation, a tag could "return" an opaque object that I am more and more convinced that we essentially get to choose between:
I would personally prefer 2): Module extensions already have access to all the API and deps information needed to manage external deps without additional, external tooling. Gazelle and other similar tools only operate on the syntax of |
@matts1 The pattern we've been recommending is to use a "hub" repo that contains This obviously doesn't work if the satellite repos have a lot of targets in them (which would mean that the hub contains the sum total of all targets in the satellite repos), which is unfortunately the case with rules_go. I don't have a good solution for this.
The problem with that is we'd need to run all module extensions to resolve repo mappings for any given repo. Currently, the repo mapping of a non-module-extension-generated repo can be calculated from parsing MODULE.bazel files, without running any extensions. If we were to have something like
That may not be a bad thing -- we also recommend against extensive usage of Starlark in BUILD files. |
That's a very good point, I didn't think about the implications for extension evaluation. I thought about alternative solutions and had an idea: How about having a Bazel module @matts1 Do you think something like that could work for rules_rust? |
I created |
I don't think we need it for rules_rust - rules_rust should work just fine with the hub-and-spoke model that @Wyverald suggested, as it already is capable of generating spoke repos and a centralized build file that aliases to them, given the right configuration. |
This is addressed by https://docs.google.com/document/d/1dj8SN5L6nwhNOufNqjBhYkk5f-BJI_FPYWKxlB3GAmA/edit. The API will be available in 6.2.0. |
This uses the new isolated module extensions feature [1], instead of a hub-repository approach [2] [3], to distinguish globally unified repositories and locally specialized repositories. [1]: bazelbuild/bazel#18529 [2]: bazelbuild/bazel#17048 [3]: bazelbuild/bazel#17493
Description of the feature request:
Allow a module extension to return a value:
What underlying problem are you trying to solve with this feature?
If a module extension returns a large number of git repositories, it becomes infeasible to use_repo on each one individually.
Here's an example:
In this example, we need to specify the dependencies once in the go.mod file, and once again in the MODULE.bazel file. I've tested, and the following does appear to work:
Would it be possible to support the following:
This would allow go.mod to be our source of truth for go repositories (and would allow other languages to do the same).
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?release 6.0.0-pre.20221012.2
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?Have you found anything relevant by searching the web?
Python appears to take an alternative approach where they write every package to a single repository. This would be a theoretically possible alternative, but:
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: