bazelbuild/bazel

Add `bazel init` to setup new workspaces

Open

#15,604 建立於 2022年6月1日

在 GitHub 查看
 (8 留言) (14 反應) (0 負責人)Java (4,465 fork)batch import
P3help wantednot staleteam-OSStype: feature request

倉庫指標

Star
 (25,384 star)
PR 合併指標
 (平均合併 22天 20小時) (30 天內合併 77 個 PR)

描述

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.

貢獻者指南