diff --git a/README.md b/README.md index 262b88b..266952f 100644 --- a/README.md +++ b/README.md @@ -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", ) ``` diff --git a/toolchain/BUILD.sdk.bazel b/toolchain/BUILD.sdk.bazel index e1505b1..ef5fd5f 100644 --- a/toolchain/BUILD.sdk.bazel +++ b/toolchain/BUILD.sdk.bazel @@ -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}, +) diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index 797e4fe..f0e6a72 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -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"]) diff --git a/toolchain/private/BUILD.sdk.bazel b/toolchain/private/BUILD.sdk.bazel deleted file mode 100644 index 3e7c23e..0000000 --- a/toolchain/private/BUILD.sdk.bazel +++ /dev/null @@ -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}, -) diff --git a/toolchain/private/cc_toolchains.bzl b/toolchain/private/cc_toolchains.bzl index 724cbda..6b8b3e6 100644 --- a/toolchain/private/cc_toolchains.bzl +++ b/toolchain/private/cc_toolchains.bzl @@ -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"], ) diff --git a/toolchain/toolchain/defs.bzl b/toolchain/toolchain/defs.bzl index 1d99a61..24a90cc 100644 --- a/toolchain/toolchain/defs.bzl +++ b/toolchain/toolchain/defs.bzl @@ -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", )