Skip to content

Commit b5dc9d1

Browse files
authored
Allow setting the dtrace binary (#2607)
Allow setting the dtrace binary in `dtrace_compile`.
1 parent fee0f3b commit b5dc9d1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

apple/dtrace.bzl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def _dtrace_compile_impl(ctx):
3939
output_hdrs = []
4040
include_dir = None
4141

42+
dtrace = "/usr/sbin/dtrace"
43+
if ctx.executable.dtrace:
44+
dtrace = ctx.executable.dtrace
45+
4246
for src in ctx.files.srcs:
4347
owner_relative_path = bundle_paths.owner_relative_path(src)
4448
label_scoped_owner_path = ctx.label.name + "/" + owner_relative_path.lstrip("/")
@@ -53,7 +57,7 @@ def _dtrace_compile_impl(ctx):
5357
inputs = [src],
5458
outputs = [hdr],
5559
mnemonic = "dtraceCompile",
56-
executable = "/usr/sbin/dtrace",
60+
executable = dtrace,
5761
arguments = ["-h", "-s", src.path, "-o", hdr.path],
5862
progress_message = ("Compiling dtrace probes %s" % (src.basename)),
5963
)
@@ -77,6 +81,12 @@ def _dtrace_compile_impl(ctx):
7781
dtrace_compile = rule(
7882
implementation = _dtrace_compile_impl,
7983
attrs = dicts.add(apple_support.action_required_attrs(), {
84+
"dtrace": attr.label(
85+
doc = "dtrace binary to use.",
86+
mandatory = False,
87+
executable = True,
88+
cfg = "exec",
89+
),
8090
"srcs": attr.label_list(
8191
allow_files = [".d"],
8292
allow_empty = False,

doc/rules-dtrace.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
## dtrace_compile
88

99
<pre>
10-
dtrace_compile(<a href="#dtrace_compile-name">name</a>, <a href="#dtrace_compile-srcs">srcs</a>)
10+
dtrace_compile(<a href="#dtrace_compile-name">name</a>, <a href="#dtrace_compile-srcs">srcs</a>, <a href="#dtrace_compile-dtrace">dtrace</a>)
1111
</pre>
1212

1313
Compiles
@@ -32,5 +32,6 @@ and a target named `dtrace_gen` the header path would be
3232
| :------------- | :------------- | :------------- | :------------- | :------------- |
3333
| <a id="dtrace_compile-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
3434
| <a id="dtrace_compile-srcs"></a>srcs | dtrace(.d) source files to be compiled. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
35+
| <a id="dtrace_compile-dtrace"></a>dtrace | dtrace binary to use. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
3536

3637

0 commit comments

Comments
 (0)