Skip to content

Releases: bazel-contrib/bazel-gazelle

0.18.1

16 Jul 22:51
8a0f108
Compare
Choose a tag to compare
0.18.1 Pre-release
Pre-release

This release is a quick fix to address an issue with go_repository on Windows.

0.18.0

16 Jul 21:04
aa5b862
Compare
Choose a tag to compare
0.18.0 Pre-release
Pre-release

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 and gazelle 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 the version and sum attributes instead of urls (for HTTP) or commit or tag (for VCS downloads). go_repository will download and verify the specified module with go mod download. The environment variables GOPROXY, GOPRIVATE, GONOPROXY, GOSUMDB, and GONOSUMDB are observed, so be sure to set these for private modules when using go1.13 or later.
  • gazelle update-repos <path> will add or update go_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 variable GO_REPOSITORY_USE_HOST_CACHE may be set to 1 to use $GOPATH/pkg/mod as a module cache instead of the cache workspace.
  • go_repository now provides a replace attribute in module mode, analogous to replace in a go.mod file. The version and sum attributes are used on the replacement, but build files will be generated with the importpath of the original module. gazelle update-repos -from-file=go.mod will add replace attributes automatically (thanks to @bigkraig!).
  • gazelle update-repos now supports the flag -prune, which may be used with -from_file. When enabled, Gazelle will remove go_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 generate importpath_aliases attributes so go_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

27 Feb 18:39
e443c54
Compare
Choose a tag to compare
0.17.0 Pre-release
Pre-release

Language agnostic changes

  • The # gazelle:map_kind directive can now be used to generate rules of
    alternative kinds. For example, instead of generating go_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 attributes import_prefix and strip_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!

0.16.0

10 Jan 00:31
cdeedbd
Compare
Choose a tag to compare
0.16.0 Pre-release
Pre-release

Changes

  • gazelle_binary is a new rule that allows developers to support new languages. To support a new language, you may:
    • Create a go_library that defines a function named NewLanguage that returns a value assignable to language.Language.
    • Create a gazelle_binary target that depends on your go_library and other language extensions through the languages attribute.
    • Reference your gazelle_binary target through the gazelle attribute of the gazelle rule.
    • See Extending Gazelle for more information.
  • Most Go packages in this repository are now public. You can now use rule and other libraries to write your own tools that manipulate build files.
  • Gazelle's git_repository and http_archive rules are deprecated. You should migrate to Bazel's git_repository and http_archive instead.
  • Gazelle will visit directories whose names start with _. Previously these were considered hidden, but go build allows directories with these names to be imported (even if they don't match wildcards). In the next release, directories whose names start with . will also be visited.

0.15.0

16 Oct 21:24
Compare
Choose a tag to compare
0.15.0 Pre-release
Pre-release

Changes

  • Gazelle can now import dependencies from go.mod files into WORKSPACE with gazelle update-repos -from_file=go.mod. This includes transitive dependencies not explicitly mentioned in go.mod.
  • cmd/autogazelle - an experimental new tool for running Gazelle as part of each Bazel command. See the README for details.
  • New directives:
    • # gazelle:follow symlink - follow a specific symlink to a directory. Gazelle normally ignores symbolic links to directories within a repository to avoid visiting a directory on more than one path. When using this, take care to # gazelle:exclude the directory from its actual parent to prevent this from happening.
    • # gazelle:resolve source-lang import-lang import-string label - specifies an explicit mapping from an import string to a label for dependency resolution.
  • New command-line options:
    • -r=true - controls whether Gazelle updates build files recursively in directories mentioned on the command line. True by default.
    • -index=true - controls whether Gazelle indexes library rules in the repository and uses the index to resolve imports to Bazel labels. True by default.
  • The go_repository rule now accepts patches and commands in the same format as git_repository and http_archive from @bazel_tools. Patches are applied after Gazelle is run (if it is run).
  • The fix and update commands can write patch files with -mode=patch.
  • The gazelle rule can now append to the command line argument list (instead of replacing it) if the arguments are prefixed with -args. For example, bazel run //:gazelle -- -args -index=false -r=false internal/label.
  • The gazelle rule now works on Windows.

0.14.0

08 Aug 17:01
6a1b93c
Compare
Choose a tag to compare
0.14.0 Pre-release
Pre-release

Changes

  • No major feature changes -- this is primarily a maintenance release.
  • Experimental: the command line flags -experimental_read_build_files_dir and -experimental_write_build_files_dir may be used to read and write build files from alternate directories, which may be outside the repository root. If a file is read from a different directory, build files in the source tree are ignored. If a file is written to an alternate directory, build files in the source tree are not modified. These flags may change in the future.

0.13.0

10 Jul 17:21
b10e7be
Compare
Choose a tag to compare
0.13.0 Pre-release
Pre-release

Features

  • Completed a major refactoring of Gazelle. All language-specific logic has moved into extensions that implement the internal/languages.Language interface. go and proto are now supported through separate extensions. This will enable Gazelle to support more languages in the future.
    • If you're interested in extending Gazelle, please file an issue or get in touch with me directly.
  • Added special cases for proto dependency resolution, both for Go and proto imports. Imports of Google APIs will now resolve to the new @go_googleapis repository.
    • There were already special cases for Well Known Types. That logic is modified and extended.
  • Added two new proto modes. These can be set with the -proto=mode flag on the command line or the # gazelle:proto mode directive in build files or with build_file_proto_mode = "mode" in go_repository.
    • disable_global - Like disable mode, Gazelle won't generate, update, or delete existing proto_library or go_proto_library rules. In addition, special cases for proto dependency resolution (for Well Known Types and Google APIs) are disabled. This is useful if you build libraries using pre-generated .pb.go files and don't want any build-time dependency on protoc.
    • package - Gazelle may generate proto_library and go_proto_library rules for multiple packages in the same directory. .proto files are grouped into packages using either the declared proto package or an option specified by # gazelle:proto_group opt, e.g., go_package.
  • The git_repository and http_archive no longer rely on a cp executable to copy files. This improves Windows compatibility (thanks @pmuetschard).
  • Several more fixes related to paths for Windows compatibility (thanks @pmuetschard).
  • race and msan tags are now ignored. Sources files will be included in rules whether these flags are true or false.

0.12.0

08 May 19:42
7f30ba7
Compare
Choose a tag to compare
0.12.0 Pre-release
Pre-release

Changes

  • importmap is now a mergeable attribute. This means Gazelle may now replace
    existing importmap attributes if they are not marked with a # keep
    comment.
  • gazelle fix no longer removes importpath attributes on go_binary
    and go_test rules. These attributes are no longer deprecated. The rules
    are still not importable, but the paths are useful for go_path and
    other rules.
  • Go imports of proto Well Known Types are now resolved to rules in
    @io_bazel_rules_go//proto/wkt. This partially worked before, but several
    packages weren't handled correctly.

Notes

  • rules_go will soon stop declaring the @bazel_gazelle repository, probably
    in the next rules_go major release. If you aren't explicitly declaring
    @bazel_gazelle in your WORKSPACE, following the template at
    Running Gazelle with Bazel, you may want to migrate soon.

0.11.0

17 Apr 14:45
8bc6a86
Compare
Choose a tag to compare
0.11.0 Pre-release
Pre-release

New features

  • Gazelle now generates a single go_test target when both internal and
    external test sources are present. This allows external tests to depend on
    definitions within internal tests. gazelle fix will squash or rename
    existing rules named "go_default_xtest".
  • srcs attributes are now flat: they will no longer contain platform-specific
    select expressions. rules_go will filter sources with build constraints
    automatically. This allows broader usage of the goos and goarch attributes
    in go_binary, but there are still problems with select in deps. See the
    cross-compile FAQ
    for more information.
  • importmap attributes are added for go_library and go_proto_library rules
    in vendor directories. This prevents conflicts when multiple packages with
    the same importpath are linked into the same binary.
  • Proto imports of Well Known Types are now resolved to standard locations in
    @io_bazel_rules_go//proto/wkt.
  • go_repository now supports a build_extra_args attribute, allowing
    additional arguments to be passed to Gazelle during build file generation.
  • gazelle update-repos will now load go_repository from @bazel_gazelle.
    The old copy in @io_bazel_rules_go is deprecated. gazelle fix will also
    fix this.

Notes

  • The minimum compatible version of rules_go is now 0.11.0. This is primarily
    due to the need for importmap on go_proto_library. Older versions may
    work if you're not using protos.

0.10.1

23 Mar 23:04
Compare
Choose a tag to compare
0.10.1 Pre-release
Pre-release
  • github.com/bazelbuild/buildtools is now vendored within Gazelle, due to breaking API changes upstream.
  • Gazelle now dereferences symlinks in the repository root directory (-repo_root). This fixes a bug where Gazelle incorrectly decided other symlinks pointed outside the repository.