Rename bazel-zig-cc to hermetic_cc_toolchain (#36)
As it says on the tin. Long live hermetic_cc_toolchain!
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# Copyright 2023 Uber Technologies, Inc.
|
||||
# Licensed under the MIT License
|
||||
|
||||
load("@bazel-zig-cc//toolchain:defs.bzl", "declare_files")
|
||||
load("@bazel-zig-cc//toolchain/private:cc_toolchains.bzl", "declare_cc_toolchains")
|
||||
load("@hermetic_cc_toolchain//toolchain:defs.bzl", "declare_files")
|
||||
load("@hermetic_cc_toolchain//toolchain/private:cc_toolchains.bzl", "declare_cc_toolchains")
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
load("@bazel_skylib//lib:paths.bzl", "paths")
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "read_user_netrc", "use_netrc")
|
||||
load("@bazel-zig-cc//toolchain/private:defs.bzl", "target_structs", "zig_tool_path")
|
||||
load("@hermetic_cc_toolchain//toolchain/private:defs.bzl", "target_structs", "zig_tool_path")
|
||||
|
||||
# Directories that `zig c++` includes behind the scenes.
|
||||
_DEFAULT_INCLUDE_DIRECTORIES = [
|
||||
@@ -13,11 +13,8 @@ _DEFAULT_INCLUDE_DIRECTORIES = [
|
||||
# Official recommended version. Should use this when we have a usable release.
|
||||
URL_FORMAT_RELEASE = "https://ziglang.org/download/{version}/zig-{host_platform}-{version}.{_ext}"
|
||||
|
||||
# Caution: nightly releases are purged from ziglang.org after ~90 days. A real
|
||||
# solution would be to allow the downstream project specify their own mirrors.
|
||||
# This is explained in
|
||||
# https://sr.ht/~motiejus/bazel-zig-cc/#alternative-download-urls and is
|
||||
# awaiting my attention or your contribution.
|
||||
# Caution: nightly releases are purged from ziglang.org after ~90 days. Use the
|
||||
# Bazel mirror or your own.
|
||||
URL_FORMAT_NIGHTLY = "https://ziglang.org/builds/zig-{host_platform}-{version}.{_ext}"
|
||||
|
||||
# Official Bazel's mirror with selected Zig SDK versions. Bazel community is
|
||||
@@ -176,19 +173,19 @@ def _zig_repository_impl(repository_ctx):
|
||||
sha256 = zig_sha256,
|
||||
)
|
||||
|
||||
cache_prefix = repository_ctx.os.environ.get("BAZEL_ZIG_CC_CACHE_PREFIX", "")
|
||||
cache_prefix = repository_ctx.os.environ.get("HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX", "")
|
||||
if cache_prefix == "":
|
||||
if os == "windows":
|
||||
cache_prefix = "C:\\\\Temp\\\\bazel-zig-cc"
|
||||
cache_prefix = "C:\\\\Temp\\\\hermetic_cc_toolchain"
|
||||
else:
|
||||
cache_prefix = "/tmp/bazel-zig-cc"
|
||||
cache_prefix = "/tmp/hermetic_cc_toolchain"
|
||||
|
||||
repository_ctx.template(
|
||||
"tools/launcher.zig",
|
||||
Label("//toolchain:launcher.zig"),
|
||||
executable = False,
|
||||
substitutions = {
|
||||
"{BAZEL_ZIG_CC_CACHE_PREFIX}": cache_prefix,
|
||||
"{HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX}": cache_prefix,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -244,7 +241,7 @@ zig_repository = repository_rule(
|
||||
"url_formats": attr.string_list(allow_empty = False),
|
||||
"host_platform_ext": attr.string_dict(),
|
||||
},
|
||||
environ = ["BAZEL_ZIG_CC_CACHE_PREFIX"],
|
||||
environ = ["HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX"],
|
||||
implementation = _zig_repository_impl,
|
||||
)
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@
|
||||
// complain that the compiler is using undeclared directories on the host file
|
||||
// system. We do not declare prerequisites using absolute paths, because that
|
||||
// busts Bazel's remote cache.
|
||||
// * BAZEL_ZIG_CC_CACHE_PREFIX is configurable per toolchain instance, and
|
||||
// * HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX is configurable per toolchain instance, and
|
||||
// ZIG_GLOBAL_CACHE_DIR and ZIG_LOCAL_CACHE_DIR must be set to its value for
|
||||
// all `zig` invocations.
|
||||
//
|
||||
// Originally this was a Bash script, then a POSIX shell script, then two
|
||||
// scripts (one with pre-defined BAZEL_ZIG_CC_CACHE_PREFIX, one without). Then
|
||||
// Windows came along with two PowerShell scripts (ports of the POSIX shell
|
||||
// scripts), which I kept breaking. Then Bazel 6 came with
|
||||
// scripts (one with pre-defined HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX, one
|
||||
// without). Then Windows came along with two PowerShell scripts (ports of the
|
||||
// POSIX shell scripts), which I kept breaking. Then Bazel 6 came with
|
||||
// `--experimental_use_hermetic_linux_sandbox`, which hermetizes the sandbox to
|
||||
// the extreme: the sandbox has nothing that is not declared. /bin/sh and its
|
||||
// dependencies (/lib/x86_64-linux-gnu/libc.so.6 on my system) are obviously
|
||||
@@ -67,7 +67,7 @@ const EXE = switch (builtin.target.os.tag) {
|
||||
else => "",
|
||||
};
|
||||
|
||||
const CACHE_DIR = "{BAZEL_ZIG_CC_CACHE_PREFIX}";
|
||||
const CACHE_DIR = "{HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX}";
|
||||
|
||||
const usage_cpp =
|
||||
\\
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copyright 2023 Uber Technologies, Inc.
|
||||
# Licensed under the MIT License
|
||||
|
||||
load("@bazel-zig-cc//toolchain/libc:defs.bzl", "declare_libcs")
|
||||
load("@hermetic_cc_toolchain//toolchain/libc:defs.bzl", "declare_libcs")
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copyright 2023 Uber Technologies, Inc.
|
||||
# Licensed under the MIT License
|
||||
|
||||
load("@bazel-zig-cc//toolchain/private:defs.bzl", "LIBCS")
|
||||
load("@hermetic_cc_toolchain//toolchain/private:defs.bzl", "LIBCS")
|
||||
|
||||
def declare_libcs():
|
||||
for libc in LIBCS:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copyright 2023 Uber Technologies, Inc.
|
||||
# Licensed under the MIT License
|
||||
|
||||
load("@bazel-zig-cc//toolchain/platform:defs.bzl", "declare_libc_aware_platforms")
|
||||
load("@hermetic_cc_toolchain//toolchain/platform:defs.bzl", "declare_libc_aware_platforms")
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copyright 2023 Uber Technologies, Inc.
|
||||
# Licensed under the MIT License
|
||||
|
||||
load("@bazel-zig-cc//toolchain/toolchain:defs.bzl", "declare_libc_aware_toolchains")
|
||||
load("@hermetic_cc_toolchain//toolchain/toolchain:defs.bzl", "declare_libc_aware_toolchains")
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
load("@bazel-zig-cc//toolchain/platform:defs.bzl", "declare_platforms")
|
||||
load("@hermetic_cc_toolchain//toolchain/platform:defs.bzl", "declare_platforms")
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
load("@bazel-zig-cc//toolchain/private:defs.bzl", "LIBCS")
|
||||
load("@hermetic_cc_toolchain//toolchain/private:defs.bzl", "LIBCS")
|
||||
|
||||
_CPUS = (("x86_64", "amd64"), ("aarch64", "arm64"))
|
||||
_OS = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
load(":defs.bzl", "target_structs", "zig_tool_path")
|
||||
load("@bazel-zig-cc//toolchain:zig_toolchain.bzl", "zig_cc_toolchain_config")
|
||||
load("@hermetic_cc_toolchain//toolchain:zig_toolchain.bzl", "zig_cc_toolchain_config")
|
||||
|
||||
DEFAULT_TOOL_PATHS = {
|
||||
"ar": "ar",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
load("@bazel-zig-cc//toolchain/toolchain:defs.bzl", "declare_toolchains")
|
||||
load("@hermetic_cc_toolchain//toolchain/toolchain:defs.bzl", "declare_toolchains")
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
load("@bazel-zig-cc//toolchain/private:defs.bzl", "target_structs")
|
||||
load("@hermetic_cc_toolchain//toolchain/private:defs.bzl", "target_structs")
|
||||
|
||||
def declare_toolchains():
|
||||
for target_config in target_structs():
|
||||
|
||||
Reference in New Issue
Block a user