diff --git a/MODULE.bazel b/MODULE.bazel index 07cc220..0199434 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,6 @@ module( name = "rules_mayhem", - version = "0.8.6", + version = "0.8.7", ) bazel_dep(name = "bazel_skylib", version = "1.9.0") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index d79f1c9..e4164e3 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -192,7 +192,7 @@ "//mayhem:extensions.bzl%rules_mayhem_extension": { "general": { "bzlTransitiveDigest": "SUFcWZq0Nc0sjSX728mHdDz01rb3+thUWiQBxjMbYsA=", - "usagesDigest": "RyJXYJvMhGiYDMSz7rvKMSwmhKhEJoWP/n6L+fT7Fkw=", + "usagesDigest": "rrpQRkerDYioRqTE9+dhc3hb9COdGQVTTq1fgQ07pZk=", "recordedInputs": [ "REPO_MAPPING:,bazel_tools bazel_tools", "REPO_MAPPING:,rules_mayhem ", diff --git a/README.md b/README.md index 248b489..4aaae4d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ You can add the following snippet: ``` ## MODULE.bazel -bazel_dep(name = "rules_mayhem", version = "0.8.6") +bazel_dep(name = "rules_mayhem", version = "0.8.7") rules_mayhem_extension = use_extension("@rules_mayhem//mayhem:extensions.bzl", "rules_mayhem_extension") use_repo(rules_mayhem_extension, "bazel_skylib", "mayhem_cli_linux", "mayhem_cli_windows", "platforms", "yq_cli_linux", "yq_cli_windows") @@ -21,8 +21,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "rules_mayhem", strip_prefix = "rules_mayhem", - urls = ["https://github.com/ForAllSecure/rules_mayhem/releases/download/0.8.6/rules_mayhem-0.8.6.tar.gz"], - sha256 = "0704d5d8443070924b153a709e9deb7e7ff71a268f6e7c88083d36dc65b85c0f", + urls = ["https://github.com/ForAllSecure/rules_mayhem/releases/download/0.8.7/rules_mayhem-0.8.7.tar.gz"], + sha256 = "911104c434cd01bfd993ed0b0395fd639526252a80710ad2830b60f1c30cceb2", ) load("@rules_mayhem//mayhem:repositories.bzl", "rules_mayhem_repositories") diff --git a/mayhem/mayhem.bzl b/mayhem/mayhem.bzl index 99c45b8..5972444 100644 --- a/mayhem/mayhem.bzl +++ b/mayhem/mayhem.bzl @@ -250,8 +250,26 @@ def _mayhem_run_impl(ctx): py_content = """#!/usr/bin/env python3 import subprocess import sys - -mayhem_cli = "{mayhem_cli}" +import os + +def resolve_runfile_mayhem_cli_path(mayhem_cli_short_path): + # Bazel sets the RUNFILES_MANIFEST_FILE environment variable on Windows + # which we can use to resolve the path to the mayhem CLI in the case that + # runfiles/symlinks are not available + + manifest_path = os.environ.get("RUNFILES_MANIFEST_FILE") + if manifest_path and os.name == "nt": + with open(manifest_path, "r") as manifest_file: + for line in manifest_file: + key, value = line.strip().split(" ", 1) + if "mayhem" in key.lower() and "cli" in key.lower(): + return value + + # If the manifest file is not set or the mayhem CLI is not found in the manifest, + # fall back to the original path + return mayhem_cli_short_path + +mayhem_cli = resolve_runfile_mayhem_cli_path("{mayhem_cli}") run_args = {run_args} wait_args = {wait_args}