1

WIP: use relative paths for tools

This commit is contained in:
Ken Micklas 2022-09-21 11:14:29 +01:00 committed by Motiejus Jakštys
parent f6b16c386f
commit ab59c18d60
6 changed files with 20 additions and 19 deletions

View File

@ -110,7 +110,7 @@ toolchain(
generator_location = "toolchain/BUILD:7:19",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:aarch64", "@zig_sdk//libc:unconstrained"],
toolchain = "@zig_sdk//private:aarch64-linux-musl_cc",
toolchain = "@zig_sdk//:aarch64-linux-musl_cc",
)
```

View File

@ -1,11 +1,10 @@
load("@bazel-zig-cc//toolchain:defs.bzl", "declare_files")
load("@bazel-zig-cc//toolchain/private:cc_toolchains.bzl", "declare_cc_toolchains")
package(
default_visibility = ["//visibility:public"],
)
declare_files(
os = {os},
zig_include_root = {zig_include_root},
@ -15,3 +14,9 @@ exports_files([
"glibc-hacks/fcntl.map",
"glibc-hacks/glibchack-fcntl.h",
])
declare_cc_toolchains(
os = {os},
absolute_path = {absolute_path},
zig_include_root = {zig_include_root},
)

View File

@ -186,14 +186,14 @@ def _zig_repository_impl(repository_ctx):
for dest, src in {
"BUILD": "//toolchain:BUILD.sdk.bazel",
"private/BUILD": "//toolchain/private:BUILD.sdk.bazel",
# "private/BUILD": "//toolchain/private:BUILD.sdk.bazel",
}.items():
repository_ctx.template(
dest,
Label(src),
executable = False,
substitutions = {
"{absolute_path}": _quote(str(repository_ctx.path(""))),
"{absolute_path}": _quote("external/zig_sdk"),
"{os}": _quote(os),
"{zig_include_root}": _quote(zig_include_root),
},
@ -246,6 +246,7 @@ def filegroup(name, **kwargs):
return ":" + name
def declare_files(os, zig_include_root):
filegroup(name = "all", srcs = native.glob(["**"]))
filegroup(name = "empty")
if os == "windows":
native.exports_files(["zig.exe"], visibility = ["//visibility:public"])

View File

@ -1,7 +0,0 @@
load("@bazel-zig-cc//toolchain/private:cc_toolchains.bzl", "declare_cc_toolchains")
declare_cc_toolchains(
os = {os},
absolute_path = {absolute_path},
zig_include_root = {zig_include_root},
)

View File

@ -29,7 +29,7 @@ def declare_cc_toolchains(os, absolute_path, zig_include_root):
absolute_tool_paths[name] = path
continue
tool_path = zig_tool_path(os).format(zig_tool = path)
absolute_tool_paths[name] = "%s/%s" % (absolute_path, tool_path)
absolute_tool_paths[name] = tool_path
linkopts = target_config.linkopts
dynamic_library_linkopts = target_config.dynamic_library_linkopts
@ -53,18 +53,20 @@ def declare_cc_toolchains(os, absolute_path, zig_include_root):
compiler = "clang",
abi_version = "unknown",
abi_libc_version = "unknown",
# visibility = ["//visibility:private"],
)
native.cc_toolchain(
name = zigtarget + "_cc",
toolchain_identifier = zigtarget + "-toolchain",
toolchain_config = ":%s_cc_config" % zigtarget,
all_files = "@zig_sdk//:zig",
ar_files = "@zig_sdk//:zig",
compiler_files = "@zig_sdk//:zig",
linker_files = "@zig_sdk//:zig",
all_files = "@zig_sdk//:all",
ar_files = "@zig_sdk//:all",
compiler_files = "@zig_sdk//:all",
linker_files = "@zig_sdk//:all",
dwp_files = "@zig_sdk//:empty",
objcopy_files = "@zig_sdk//:empty",
strip_files = "@zig_sdk//:empty",
supports_param_files = 0,
# visibility = ["//visibility:private"],
)

View File

@ -32,7 +32,7 @@ def _declare_toolchain(gotarget, zigtarget, target_compatible_with):
name = gotarget,
exec_compatible_with = None,
target_compatible_with = target_compatible_with,
toolchain = "@zig_sdk//private:%s_cc" % zigtarget,
toolchain = "@zig_sdk//:%s_cc" % zigtarget,
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
@ -41,6 +41,6 @@ def _declare_toolchain(gotarget, zigtarget, target_compatible_with):
name = zigtarget,
exec_compatible_with = None,
target_compatible_with = target_compatible_with,
toolchain = "@zig_sdk//private:%s_cc" % zigtarget,
toolchain = "@zig_sdk//:%s_cc" % zigtarget,
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)