Question: How to configure Workspace to add a dependency only for a particular platform

40 views
Skip to first unread message

Aditya Maheshwari

unread,
Nov 29, 2021, 9:24:18 AM11/29/21
to bazel-go-discuss
I am using bazel to build my golang  project. I want to use fips compliant crypto libraries.

I have made these changes - 

```
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies", "go_download_sdk")

go_rules_dependencies()

go_register_toolchains(version = "1.14.8")

go_download_sdk(
    name = "go_sdk",
    sdks = {
       "linux_amd64": ("go1.14.15b4.linux-amd64.tar.gz", "82ba7297d26afcdade439de5621bdcb16e5261877f204aa60d03b5e07223a5c8"),
    },
)
```
This works fine and build is green on Ubuntu. But if I run it on macos, I get unsupported platform error.

Above boringcrypto sdk is not available for macos. So I want to remove this dependency in case platform is "darwinamd64". How I can selectively add this dependency on the basis of os? I want to add this if OS is linux and not if OS is MacOS.

Thanks
Reply all
Reply to author
Forward
0 new messages