Replies: 13 comments 34 replies
-
|
Tagging active maintainers of open source Gazelle extensions:
Please tag anyone else you think might be interested! |
Beta Was this translation helpful? Give feedback.
-
|
Overall I these changes seem pretty reasonable to me. I like the Resolver/Indexer split.
I welcome this change, though I'd like to know more about the
Sounds like this should simplify things 👍.
To clarify: Will the the bazel-contrib/bazel-gazelle maintainers continue to provide protobuf target generation support via I assume that all Footnotes
|
Beta Was this translation helpful? Give feedback.
-
|
@dougthor42 Responding to this in a separate thread:
For now, there are no plans to change ownership or write a new extension here. Gazelle will continue to maintain the current extension unless someone's interested in taking ownership and moving it elsewhere.
Yes. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @jayconrod I'm excited to see this better factoring, especially re: protobuf support.
I'd be interested in implementing this interface e.g. to better support bundled/unbundled TypeScript generation for stairwell.com internal tools. Can you say more about the difference between the two indexing results: ImportResult{
Imports: nil,
NotImportable: false,
}
// and...
ImportResult{
Imports: []ImportSpec{{Lang: "typescript", Imp: "my/module/index"}},
NotImportable: true,
} |
Beta Was this translation helpful? Give feedback.
-
|
WDYT about dropping WORKSPACE support? Is that an option in the rules_go ecosystem yet? I will be dropping (or not actively testing+supporting) WORKSPACE in all the js related rulesets as well as gazelle language implementations. |
Beta Was this translation helpful? Give feedback.
-
|
How about moving go specific things like |
Beta Was this translation helpful? Give feedback.
-
Is there an alternative solution proposed here? There are cases where folks would like to use the protos which came from the go_repository, but with their own proto compiler. |
Beta Was this translation helpful? Give feedback.
-
|
For Gazelle 2.0 I would like to see Other languages do this as well (Java |
Beta Was this translation helpful? Give feedback.
-
|
My take on the new extension interfaces: The number one challenge in implementing a Gazelle extension is that the author would have to learn and maintain Go code. This is not addressed in the current proposal. The extensions are usually created to support other language ecosystems: python, java, cc, swift, etc... and realistically, they often have to use a shim Go code that would eventually shell out to a side-car process that was written in a different language. So at the very least, I would expect that we can come up with a solution that makes this effort a bit easier to work with. Nit: why are we adding context to the custom args structs?
|
Beta Was this translation helpful? Give feedback.
-
|
From #2232, |
Beta Was this translation helpful? Give feedback.
-
|
@sluongng mentioned this, but my biggest feedback is the If the signature is (cc @linzhp) We may want a way to make |
Beta Was this translation helpful? Give feedback.
-
|
@jayconrod, I have a suggestion regarding error handling, which came to my mind when working on EngFlow/gazelle_cc#157
So instead of: type Merger interface {
Merge(other bzl.Expr) bzl.Expr
}There should be: type Merger interface {
Merge(other bzl.Expr) (bzl.Expr, error)
}Things are getting clear now. A potential error is passed up into the |
Beta Was this translation helpful? Give feedback.
-
|
I'm preparing the initial set of changes for v2, but I could use some feedback on how modules and releases should be structured, going forward. There are two major alternatives on how to accomplish this. I'm leaning toward the subdirectory alternative. Subdirectory alternative
This makes use of Go's module subdirectories feature, which was meant to smooth the GOPATH migration. It allowed Branch alternative
For both alternatives
Comparison
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Purpose
This proposal collects ideas for a v2 release of Gazelle. This release decouples the extension interfaces to improve forward compatibility and to make extensions more flexible and powerful. It also removes legacy functionality, changes default behaviors, and completely moves Go and protobuf functionality into extensions.
We usually strive to maintain compatibility as much as possible. Incompatible changes require migration effort from users and extension authors, which is rarely an enjoyable task. However, legacy functionality and early design mistakes cost time and effort too, and sometimes incompatible changes are worth the migration effort.
To keep the v2 release small and tractable and to a avoid a v3 release within the next several years, we're focusing only on incompatible changes that we anticipate are necessary. New features that don't require incompatible changes may be proposed and implemented separately, either in v1 or v2.
Proposed changes
Extension interfaces
The Gazelle language interface is decomposed into a cleaner set of interfaces. An extension may implement any subset of interfaces.
Most methods can now return an
error. Multiple errors may be returned together witherrors.Join. In most cases, an extension should return "best effort" results together with an error. Gazelle may report the error to the user as a printed warning, or it may exit quickly but gracefully, depending on whether the-strictflag is used. Extensions should not callos.Exitorlog.Fataland should avoid panicking when possible.Most methods now also support cancellation with
context.Context. This should be useful for extensions that communicate on the network or interact with external processes. When the user interrupts Gazelle by pressing^C, Gazelle should shut down quickly and gracefully.More methods now have arguments and return values wrapped in struct types. New fields may be added to these structs in the future, effectively adding parameters or return values without further breaking compatibility.
config.Configurer.Configurerparses directive comments in build files and applies them to the configuration for the current directory.RegisterFlagsandCheckFlagsmethods are removed. Extensions are no longer able to register command-line flags. All configuration must be done with directives.Configurenow returnserror.resolve.IndexerIndexerextracts the strings by which a library may be imported.Indexeris split from the v1 interfaceresolver.Resolver.ImportsandEmbedsmethods are combined. Most languages don't need anything likeEmbeds, so it's easier to ignore.Importsnow accepts a context for cancellation.Importscan now return an error.resolver.ResolverResolverperforms dependency resolution and modifies a rule, typically by setting its"deps"attribute.Resolveris split from the v1 interface of the same name.Namemethod may be dropped, if possible. It's mostly used to ensureImportsandResolveare called using the same extension that generated a rule, but Gazelle can track that internally.*repo.RemoteCacheparameter is dropped. It's only used by Go and shouldn't actually be used anymore at all.Resolvenow accepts a context for cancellation.Resolvecan now return an error.language.GeneratorGeneratorgenerates rules to be merged into a new or existing build file.Generatoris split from thelanguage.Languageinterface.Loadsmethod andModuleAwareLanguageinterface are dropped. These were used to declare which.bzlfile a symbol could be loaded from. We can add this torule.KindInfoinstead.Generatenow accepts a context for cancellation.Generatecan now return an error.language.FixerFixercan make arbitrary changes to a build file, beforegenerator.Generateis called. Typically, it's used to migrate away from deprecated functionality in old rule sets.Fixeris split fromlanguage.Language.Fixnow accepts a context for cancellation.Fixcan now return an error.Life cycle hooks
These interfaces let extensions expose methods to be called at certain times during Gazelle's execution. Each method is called once, globally.
language.FinishableLanguageandlanguage.LifecycleManager.NOTE: The main use case for these methods is starting and stopping external processes. Gazelle would call the methods here at different times than it currently calls
Before,DoneGeneratingRules, andAfterResolvingDeps. If you have a use case not satisfied byOnStartandOnFinish, please let us know. We may add more interfaces here for hooks called at differen times.Compatibility
Gazelle v2 is backward compatible with extensions written against the v1 interfaces, so it's possible to use an existing extension without migration. Gazelle v1 is also forward compatible with extensions written against the v2 interfaces, so it's possible to use newer extensions without losing legacy functionality.
Each extension package must provide either or both of the following functions. Gazelle calls one of these to load the extension.
The call is generated by the
gazelle_binaryrule, which can inspect the extension's source code to determine which function to call.Gazelle v1 prefers to call
NewLanguage() language.Language, and Gazelle v2 prefers to callNewV2() any, but both versions are aware of both functions, and an extension only needs to implement one. Both Gazelle v1 and v2 can call the "wrong" function and wrap the result with an adapter.If a v3 release is necessary in the future, we expect to support a
NewV3() anyfunction with suitable adapters as well.Command Line Interface
-index=lazyis the new default, and when Gazelle has at least one positional argument,-r=falseis set by default. This should let users update specific build files much more quickly, but it requires coordination from language extensions.-build_file_name-build_tags-exclude-external-go_grpc_compiler-go_naming_convention-go_naming_convention_external-go_prefix-go_proto_compiler-known_import-proto-proto_group-mode=diffand-patch.-experimental_read_build_files_dir-experimental_write_build_files_dirupdate-repossubcommand is dropped. The purpose of this command was to managego_repositorydeclarations inWORKSPACE. It's no longer needed forMODULE.bazelfiles. It never supported other languages.go_repositorygo_repositoryshall only generate Go targets.build_file_generation = "clean"). If a dependency already has working build files, it should be depended on as a Bazel module. Thebuild_file_generationattribute is removed.GOPATHsupport. Thecanonical_id,commit,tag,vcs,remote,urls,strip_prefix,type, andsha256attributes are removed.build_external,build_file_name,build_naming_convention,build_tags,build_file_proto_mode, andbuild_extra_args. Usebuild_directivesinstead.Other incompatible changes
//language/go, or a package nested within that directory. These extensions are no longer special.github.com/bazelbuild/bazel-gazelletogithub.com/bazel-contrib/bazel-gazelle/v2, reflecting both the new major version (required by Go) and Gazelle's new home withinbazel-contrib.gazelleBazel module name remains the same. Users don't need to updateMODULE.bazelfiles, aside from selecting a new version.Wait, what about Gazelle 1.0?
The current version of Gazelle is 0.45.0. We'll tag 1.0.0 soon without including any incompatible changes.
Under semantic versioning, we could make incompatible changes without incrementing the major version, as long as we do so under v0. However, Gazelle has been maintaining compatibility for years now, so truthfully, we should have tagged 1.0.0 long ago. We'll tag 1.0.0 belatedly, then use 2.0.0 to mark the actual imcompatible changes.
Beta Was this translation helpful? Give feedback.
All reactions