bazelbuild / bazel

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

Better bash-less Windows support in actions.run_shell: add command_bat, command_ps #15194

Open tetromino opened 2 years ago

tetromino commented 2 years ago

Description of the feature request:

For better bash-less Windows support,ctx.actions.run_shell could add command_bat (with the same behavior as genrule's cmd_bat) and command_ps (with the same behavior as genrule's cmd_ps).

This would, in particular, considerably simplify skylib's Windows support, where currently we are forced to write and execute temporary .bat files on Windows (and attempt to deal with the ancient terror of argument quoting in .bat interpreter context - take a look at https://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts if you don't mind losing some points of sanity).

Pinging potentially interested parties: @brandjon @meteorcloudy @alexeagle

meteorcloudy commented 2 years ago

Related commit is https://github.com/bazelbuild/bazel/commit/d3bacfba3efef386bba80d7ff16c12c486165c4e, this is a great feature that the community can contribute when the Build API team currently doesn't have the resource.

sreenath-tm commented 2 years ago

I'm interested in contributing to this issue, so before I start working it, would you mind sparing your time explaining what the issue is about and pointing me to some resources to get started.

meteorcloudy commented 2 years ago

This is basically adding addtional APIs to ctx.actions so that it also supports run_bat, run_ps. This will allow users to write starlark rules that works on Windows without installing bash.

comius commented 1 year ago

This is basically adding addtional APIs to ctx.actions so that it also supports run_bat, run_ps. This will allow users to write starlark rules that works on Windows without installing bash.

Adding new arguments to run_shell should be considered (not new call under ctx.actions).