Skip to content

Commit

Permalink
Enable the custom_interpreter test on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
aherrmann committed Dec 30, 2023
1 parent 648e9ca commit a00ffea
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions zig/tests/integration_tests/integration_tests_runner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ test "zig_target_toolchain attribute dynamic_linker configures the interpreter"
"build",
"//custom_interpreter:binary-custom_interpreter",
"--extra_toolchains=//custom_interpreter:x86_64-linux-custom_interpreter_toolchain",
"--extra_toolchains=//custom_interpreter:cc_x86_64-linux-custom_interpreter_toolchain",
},
});
defer result.deinit();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@rules_zig//zig:defs.bzl", "zig_binary", "zig_configure_binary")
load("@rules_zig//zig:toolchain.bzl", "zig_target_toolchain")
load(":cc.bzl", "cc_config")

constraint_setting(
name = "interpreter",
Expand Down Expand Up @@ -36,6 +37,14 @@ toolchain(
toolchain_type = "@rules_zig//zig/target:toolchain_type",
)

cc_config(
name = "cc_x86_64-linux-custom_interpreter_toolchain",
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)

zig_binary(
name = "binary",
cdeps = ["@rules_zig//zig/lib:libc"],
Expand Down
46 changes: 46 additions & 0 deletions zig/tests/integration_tests/workspace/custom_interpreter/cc.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Dummy CC toolchain for custom-interpreter test.
Provides a dummy CC toolchain such that the custom_interpreter test also works
on other platforms than Linux without having to supply a proper C/C++
cross-compilation toolchain.
"""

def _cc_toolchain_config_impl(ctx):
return cc_common.create_cc_toolchain_config_info(
ctx = ctx,
toolchain_identifier = "cc-dummy-toolchain",
host_system_name = "dummy",
target_system_name = "dummy",
target_cpu = "dummy",
target_libc = "gnu",
compiler = "dummy",
abi_version = "unknown",
abi_libc_version = "unknown",
)

_cc_toolchain_config = rule(
implementation = _cc_toolchain_config_impl,
attrs = {},
provides = [CcToolchainConfigInfo],
)

def cc_config(*, name, target_compatible_with):
_cc_toolchain_config(name = name + "_cc_config")
native.cc_toolchain(
name = name + "_cc_toolchain",
toolchain_identifier = "dummy-toolchain",
toolchain_config = ":" + name + "_cc_config",
all_files = ":empty",
compiler_files = ":empty",
dwp_files = ":empty",
linker_files = ":empty",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 0,
)
native.toolchain(
name = name,
target_compatible_with = target_compatible_with,
toolchain = ":" + name + "_cc_toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

0 comments on commit a00ffea

Please sign in to comment.