1

I'm trying to get some broken, platform dependent C# code to compile using bazel and I'm having quite a lot of problems defining a platform.

I've defined two platforms:

platform ( name = "darwin", constraint_values = [ "@bazel_tools//platform:osx", ], ) platform ( name = "windows", constraint_values = [ "@bazel_tools//platform:windows", ], ) 

Which I then use in a select in a genrule somewhere else in the BUILD file:

cmd = select ({ ":darwin" : "a bash command", ":windows" : "a long and complex windows command because windows is stupid and makes everything much much more complex than it has to be" }) 

When I try to build something, however, I get an error along the lines of

no such package '@bazel_tools//platform': BUILD file not found on package path and referenced by //<package>:darwin 

I take this to mean that @bazel_tools isn't available.

The documentation claims that @bazel_tools is builtin, so this is quite a surprise to me -- to me "builtin", means "you don't have to do anything for this to be available to you". I haven't been able to find anything that will tell how to fix the problem either.

2 Answers 2

3

I believe the directory is platforms":

@bazel_tools//platforms:osx"

Sign up to request clarification or add additional context in comments.

1 Comment

So it seems :-)
2

platform rule doesn't define config setting you can use in select(). You should use config_setting

This worked for me:

config_setting( name = "darwin", constraint_values = [ "@bazel_tools//platforms:osx", "@bazel_tools//platforms:x86_64" ] ) config_setting( name = "linux_x86", constraint_values = [ "@bazel_tools//platforms:linux", "@bazel_tools//platforms:x86_64" ] ) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.