1

buildifier

This commit is contained in:
Motiejus Jakštys 2021-06-10 13:12:54 +03:00 committed by Motiejus Jakštys
parent 5973131fff
commit dbff5afa75
4 changed files with 63 additions and 59 deletions

View File

@ -22,7 +22,6 @@ http_archive(
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
@ -32,6 +31,7 @@ go_register_toolchains(version = "1.16")
gazelle_dependencies(go_repository_default_config = "@//:WORKSPACE")
# protobuf is required for //:buildifier
http_archive(
name = "com_google_protobuf",
sha256 = "bf0e5070b4b99240183b29df78155eee335885e53a8af8683964579c214ad301",
@ -40,6 +40,7 @@ http_archive(
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
http_archive(
@ -48,10 +49,12 @@ http_archive(
url = "https://github.com/bazelbuild/buildtools/archive/master.zip",
)
load("//toolchain:defs.bzl",
load(
"//toolchain:defs.bzl",
zig_register_all_toolchains = "register_all_toolchains",
zig_toolchain_repositories = "toolchain_repositories",
)
zig_toolchain_repositories()
zig_register_all_toolchains()

View File

@ -1,7 +1,7 @@
load("@zig-cc-bazel//toolchain:defs.bzl", "zig_build_macro")
package(
default_visibility = ["//visibility:public"]
default_visibility = ["//visibility:public"],
)
zig_build_macro(

View File

@ -4,7 +4,6 @@ load(":zig_toolchain.bzl", "zig_cc_toolchain_config")
DEFAULT_TOOL_PATHS = {
"ar": "ar",
"gcc": "c++", # https://github.com/bazelbuild/bazel/issues/4644
"cpp": "/usr/bin/false",
"gcov": "/usr/bin/false",
"nm": "/usr/bin/false",
@ -38,6 +37,7 @@ TARGET_CONFIGS = [
],
tool_paths = {"ld": "ld64.lld"},
),
] + [
struct(
target = "x86_64-linux-gnu",
target_suffix = ".2.19",
@ -80,18 +80,16 @@ TARGET_CONFIGS = [
def toolchain_repositories():
zig_repository(
name = "zig_sdk",
version = "0.8.0",
url_format = "https://ziglang.org/download/{version}/zig-{host_platform}-{version}.tar.xz",
host_platform_sha256 = {
"linux-x86_64": "502625d3da3ae595c5f44a809a87714320b7a40e6dff4a895b5fa7df3391d01e",
"macos-x86_64": "279f9360b5cb23103f0395dc4d3d0d30626e699b1b4be55e98fd985b62bc6fbe",
},
host_platform_include_root = {
"macos-x86_64": "lib/zig/",
"linux-x86_64": "lib/",
}
},
)
def register_all_toolchains():
@ -230,7 +228,7 @@ def zig_build_macro(absolute_path, zig_include_root):
zig_cc_toolchain_config(
name = target + "_cc_toolchain_config",
target = target,
target_suffix = getattr(target_config, 'target_suffix', ''),
target_suffix = getattr(target_config, "target_suffix", ""),
tool_paths = absolute_tool_paths,
cxx_builtin_include_directories = cxx_builtin_include_directories,
copts = target_config.copts,
@ -262,7 +260,7 @@ def zig_build_macro(absolute_path, zig_include_root):
toolchains = {
target_config.bazel_target_cpu: ":%s_cc_toolchain" % target,
},
tags = ["manual"]
tags = ["manual"],
)
native.toolchain(

View File

@ -1,10 +1,11 @@
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
load(
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"feature",
"flag_group",
"flag_set",
"tool_path",
"tool",
"tool_path",
)
all_link_actions = [
@ -40,7 +41,8 @@ def _zig_cc_toolchain_config_impl(ctx):
"-I" + d
for d in ctx.attr.cxx_builtin_include_directories
] + [
"-target", ctx.attr.target + ctx.attr.target_suffix,
"-target",
ctx.attr.target + ctx.attr.target_suffix,
"-no-canonical-prefixes",
"-Wno-builtin-macro-redefined",
"-D__DATE__=\"redacted\"",
@ -62,7 +64,8 @@ def _zig_cc_toolchain_config_impl(ctx):
flag_groups = ([
flag_group(
flags = [
"-target", ctx.attr.target,
"-target",
ctx.attr.target,
] + ctx.attr.linkopts,
),
]),