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

Windows: implement native_binary and native_test rules #148

Closed
laszlocsomor opened this issue May 8, 2019 · 4 comments · Fixed by #152
Closed

Windows: implement native_binary and native_test rules #148

laszlocsomor opened this issue May 8, 2019 · 4 comments · Fixed by #152
Assignees

Comments

@laszlocsomor
Copy link
Contributor

laszlocsomor commented May 8, 2019

Implement rules that allow wrapping a native binary (or native script) in a _binary and _test rule, so we can bazel run and bazel test it, or use as tools entry for other rules.

Desired semantics:

native_test(
  name = "my_bin",
  src = "my_bin.exe",
  args = ["--data=$(location some-data.txt)"],
  data = ["some-data.txt"],
)

Crucially these rules should use ctx.actions.run and NOT ctx.actions.run_shell, to avoid depending on Bash.

@laurentlb
Copy link
Contributor

Do you plan to work on this?

IMO, that would be great to have this (and #149) before publishing the blog post about living in a bash-less world.

@laszlocsomor
Copy link
Contributor Author

Yes, and yes I agree.

@laszlocsomor
Copy link
Contributor Author

laszlocsomor commented May 8, 2019

Wow, living in the future!


image

@laszlocsomor laszlocsomor self-assigned this May 8, 2019
laszlocsomor added a commit to laszlocsomor/bazel-skylib that referenced this issue May 13, 2019
I plan to use these functions in native_binary()
and native_test().

See bazelbuild#148
laszlocsomor added a commit that referenced this issue May 13, 2019
I plan to use these functions in native_binary()
and native_test().

See #148
laszlocsomor added a commit to laszlocsomor/bazel-skylib that referenced this issue May 13, 2019
native_binary() wraps a pre-built binary or script
in a *_binary rule interface. Rules like genrule
can tool-depend on it, and it can be executed with
"bazel run". This rule can also augment the binary
with runfiles.

native_test() is similar, but creates a testable
rule instead of a binary rule.

Fixes bazelbuild#148

RELNOTES[NEW]: The new `native_binary()` and `native_test()` rules let you wrap a pre-built binary in a binary and test rule respectively.
laszlocsomor added a commit that referenced this issue May 14, 2019
native_binary() wraps a pre-built binary or script
in a *_binary rule interface. Rules like genrule
can tool-depend on it, and it can be executed with
"bazel run". This rule can also augment the binary
with runfiles.

native_test() is similar, but creates a testable
rule instead of a binary rule.

Fixes #148

RELNOTES[NEW]: The new `native_binary()` and `native_test()` rules let you wrap a pre-built binary in a binary and test rule respectively.
@erenon
Copy link
Contributor

erenon commented Apr 9, 2020

The documentation referencing these rules link to non-existent pages:
https://docs.bazel.build/versions/master/skylark/windows_tips.html

run_binary() (source, documentation): runs a binary (or *_binary rule) with given inputs and expected outputs as a build action (this is a build rule wrapper for ctx.actions.run)

native_binary() (source, documentation): wraps a native binary in a *_binary rule, which you can bazel run or use in run_binary()’s tool attribute or

The bold links are dead.

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

Successfully merging a pull request may close this issue.

3 participants