From e5eff0c911969692afb8f93bf56b370be5af105a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 11 Oct 2022 14:57:44 +0300 Subject: [PATCH] zig include root: it depends on the OS Previously the toolchain wrappers used to assume the zig_lib_dir is always in "lib". However, it depends on the OS: macos-x86_64 and linux-aarch64 have it in "lib/zig". Update the wrapper scripts to reflect that. --- toolchain/defs.bzl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index 2748354..f031d62 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -125,9 +125,9 @@ set ZIG_GLOBAL_CACHE_DIR=%ZIG_LOCAL_CACHE_DIR% _ZIG_TOOL_WRAPPER_CACHE_KNOWN = """#!/bin/sh set -e if [ -d external/zig_sdk/lib ]; then - ZIG_LIB_DIR=external/zig_sdk/lib + ZIG_LIB_DIR=external/zig_sdk/{zig_include_root} else - ZIG_LIB_DIR="$(dirname "$0")/../../lib" + ZIG_LIB_DIR="$(dirname "$0")/../../{zig_include_root}" fi export ZIG_LIB_DIR export ZIG_LOCAL_CACHE_DIR="{cache_prefix}/bazel-zig-cc" @@ -139,9 +139,9 @@ exec "{zig}" "{zig_tool}" {maybe_target} "$@" _ZIG_TOOL_WRAPPER_CACHE_GUESS = """#!/bin/sh set -e if [ -d external/zig_sdk/lib ]; then - ZIG_LIB_DIR=external/zig_sdk/lib + ZIG_LIB_DIR=external/zig_sdk/{zig_include_root} else - ZIG_LIB_DIR="$(dirname "$0")/../../lib" + ZIG_LIB_DIR="$(dirname "$0")/../../{zig_include_root}" fi if [ -n "$TMPDIR" ]; then _cache_prefix=$TMPDIR @@ -180,13 +180,14 @@ fi eval set -- "$saved" """ -def _zig_tool_wrapper(zig_tool, zig, is_windows, cache_prefix, zigtarget): +def _zig_tool_wrapper(zig_tool, zig, is_windows, cache_prefix, zigtarget, zig_include_root): kwargs = dict( zig = str(zig).replace("/", "\\") + ".exe" if is_windows else zig, zig_tool = zig_tool, cache_prefix = cache_prefix, maybe_gohack = _ZIG_TOOL_GOHACK if (zig_tool == "c++" and not is_windows) else "", maybe_target = "-target {}".format(zigtarget) if zig_tool == "c++" else "", + zig_include_root = zig_include_root, ) if is_windows: @@ -271,6 +272,7 @@ def _zig_repository_impl(repository_ctx): os == "windows", repository_ctx.os.environ.get("BAZEL_ZIG_CC_CACHE_PREFIX", ""), zigtarget = target_config.zigtarget, + zig_include_root = zig_include_root, ) repository_ctx.file(