Releases: bazelbuild/bazel-gazelle
Releases · bazelbuild/bazel-gazelle
v0.22.0
Changes
- The Go extension can now generate targets with a new naming convention.
- In new projects, by default, a library will be named
foo
if its import path ends withfoo
instead ofgo_default_library
. Similarly, a test will be namedfoo_test
instead ofgo_default_test
. - Gazelle will attempt to detect the naming convention used in existing projects, so it shouldn't unexpectedly change the naming convention.
- To specify the naming convention explicitly, use the
# gazelle:go_naming_convention
directive or the-go_naming_convention
flag. Valid values areimport
,go_default_library
, andimport_alias
. Gazelle will rename existing targets the next time it runs after a change. go_repository
uses theimport_alias
naming convention by default, so either the old or new names may be used.- Thanks to @tomlu for implementing this.
- In new projects, by default, a library will be named
- Added
# gazelle:go_generate_proto
directive, which instructs the Go extension whether to generatego_proto_library
rules forproto_library
generated by the proto extension (thanks @linzhp). - Improved Windows compatibility (thanks @tomlu).
- Language extensions can now provide dependency resolution for other extensions by implementing the
resolve.CrossResolver
interface. This is now used for resolve proto imports in Go (thanks @blico). - In the
update-repos
command, the-build_directives
flag may be used to set thebuild_directives
attribute on generated repositories (thanks @Helcaraxan). - In the
update-repos
command, new rules and macros will be inserted higher inWORKSPACE
, abovego_rules_dependencies
andgazelle_dependencies
if possible, to make it easier to override indirect dependencies.
Compatibility
gazelle_binary
no longer supports mode attributes such asgoos
,race
, andgotags
. These depended on internal implementation details in rules_go. If you need to build agazelle_binary
for a platform other than the host, use command-line flags such as--platforms
and--@io_bazel_rules_go//go/config:race
or use a transition.
WORKSPACE code
http_archive(
name = "bazel_gazelle",
sha256 = "d4113967ab451dd4d2d767c3ca5f927fec4b30f3b2c6f8135a2033b9c05a5687",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.0/bazel-gazelle-v0.22.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.0/bazel-gazelle-v0.22.0.tar.gz",
],
)
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
gazelle_dependencies()
v0.21.1
Bug fixes
- Fixed visibility for Go libraries in
internal
directories. Previously,
internal visibility was applied to packages in subdirectories ofinternal
,
directories, notinternal
directories themselves. Thanks to @robfig. go_repository
no longer runscat
, andgenrules
are replaced with native
rules to reduce dependence on msys2 on Windows. Thanks to @tomlu.- Cases in
select
expressions are no longer emitted for platforms that aren't
supported by the current version of rules_go.
v0.21.0
# gazelle:exclude
directives now accept patterns with*
and**
wildcards. (thanks @kalbasit)- The
-lang
flag may now be used to select which language extensions should be run. By default, all extensions Gazelle was built with will run. (thanks @robfig) - Attribute matching now works on string slice attributes, not just strings. This is now used to match
proto_library
rules with one or more sources in common with the generated rule, even if the rule has been renamed. (thanks @linzhp) - Many bugs have been fixed. Thanks to everyone who helped out!
v0.20.0
General changes
- When
update-repos
is invoked with-to_macro
, Gazelle will add a call to the macro and a# gazelle:repository_macro
directive to WORKSPACE if neither is present.
Go changes
- Gazelle will avoid generating duplicate
go_repository
rules when two module paths differ only in case. Thanks to @linzhp. - When deriving a repository name from an import path, all non-word characters will be replaced with underscores, not just dots and slashes. Consecutive non-word characters will be collapsed to a single underscore. Thanks to @carnott-snap.
- Imported repository rules are now sorted.
Proto changes
v0.19.1
Changes
- Rule names are now included in
go_repository
stderr output. - Environment variables
SSL_CERT_FILE
andSSL_CERT_DIR
are passed through to tools used bygo_repository
. - The list of standard packages is correctly updated for Go 1.13.
v0.19.0
General changes
- The
# gazelle:repository
directive is now supported in WORKSPACE files. Gazelle will behave as if a repository rule were declared with the given kind and attributes. This may override other declared rules. This is useful for declaring rules that appear in other files and can't be managed with#gazelle:repository_macro
. Thanks to @blico. - The
update-repos
command now accepts versions for each argument, for example,update-repos github.com/sirupsen/logrus@v1.4.0
. For Go, the version suffixes follow the same format thatgo get
accepts in module mode. Thanks to @weixiao-huang.
Go changes
go_repository
has better support for visibility across submodules. For example,cloud.google.com/logging
may now depend on internal packages incloud.google.com
, when both modules are unmodifiedgo_repository
rules. Previously, this requiredvisibility
attributes to be patched into the parent module.go_repository
now handles WORKSPACE-based configuration more efficiently. A configuration file is derived from the relevant parts of WORKSPACE and any functions declared with# gazelle:repository_macro
.go_repository
rules are re-evaluated when the configuration file changes, not when WORKSPACE changes. Previously, non-Go-related changes to WORKSPACE would causego_repository
to be re-evaluated. Thanks to @blico.go_repository
now accepts abuild_directives
attribute, a list of directives to write into the root build file before running Gazelle. Thanks to @linzhp.- The
# gazelle:go_visibility
directive may be used to add labels to visibility attributes of Go rules. Thanks to @linzhp. - Generated .go files are no longer included in
go_library
srcs
if they are consumed by another rule through thesrc
orsrcs
attributes. Thanks to @linzhp.
Proto changes
- Updated dependency resolution tables for know protos.
0.18.2
0.18.1
0.18.0
Compatibility
rules_go
0.19.0 or later is now required. Older versions are not supported but may still work, depending on what features are needed.
General changes
gazelle update-repos
now supports the flag-to_macro=file.bzl%macro
. Instead of writing new repository rules to WORKSPACE, rules will be written to a function in a separate .bzl file. This helps keep related rules together. Thanks to @blico!- The directive
# gazelle:repository_macro file.bzl%macro
may be used in WORKSPACE to declare a macro generated with the above flag.gazelle update-repos
will automatically update rules declared in the named macros instead of adding them to WORKSPACE. The directive may be repeated for multiple macros.gazelle fix
andgazelle update
will also read workspaces declared in these macros to find known repository roots and names. Thanks again to @blico! - The directive
# gazelle:exclude .
may now be written to skip updating the current directory and subdirectories. Previously,exclude
only applied to files and subdirectories.
Go changes
go_repository
can now download modules. To download a module, set theversion
andsum
attributes instead ofurls
(for HTTP) orcommit
ortag
(for VCS downloads).go_repository
will download and verify the specified module withgo mod download
. The environment variablesGOPROXY
,GOPRIVATE
,GONOPROXY
,GOSUMDB
, andGONOSUMDB
are observed, so be sure to set these for private modules when using go1.13 or later.gazelle update-repos <path>
will add or updatego_repository
rules in module mode.gazelle update-repos -from_file=go.mod
will also add or update rules in module mode.- Refactored infrastructure behind
go_repository
. There are now separate tools and cache workspaces. Modules are downloaded into the cache. When Gazelle is updated, it should not be necessary to re-download modules unless the implementation of the cache changes. The environment variableGO_REPOSITORY_USE_HOST_CACHE
may be set to1
to use$GOPATH/pkg/mod
as a module cache instead of the cache workspace. go_repository
now provides areplace
attribute in module mode, analogous toreplace
in a go.mod file. Theversion
andsum
attributes are used on the replacement, but build files will be generated with theimportpath
of the original module.gazelle update-repos -from-file=go.mod
will addreplace
attributes automatically (thanks to @bigkraig!).gazelle update-repos
now supports the flag-prune
, which may be used with-from_file
. When enabled, Gazelle will removego_repository
rules that no longer have equivalent repos in go.mod or Gopkg.lock. Thanks to @blico!- When run by
go_repository
, Gazelle now supports minimal module compatibility. For v2+ modules, Gazelle will generateimportpath_aliases
attributes sogo_libraries
may be imported without the semantic import version suffix by non-modularized packages.
Proto changes
- Updated table of known proto import paths for consistency with rules_go 0.19.0.
0.17.0
Language agnostic changes
- The
# gazelle:map_kind
directive can now be used to generate rules of
alternative kinds. For example, instead of generatinggo_binary
rules,
you could generate a call to a macro that takes the same arguments
(for example,go_image
,go_deployable
). Thanks to @robfig! - Gazelle exits with status 1 when run with
-mode=diff
when there are
differences. Thanks to @mjduijn and @achew22! - Hidden directories are included when walking the directory tree. Thanks to
@linzhp.
Go changes
go_repository
now works with Go 1.12.- The
update-repos
command now lets you set attributes such as build file
names and proto modes on the command line. Thanks to @blico! - Alternative compilers can now be set on
go_proto_library
rules with the
-go_proto_compiler
and-go_grpc_compiler
flags. Thanks to @bartle-stripe! - Go repositories may now be imported from Godep. Thanks to @GauntletWizard!
- Imports that can't be resolved using the index when the index is enabled
are now resolved as external, even if they're under the current prefix.
This is necessary to handle cases where one repository path is a prefix
of another. Thanks to @linzhp!
Proto changes
- The new
proto_library
attributesimport_prefix
andstrip_import_prefix
may be set with the# gazelle:proto_import_prefix
and
# gazelle:proto_strip_import_prefix
directives or the-proto_import_prefix
command line argument. Thanks to @blico!