Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cquery --output=files ignores source files #16599

Closed
illicitonion opened this issue Oct 28, 2022 · 4 comments
Closed

cquery --output=files ignores source files #16599

illicitonion opened this issue Oct 28, 2022 · 4 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability Issues for Configurability team type: bug

Comments

@illicitonion
Copy link
Contributor

Description of the bug:

I try to use bazel cquery --output=files to replace bazel run --run_under=echo in order to find the path to files which may later be run (or e.g. passed as arguments to other scripts).

Sometimes this is for complex targets, e.g. an alias where on some platform we use a pre-built binary and on another we build a binary, e.g. something like:

alias(
    name = "my_binary",
    actual = select({
        "//some:condition": ":prebuilt_file_for_some_platform",
        "//some/other:condition": ":build_a_binary",
    }),
)

However, bazel cquery --output=files :my_binary ignores source files because of this filtering.

I think there should be a way to ask bazel "what file(s) does this resolve to?", regardless of whether the file is generated or checked in.

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

% touch WORKSPACE && touch prebuilt && chmod 0755 prebuilt && echo 'exports_files(["prebuilt"])' > BUILD.bazel && bazel cquery --output=files :prebuilt 2>/dev/null

Expect to see prebuilt output, but actually see nothing.

Which operating system are you running Bazel on?

macOS

What is the output of bazel info release?

release 5.3.2

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

No response

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

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

/cc @fmeum @gregestren

@fmeum
Copy link
Collaborator

fmeum commented Oct 28, 2022

This was done to mimic the output of bazel build <target>, but I agree that having this functionality would be very useful, not just for complex select statements but already for simple filegroups.

I'm actually thinking this may make for a better default. In hindsight, doing what bazel build <target> did may not have been the right choice as "what are all the files offered by this target?" is a very different question from "what did Bazel just build?".

@gregestren What do you think, could we mimic --starlark:expr and add a flag similar to --files:include_source_files and, perhaps, even include the files by default?

@fmeum
Copy link
Collaborator

fmeum commented Oct 28, 2022

I created #16602 with a proposal for an implementation. It is not touching the default value.

@illicitonion Could you check whether that PR works as expected in more realistic scenarios?

@illicitonion
Copy link
Contributor Author

That works perfectly for my use-cases - thanks so much!

@sgowroji sgowroji added type: bug team-Configurability Issues for Configurability team untriaged labels Oct 28, 2022
@gregestren gregestren added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Dec 5, 2022
@gregestren
Copy link
Contributor

Fixed by #16602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability Issues for Configurability team type: bug
Projects
None yet
Development

No branches or pull requests

4 participants