bazelbuild/bazel

Add `bazel init` to setup new workspaces

Open

#15.604 aperta il 1 giu 2022

Vedi su GitHub
 (8 commenti) (14 reazioni) (0 assegnatari)Java (4465 fork)batch import
P3help wantednot staleteam-OSStype: feature request

Metriche repository

Star
 (25.384 star)
Metriche merge PR
 (Merge medio 22g 20h) (77 PR mergiate in 30 g)

Descrizione

Description of the feature request:

Add a bazel init command that sets up a skeleton Bazel workspace for new projects. It could create WORKSPACE, BUILD.bazel, .bazelrc and maybe others, using a template that applies modern best practices.

The init command is popular in other tools. E.g.,

  • git init - create a new git repo
  • npm init - create a new npm package
  • poetry init - create a new Poetry (python) package
  • cargo init - create a new Cargo (rust) package

What underlying problem are you trying to solve with this feature?

New users often get tripped up by environment variables leaking into their builds and invalidating caches. The --incompatible_strict_action_env flag has existed for years and often solves the problem, but it is disabled by default due (I think) to not being compatible with many existing workspaces.

Arguably --incompatible_strict_action_env should be enabled by default, as well as a variety of other flags for correctness, performance, and dev experience detailed in this post. bazel init would offer a place to put these more recent, incompatible flags for use in new repos, and also provide a skeleton to help new users get started.

Guida contributor