From d1b0dddf8cac523cec6896af15119e2e76ab3f33 Mon Sep 17 00:00:00 2001 From: laurynasl Date: Wed, 6 Apr 2022 19:19:44 +0000 Subject: [PATCH] Move declare_platforms() to platform/ --- toolchain/defs.bzl | 17 ----------------- toolchain/platform/BUILD | 2 +- toolchain/platform/defs.bzl | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 toolchain/platform/defs.bzl diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index eb005fe..3f6b4bd 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -385,20 +385,3 @@ def zig_build_macro(absolute_path, zig_include_root): toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", ) -def declare_platforms(): - # create @zig_sdk//{os}_{arch}_platform entries with zig and go conventions - for zigcpu, gocpu in (("x86_64", "amd64"), ("aarch64", "arm64")): - for bzlos, oss in {"linux": ["linux"], "macos": ["macos", "darwin"]}.items(): - for os in oss: - constraint_values = [ - "@platforms//os:{}".format(bzlos), - "@platforms//cpu:{}".format(zigcpu), - ] - native.platform( - name = "{os}_{zigcpu}".format(os = os, zigcpu = zigcpu), - constraint_values = constraint_values, - ) - native.platform( - name = "{os}_{gocpu}".format(os = os, gocpu = gocpu), - constraint_values = constraint_values, - ) diff --git a/toolchain/platform/BUILD b/toolchain/platform/BUILD index b02436b..ce0ffc7 100644 --- a/toolchain/platform/BUILD +++ b/toolchain/platform/BUILD @@ -1,3 +1,3 @@ -load("@bazel-zig-cc//toolchain:defs.bzl", "declare_platforms") +load("@bazel-zig-cc//toolchain/platform:defs.bzl", "declare_platforms") declare_platforms() diff --git a/toolchain/platform/defs.bzl b/toolchain/platform/defs.bzl new file mode 100644 index 0000000..e094029 --- /dev/null +++ b/toolchain/platform/defs.bzl @@ -0,0 +1,17 @@ +def declare_platforms(): + # create @zig_sdk//{os}_{arch}_platform entries with zig and go conventions + for zigcpu, gocpu in (("x86_64", "amd64"), ("aarch64", "arm64")): + for bzlos, oss in {"linux": ["linux"], "macos": ["macos", "darwin"]}.items(): + for os in oss: + constraint_values = [ + "@platforms//os:{}".format(bzlos), + "@platforms//cpu:{}".format(zigcpu), + ] + native.platform( + name = "{os}_{zigcpu}".format(os = os, zigcpu = zigcpu), + constraint_values = constraint_values, + ) + native.platform( + name = "{os}_{gocpu}".format(os = os, gocpu = gocpu), + constraint_values = constraint_values, + )