Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions docs/toolchains.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions zig/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ filegroup(
name = "all_files",
srcs = [
":BUILD.bazel",
"//zig/config/bootstrapped:all_files",
"//zig/config/mode:all_files",
"//zig/config/threaded:all_files",
"//zig/config/use_standalone_translate_c:all_files",
Expand Down
20 changes: 20 additions & 0 deletions zig/config/bootstrapped/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
config_setting(
name = "bootstrap_enabled",
flag_values = {
"//zig/settings:bootstrapped": "true",
},
)

config_setting(
name = "bootstrap_disabled",
flag_values = {
"//zig/settings:bootstrapped": "false",
},
)

# Execute `bazel run //util:update_filegroups` to update this target.
filegroup(
name = "all_files",
srcs = [":BUILD.bazel"],
visibility = ["//zig/config:__pkg__"],
)
2 changes: 0 additions & 2 deletions zig/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ bzl_library(
visibility = ["//zig:__subpackages__"],
deps = [
"//zig/private/providers:zig_toolchain_info",
"@aspect_bazel_lib//lib:paths",
"@bazel_skylib//lib:paths",
],
)

Expand Down
6 changes: 3 additions & 3 deletions zig/private/common/translate_c.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ def _builtin_translate_c(*, ctx, zigtoolchaininfo, global_args, compilation_cont
transitive = transitive_inputs,
),
outputs = [zig_out],
arguments = [zigtoolchaininfo.zig_exe_path, "translate-c", global_args, args],
arguments = [zigtoolchaininfo.zig_exe.path, "translate-c", global_args, args],
mnemonic = "ZigTranslateC",
progress_message = "zig translate-c %{label}",
execution_requirements = {tag: "" for tag in ctx.attr.tags},
env = {
"ZIG_GLOBAL_CACHE_DIR": zigtoolchaininfo.zig_cache,
"ZIG_LIB_DIR": zigtoolchaininfo.zig_lib_path,
"ZIG_LIB_DIR": zigtoolchaininfo.zig_lib.path,
"ZIG_LOCAL_CACHE_DIR": zigtoolchaininfo.zig_cache,
},
tools = zigtoolchaininfo.zig_files,
tools = [zigtoolchaininfo.zig_exe, zigtoolchaininfo.zig_lib],
toolchain = "//zig:toolchain_type",
)

Expand Down
22 changes: 11 additions & 11 deletions zig/private/common/zig_build.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,11 @@ def zig_build_impl(ctx, *, kind):

zig_build_kwargs = dict(
execution_requirements = {tag: "" for tag in ctx.attr.tags},
tools = zigtoolchaininfo.zig_files,
tools = [zigtoolchaininfo.zig_exe, zigtoolchaininfo.zig_lib],
toolchain = "//zig:toolchain_type",
env = {
"ZIG_GLOBAL_CACHE_DIR": zigtoolchaininfo.zig_cache,
"ZIG_LIB_DIR": zigtoolchaininfo.zig_lib_path,
"ZIG_LIB_DIR": zigtoolchaininfo.zig_lib.path,
"ZIG_LOCAL_CACHE_DIR": zigtoolchaininfo.zig_cache,
},
)
Expand Down Expand Up @@ -511,7 +511,7 @@ def zig_build_impl(ctx, *, kind):
ctx.actions.run(
outputs = [static_lib] + auxiliary_outputs,
inputs = inputs,
executable = zigtoolchaininfo.zig_exe_path,
executable = zigtoolchaininfo.zig_exe,
arguments = ["build-lib", global_args, args],
mnemonic = "ZigBuildLib",
progress_message = "zig build-lib %{label}",
Expand Down Expand Up @@ -548,7 +548,7 @@ def zig_build_impl(ctx, *, kind):
ctx.actions.run(
outputs = [bin_output] + auxiliary_outputs,
inputs = inputs,
executable = zigtoolchaininfo.zig_exe_path,
executable = zigtoolchaininfo.zig_exe,
arguments = ["build-exe", global_args, args],
mnemonic = "ZigBuildExe",
progress_message = "zig build-exe %{label}",
Expand All @@ -564,7 +564,7 @@ def zig_build_impl(ctx, *, kind):
ctx.actions.run(
outputs = [test_obj] + auxiliary_outputs,
inputs = inputs,
executable = zigtoolchaininfo.zig_exe_path,
executable = zigtoolchaininfo.zig_exe,
arguments = ["test-obj", "--test-no-exec", global_args, args, test_args],
mnemonic = "ZigBuildTest",
progress_message = "zig test-obj %{label}",
Expand All @@ -583,7 +583,7 @@ def zig_build_impl(ctx, *, kind):
ctx.actions.run(
outputs = [bc] + auxiliary_outputs,
inputs = inputs,
executable = zigtoolchaininfo.zig_exe_path,
executable = zigtoolchaininfo.zig_exe,
arguments = ["test", "--test-no-exec", global_args, args, test_args],
mnemonic = "ZigBuildTest",
progress_message = "zig test %{label}",
Expand All @@ -602,7 +602,7 @@ def zig_build_impl(ctx, *, kind):
ctx.actions.run(
outputs = [static_lib],
inputs = [test_artifact],
executable = zigtoolchaininfo.zig_exe_path,
executable = zigtoolchaininfo.zig_exe,
arguments = ["build-lib", global_args, lib_args],
mnemonic = "ZigBuildLib",
progress_message = "zig build-lib %{label}",
Expand Down Expand Up @@ -639,7 +639,7 @@ def zig_build_impl(ctx, *, kind):
ctx.actions.run(
outputs = [bin_output] + auxiliary_outputs,
inputs = inputs,
executable = zigtoolchaininfo.zig_exe_path,
executable = zigtoolchaininfo.zig_exe,
arguments = ["test", "--test-no-exec", global_args, args],
mnemonic = "ZigBuildTest",
progress_message = "zig test %{label}",
Expand All @@ -653,7 +653,7 @@ def zig_build_impl(ctx, *, kind):
ctx.actions.run(
outputs = ([bin_output] if ctx.attr.emit_bin else []) + auxiliary_outputs,
inputs = inputs,
executable = zigtoolchaininfo.zig_exe_path,
executable = zigtoolchaininfo.zig_exe,
arguments = ["build-lib", global_args, args],
mnemonic = "ZigBuildStaticLib",
progress_message = "zig build-lib %{label}",
Expand All @@ -677,7 +677,7 @@ def zig_build_impl(ctx, *, kind):
ctx.actions.run(
outputs = [static_lib] + auxiliary_outputs,
inputs = inputs,
executable = zigtoolchaininfo.zig_exe_path,
executable = zigtoolchaininfo.zig_exe,
arguments = ["build-lib", global_args, args],
mnemonic = "ZigBuildLib",
progress_message = "zig build-lib %{label}",
Expand Down Expand Up @@ -729,7 +729,7 @@ def zig_build_impl(ctx, *, kind):
ctx.actions.run(
outputs = [bin_output] + auxiliary_outputs,
inputs = inputs,
executable = zigtoolchaininfo.zig_exe_path,
executable = zigtoolchaininfo.zig_exe,
arguments = ["build-lib", "-dynamic", global_args, args],
mnemonic = "ZigBuildSharedLib",
progress_message = "zig build-lib -dynamic %{label}",
Expand Down
4 changes: 2 additions & 2 deletions zig/private/common/zig_docs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ def zig_docs_impl(ctx, *, kind):
ctx.actions.run(
outputs = outputs,
inputs = inputs,
executable = zigtoolchaininfo.zig_exe_path,
tools = zigtoolchaininfo.zig_files,
executable = zigtoolchaininfo.zig_exe,
tools = [zigtoolchaininfo.zig_exe, zigtoolchaininfo.zig_lib],
arguments = arguments,
mnemonic = mnemonic,
progress_message = progress_message,
Expand Down
2 changes: 1 addition & 1 deletion zig/private/common/zig_lib_dir.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def zig_lib_dir(*, zigtoolchaininfo, args):
zigtoolchaininfo: ZigToolchainInfo.
args: Args; mutable, Append the Zig cache flags to this object.
"""
args.add_all(["--zig-lib-dir", zigtoolchaininfo.zig_lib_path])
args.add_all(["--zig-lib-dir", zigtoolchaininfo.zig_lib])
20 changes: 3 additions & 17 deletions zig/private/providers/zig_toolchain_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,9 @@ Information about how to invoke the Zig executable.
"""

FIELDS = {
"zig_exe_path": "Path to the Zig executable for the target platform.",
"zig_exe_rpath": """\
Rlocation path to the Zig executable for the target platform.

May be absolute if the zig_exe_path points to a locally installed Zig executable.
""",
"zig_lib_path": "Path to the Zig library directory for the target platform.",
"zig_lib_rpath": """\
Rlocation path to the Zig library directory for the target platform.

May be absolute if the zig_exe_path points to a locally installed Zig executable.
""",
"zig_files": """\
Files required in runfiles to make the Zig executable available.

May be empty if the zig_exe_path points to a locally installed Zig executable.
""",
"zig_exe": "File for the Zig executable.",
"zig_h": "File for the Zig header at the root of the Zig lib directory.",
"zig_lib": "File for the Zig lib source directory.",
"zig_version": "String, The Zig toolchain's version.",
"zig_cache": "String, The Zig cache directory prefix used for the global and local cache.",
}
Expand Down
1 change: 0 additions & 1 deletion zig/private/repo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ bzl_library(
visibility = ["//zig:__subpackages__"],
deps = [
"//zig/private/common:zig_cache",
"@bazel_skylib//lib:paths",
"@bazel_tools//tools/build_defs/repo:utils.bzl",
],
)
Expand Down
8 changes: 3 additions & 5 deletions zig/private/repo/zig_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ def _zig_repository_impl(repository_ctx):
repository_ctx.attr.platform,
)

zig_exe = "zig"
if repository_ctx.attr.platform.find("windows") != -1:
zig_exe = "zig.exe"
zig_exe = "zig.exe" if repository_ctx.attr.platform.find("windows") != -1 else "zig"

build_content = """\
# Generated by zig/private/repo/zig_repository.bzl
Expand All @@ -89,8 +87,8 @@ load("@rules_zig//zig:toolchain.bzl", "zig_toolchain")
zig_toolchain(
name = "zig_toolchain",
zig_exe = {zig_exe},
zig_lib = glob(["lib/**"]),
zig_lib_path = "lib",
zig_h = "lib/zig.h",
zig_lib = "lib",
zig_version = {zig_version},
zig_cache = {zig_cache},
)
Expand Down
Loading
Loading