bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
22.94k stars 4.02k forks source link

Support --compile_one_dependency in Starlark #13419

Closed phst closed 1 month ago

phst commented 3 years ago

ATTENTION! Please read and follow:

  • if this is a question about how to build / test / query / deploy using Bazel, or a discussion starter, send it to bazel-discuss@googlegroups.com
  • if this is a bug or feature request, fill the form below as best as you can.

Description of the problem / feature request:

--compile_one_dependency officially works only for built-in rules. Starlark rules can pass attr.label_list(flags = ["DIRECT_COMPILE_TIME_INPUT"]), but that is undocumented and doesn't work for single-label attributes (attr.label doesn't have a flags parameter). It would be great to give attr.label and attr.label_list an officially-supported parameter like direct_compile_time_input = True/False.

Feature requests: what underlying problem are you trying to solve with this feature?

I'm trying to write a Starlark rule that has rough feature parity with the builtin rules, including support for --compile_one_dependency.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Create a Starlark rule with an attribute like "srcs": attr.label_list(). Use that rule in some BUILD file. Try running bazel build --compile_one_dependency source-file. Bazel will print an error like "Couldn't find dependency on target …".

What operating system are you running Bazel on?

GNU/Linux (but this is OS-independent).

What's the output of bazel info release?

release 4.0.0

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

N/A

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

N/A

Have you found anything relevant by searching the web?

I searched through GitHub issues for this repository, but found nothing related. https://github.com/bazelbuild/bazel/blob/09c621e4cf5b968f4c6cdf905ab142d5961f9ddc/src/test/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformerTest.java#L75 is an example that "documents" the current support.

brandjon commented 3 years ago

What does this block? What rule are you trying to create or migrate?

@comius FYI.

phst commented 3 years ago

In this case I've been using the workaround for my Emacs Lisp rules (https://github.com/phst/rules_elisp/commit/66ad6e257e083323a49a14f55016c37346eb17fb). It doesn't really block anything, it would just be nice to officially support this in Starlark to bring Starlark-written rules on par with native ones.

comius commented 1 year ago

We will remove --compile_one_dependency from Bazel. Thus, we will not provide functionality for it in Starlark.

github-actions[bot] commented 4 months ago

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

github-actions[bot] commented 1 month ago

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post @bazelbuild/triage in a comment here and we'll take a look. Thanks!