From 1fa90818cb8c1cd5678ed0d1cf21079b95a6dc83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Mon, 12 Jul 2021 09:45:23 +0300 Subject: [PATCH] quote strings properly --- toolchain/BUILD.sdk.bazel | 4 ++-- toolchain/defs.bzl | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/toolchain/BUILD.sdk.bazel b/toolchain/BUILD.sdk.bazel index fc65b78..3675330 100644 --- a/toolchain/BUILD.sdk.bazel +++ b/toolchain/BUILD.sdk.bazel @@ -6,6 +6,6 @@ package( # TODO(motiejus) use json.encode() and unquote these variables with bazel 4+. zig_build_macro( - absolute_path = "{absolute_path}", - zig_include_root = "{zig_include_root}", + absolute_path = {absolute_path}, + zig_include_root = {zig_include_root}, ) diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index 837984c..617a3ca 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -1,3 +1,4 @@ +load("@bazel_skylib//lib:shell.bzl", "shell") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load(":zig_toolchain.bzl", "zig_cc_toolchain_config") @@ -162,8 +163,8 @@ def _zig_repository_impl(repository_ctx): Label("//toolchain:BUILD.sdk.bazel"), executable = False, substitutions = { - "{absolute_path}": str(repository_ctx.path("")), - "{zig_include_root}": zig_include_root, + "{absolute_path}": shell.quote(str(repository_ctx.path(""))), + "{zig_include_root}": shell.quote(zig_include_root), }, ) @@ -215,7 +216,6 @@ def zig_build_macro(absolute_path, zig_include_root): absolute_tool_paths[name] = "%s/%s" % (absolute_path, tool_path) tool_srcs[name].append(tool_path) - zig_cc_toolchain_config( name = target + "_cc_toolchain_config", target = target, @@ -225,7 +225,7 @@ def zig_build_macro(absolute_path, zig_include_root): copts = target_config.copts, linkopts = target_config.linkopts, target_system_name = "unknown", - target_cpu = target_config.bazel_target_cpu, + target_cpu = getattr(target_config, "bazel_target_cpu", None), target_libc = "unknown", compiler = "clang", abi_version = "unknown", @@ -246,14 +246,6 @@ def zig_build_macro(absolute_path, zig_include_root): supports_param_files = 0, ) - native.cc_toolchain_suite( - name = target + "_cc_toolchain_suite", - toolchains = { - target_config.bazel_target_cpu: ":%s_cc_toolchain" % target, - }, - tags = ["manual"], - ) - native.toolchain( name = target + "_toolchain", exec_compatible_with = None,