experimental_platforms_api - Cannot Create New Platforms

Skip to first unread message

Mark Schulte

May 15, 2024, 10:47:53 AMMay 15
to bazel-discuss
Hi Bazel Users!

Does Bazel intend to support the --experimental_platforms_api? And if so, any thoughts on why this example is failing?

Background: I'm working on upgrading a library of custom rules from a legacy "cross-platform" rule, hacked together using aspects before transitions were available, over to Platforms/Toolchains/Constraints.

One method I've attempted to do this upgrade is using --experimental_platforms_api to modify our custom rules to return a platform_common.PlatformInfo provider in addition to the legacy custom providers those rules already returned.

In doing that, I kept getting this error:
╰─❯ bazel build //...
ERROR: /Users/mschulte/src/bazel_platforms_api_failure/BUILD:3:12: Target //:linux_amd64 was referenced as a platform, but does not provide PlatformInfo
ERROR: Analysis of target '//:linux_amd64' failed; build aborted
INFO: Elapsed time: 0.113s, Critical Path: 0.00s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

The code (linked above) is pretty simple:

// defs.bzl
def _my_platform_impl(ctx):
    return [platform_common.PlatformInfo(label = ctx.label)]

my_platform = rule(
    implementation = _my_platform_impl,

load(":defs.bzl", "my_platform")

    name = "linux_amd64",

bazel build //... --platforms=:linux_amd64

Thanks in advance for any help!
Reply all
Reply to author
0 new messages