From cb10c591beb592d3c8a96ff2df6ad7e0653c650e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 21 Jul 2021 14:53:39 +0300 Subject: [PATCH] rename zig toolchain to match go --- .build.yml | 4 ++-- toolchain/defs.bzl | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.build.yml b/.build.yml index 3e36358..a761dc2 100644 --- a/.build.yml +++ b/.build.yml @@ -20,7 +20,7 @@ tasks: - test_x86_64-linux-musl: | cd bazel-zig-cc; . .envrc; ./build-and-file \ --platforms @io_bazel_rules_go//go/toolchain:linux_amd64_cgo \ - --extra_toolchains @zig_sdk//:x86_64-linux-musl_toolchain //test:hello | \ + --extra_toolchains @zig_sdk//:linux_amd64_musl_toolchain //test:hello | \ grep -q "ELF 64-bit.* x86-64.* statically linked" - test_aarch64-linux-gnu: | cd bazel-zig-cc; . .envrc; ./build-and-file \ @@ -29,7 +29,7 @@ tasks: - test_aarch64-linux-musl: | cd bazel-zig-cc; . .envrc; ./build-and-file \ --platforms @io_bazel_rules_go//go/toolchain:linux_arm64_cgo \ - --extra_toolchains @zig_sdk//:aarch64-linux-musl_toolchain //test:hello | \ + --extra_toolchains @zig_sdk//:linux_arm64_musl_toolchain //test:hello | \ grep -q "ELF 64-bit.* ARM aarch64.* statically linked" - test_x86_64-macos-gnu: | cd bazel-zig-cc; . .envrc; ./build-and-file \ diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index 621aec7..ba5a895 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -21,6 +21,7 @@ DEFAULT_INCLUDE_DIRECTORIES = [ # https://github.com/ziglang/zig/blob/0cfa39304b18c6a04689bd789f5dc4d035ec43b0/src/main.zig#L2962-L2966 TARGET_CONFIGS_LISTOFLISTS = [[ struct( + gotarget = "darwin_{}".format(gocpu), zigtarget = "{}-macos-gnu".format(zigcpu), includes = [ "libunwind/include", @@ -39,6 +40,7 @@ TARGET_CONFIGS_LISTOFLISTS = [[ register = True, ), struct( + gotarget = "linux_{}_gnu".format(gocpu), zigtarget = "{}-linux-gnu".format(zigcpu), target_suffix = ".2.19", includes = [ @@ -59,6 +61,7 @@ TARGET_CONFIGS_LISTOFLISTS = [[ register = True, ), struct( + gotarget = "linux_{}_musl".format(gocpu), zigtarget = "{}-linux-musl".format(zigcpu), includes = [ "libc/include/generic-musl", @@ -104,7 +107,7 @@ def register_all_toolchains(): for target_config in TARGET_CONFIGS: if target_config.register: native.register_toolchains( - "@zig_sdk//:%s_toolchain" % target_config.zigtarget, + "@zig_sdk//:%s_toolchain" % target_config.gotarget, ) ZIG_TOOL_PATH = "tools/{zig_tool}" @@ -192,9 +195,10 @@ def zig_build_macro(absolute_path, zig_include_root): lazy_filegroups = {} for target_config in TARGET_CONFIGS: + gotarget = target_config.gotarget zigtarget = target_config.zigtarget native.platform( - name = zigtarget, + name = gotarget, constraint_values = target_config.constraint_values, ) @@ -249,7 +253,7 @@ def zig_build_macro(absolute_path, zig_include_root): ) native.toolchain( - name = zigtarget + "_toolchain", + name = gotarget + "_toolchain", exec_compatible_with = None, target_compatible_with = target_config.constraint_values, toolchain = ":%s_cc_toolchain" % zigtarget,