From 7890b42438cb7a7e6afd5856ec06684d3b601240 Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Mon, 7 Oct 2024 13:48:32 -0700 Subject: [PATCH] Revert #2911 and #2922 (#2925) Revert "Restore lost "is_absolute" (#2922)" This reverts commit 2a85e13c74239d2a0d0c47a37f10a4c9739fa5e6. Revert "Use absolute path with "-fsanitize-ignorelist" (#2911)" This reverts commit 9594fa70b5b6f556a7b4f57ca0ac7c48149bf280. --- MODULE.bazel | 2 +- cargo/private/cargo_build_script.bzl | 41 ++++++++++++++++------------ version.bzl | 2 +- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 0011e62efb..a22f29cc57 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -2,7 +2,7 @@ module( name = "rules_rust", - version = "0.52.1", + version = "0.52.2", ) bazel_dep( diff --git a/cargo/private/cargo_build_script.bzl b/cargo/private/cargo_build_script.bzl index 2c2a64a508..26e477c0cf 100644 --- a/cargo/private/cargo_build_script.bzl +++ b/cargo/private/cargo_build_script.bzl @@ -153,7 +153,7 @@ def get_cc_compile_args_and_env(cc_toolchain, feature_configuration): ) return cc_c_args, cc_cxx_args, cc_env -def _pwd_flags(args): +def _pwd_flags_sysroot(args): """Prefix execroot-relative paths of known arguments with ${pwd}. Args: @@ -163,33 +163,38 @@ def _pwd_flags(args): list: The modified argument list. """ res = [] - fix_next_arg = False + for arg in args: + s, opt, path = arg.partition("--sysroot=") + if s == "" and not paths.is_absolute(path): + res.append("{}${{pwd}}/{}".format(opt, path)) + else: + res.append(arg) + return res - flags = ["-fsanitize-ignorelist", "-isystem", "--sysroot"] +def _pwd_flags_isystem(args): + """Prefix execroot-relative paths of known arguments with ${pwd}. - def split_flag(flag): - if flag in flags: - return (flag, None) - for flag in flags: - s, opt, path = arg.partition(flag + "=") - if s == "": - return (opt, path) - return (None, None) + Args: + args (list): List of tool arguments. + Returns: + list: The modified argument list. + """ + res = [] + fix_next_arg = False for arg in args: if fix_next_arg and not paths.is_absolute(arg): res.append("${{pwd}}/{}".format(arg)) - fix_next_arg = False else: - opt, path = split_flag(arg) - if opt and path and not paths.is_absolute(path): - res.append("{}${{pwd}}/{}".format(opt, path)) - else: - fix_next_arg = (opt != None) - res.append(arg) + res.append(arg) + + fix_next_arg = arg == "-isystem" return res +def _pwd_flags(args): + return _pwd_flags_isystem(_pwd_flags_sysroot(args)) + def _feature_enabled(ctx, feature_name, default = False): """Check if a feature is enabled. diff --git a/version.bzl b/version.bzl index f68d2dbb5f..dcfea0c16f 100644 --- a/version.bzl +++ b/version.bzl @@ -1,3 +1,3 @@ """The version of rules_rust.""" -VERSION = "0.52.1" +VERSION = "0.52.2"