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.

贡献者指南