bazelbuild/bazel

Documentation genrule example - maybe avoid $(location ..) or $(locations ..)

Open

#15,078 创建于 2022年3月18日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)Java (4,465 fork)batch import
P3help wantedteam-Documentationteam-Rules-Servertype: documentation (cleanup)

仓库指标

Star
 (25,384 star)
PR 合并指标
 (平均合并 22天 20小时) (30 天内合并 77 个 PR)

描述

Description of the problem / feature request:

https://docs.bazel.build/versions/main/be/general.html#genrule_examples

Elsewhere I've seen that we're not supposed to be using $(location) calls and should instead be using $(rootpath ..) or $(execpath ..)

https://github.com/bazelbuild/bazel/issues/2475#issuecomment-339318016

I just spent hours debugging why a genrule of mine didn't work, when it wasn't exactly clear from the example that

  1. We shouldn't be using $(location ..)
  2. That $(location ..) can return different things in Skylark depending on srcs vs other generated outs.

Maybe this is clear for people who've been in Bazel for years and are aware of the changes to all make-style vars.

贡献者指南