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

Select usage example for refresh_compile_commands #186

Open
dambrosio opened this issue May 6, 2024 · 1 comment
Open

Select usage example for refresh_compile_commands #186

dambrosio opened this issue May 6, 2024 · 1 comment

Comments

@dambrosio
Copy link

Creating a ticket based on a recent comment in a past closed ticket.

Was wondering if there is example usage for refresh_compile_commands with a targets select. As stated in the mentioned comment, I am a Bazel n00b so it might not be possible.

Fundamentally I am looking for a way to pass an argument (target package) to the root refresh_compile_commands.

Something like:

# BUILD

config_setting(
    name = "refresh_comp_cmds_target",
    values = {"define": "target="},
)

refresh_compile_commands(
    name = "refresh_comp_cmds",
    targets = select({
        ":refresh_comp_cmds_target": {"$(target)": ""},
        "//condition:default": {"//...": ""},
    }),
)

With command line usage of:
bazel run :refresh_comp_cmds --define target=//my_pkg:my_target.

When I try the above I run into the following error:

ERROR: Traceback (most recent call last):
        File "/.../BUILD", line 21, column 25, in <toplevel>
                refresh_compile_commands(
        File "/.../external/hedron_compile_commands/refresh_compile_commands.bzl", line 82, column 37, in refresh_compile_commands
                for target, flags in targets.items()
Error: 'select' value has no field or method 'items'

Please let me know if moving the comment to a ticket was acceptable.

Appreciate the help and cheers!

@neko-para
Copy link

neko-para commented Jun 13, 2024

I've encountered a similar situation. My target doesn't recognize the passed config and failed for missing matching condition.


@dambrosio
It's my problem. According to document, there should be an extra -- before argument for target.

bazel run :refresh_comp_cmds -- --define target=//my_pkg:my_target
                             ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants