From b5dc9d1f0457541bc2c5e712a942bd7967ee6e56 Mon Sep 17 00:00:00 2001 From: Steve Barrau <98589981+stevebarrau@users.noreply.github.com> Date: Mon, 2 Dec 2024 13:43:08 +0000 Subject: [PATCH] Allow setting the dtrace binary (#2607) Allow setting the dtrace binary in `dtrace_compile`. --- apple/dtrace.bzl | 12 +++++++++++- doc/rules-dtrace.md | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apple/dtrace.bzl b/apple/dtrace.bzl index 17cd398c92..cc3f2dd78e 100644 --- a/apple/dtrace.bzl +++ b/apple/dtrace.bzl @@ -39,6 +39,10 @@ def _dtrace_compile_impl(ctx): output_hdrs = [] include_dir = None + dtrace = "/usr/sbin/dtrace" + if ctx.executable.dtrace: + dtrace = ctx.executable.dtrace + for src in ctx.files.srcs: owner_relative_path = bundle_paths.owner_relative_path(src) label_scoped_owner_path = ctx.label.name + "/" + owner_relative_path.lstrip("/") @@ -53,7 +57,7 @@ def _dtrace_compile_impl(ctx): inputs = [src], outputs = [hdr], mnemonic = "dtraceCompile", - executable = "/usr/sbin/dtrace", + executable = dtrace, arguments = ["-h", "-s", src.path, "-o", hdr.path], progress_message = ("Compiling dtrace probes %s" % (src.basename)), ) @@ -77,6 +81,12 @@ def _dtrace_compile_impl(ctx): dtrace_compile = rule( implementation = _dtrace_compile_impl, attrs = dicts.add(apple_support.action_required_attrs(), { + "dtrace": attr.label( + doc = "dtrace binary to use.", + mandatory = False, + executable = True, + cfg = "exec", + ), "srcs": attr.label_list( allow_files = [".d"], allow_empty = False, diff --git a/doc/rules-dtrace.md b/doc/rules-dtrace.md index a21c16df52..45fe391773 100644 --- a/doc/rules-dtrace.md +++ b/doc/rules-dtrace.md @@ -7,7 +7,7 @@ ## dtrace_compile
-dtrace_compile(name, srcs) +dtrace_compile(name, srcs, dtrace)Compiles @@ -32,5 +32,6 @@ and a target named `dtrace_gen` the header path would be | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | srcs | dtrace(.d) source files to be compiled. | List of labels | optional | `[]` | +| dtrace | dtrace binary to use. | Label | optional | `None` |