Is there a way to bazel run args for executable in DefaultInfo?

766 views
Skip to first unread message

carpen...@gmail.com

unread,
Jul 30, 2021, 7:10:59 AM7/30/21
to bazel-discuss
On Windows, I have an executable rule which returns an executable in its default info. I would like to be able to return the commandline arguments to pass to that executable when you call bazel run. This executable is just a py_binary that gets passed into the rule, generating the commandline from the rule is the important bit. 

What I want is the equivilant of passing in args as an attribute when you declare a target based on that rule. 

I can write a batch file, and get it to call my binary, but for that to work I always need to pass --run_under=cmd which doesn't give an elegant interface. 

Background info, what I want to do eventually is `bazel run //subasset:publish_outputs` and have the rule take care of all the dependency management and publishing parameters

Thanks


Yannic Bonenberger

unread,
Jul 30, 2021, 3:20:39 PM7/30/21
to carpen...@gmail.com, bazel-discuss
You can pass them on the command-line if you add -- as seperator betwee
Bazel flags/the target and the options to pass to the executable.

Example: bazel run @com_google_protobuf//:protoc --compilation_mode=opt -- —help

---

EngFlow GmbH
Fischerweg 51, 82194 Gröbenzell, Germany
Amtsgericht München, HRB 255664
Geschäftsführer: Ulf Adams
https://www.engflow.com


Am 30.07.2021 um 21:18 schrieb Yannic Bonenberger <yan...@engflow.com>:

You can pass them on the command-line if you add -- as seperator betwee
Bazel flags/the target and the options to pass to the executable.

Example: bazel run @com_google_protobuf//:protoc --compilation_mode=opt -- --help


---

EngFlow GmbH
Fischerweg 51, 82194 Gröbenzell, Germany
Amtsgericht München, HRB 255664
Geschäftsführer: Ulf Adams
https://www.engflow.com

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/42569e9d-f9c7-4375-8360-b405a90f233en%40googlegroups.com.


Jonathan Schear

unread,
Jul 31, 2021, 5:16:59 PM7/31/21
to bazel-discuss
I'm not aware of a way of doing this, but I would really appreciate this functionality. One workaround I've seen is to use `actions.expand_template` to replace known tokens within the Python script -- sort of "sideloading" the arguments.
Reply all
Reply to author
Forward
0 new messages