@@ -41,9 +41,7 @@ def _dtrace_compile_impl(ctx):
4141    output_hdrs  =  []
4242    include_dir  =  None 
4343
44-     dtrace  =  "/usr/sbin/dtrace" 
45-     if  ctx .executable .dtrace :
46-         dtrace  =  ctx .executable .dtrace 
44+     dtrace  =  ctx .executable .dtrace 
4745
4846    for  src  in  ctx .files .srcs :
4947        owner_relative_path  =  bundle_paths .owner_relative_path (src )
@@ -88,16 +86,14 @@ dtrace_compile = rule(
8886            mandatory  =  False ,
8987            executable  =  True ,
9088            cfg  =  "exec" ,
89+             default  =  "//apple:dtrace_wrapper" ,
9190        ),
9291        "srcs" : attr .label_list (
9392            allow_files  =  [".d" ],
9493            allow_empty  =  False ,
9594            doc  =  "dtrace(.d) source files to be compiled." ,
9695        ),
9796    }),
98-     exec_compatible_with  =  [
99-         "@platforms//os:macos" ,
100-     ],
10197    fragments  =  ["apple" ],
10298    doc  =  """ 
10399Compiles 
@@ -116,3 +112,15 @@ and a target named `dtrace_gen` the header path would be
116112`<GENFILES>/dtrace_gen/foo/bar.h`. 
117113""" ,
118114)
115+ 
116+ def  _dtrace_wrapper_impl (ctx ):
117+     dtrace_wrapper  =  ctx .actions .declare_file ("%s.sh"  %  ctx .label .name )
118+     contents  =  """#!/bin/bash 
119+ exec /usr/sbin/dtrace "$@" 
120+ """ 
121+     ctx .actions .write (dtrace_wrapper , contents , is_executable  =  True )
122+     return  [DefaultInfo (files  =  depset ([dtrace_wrapper ]), executable  =  dtrace_wrapper )]
123+ 
124+ dtrace_wrapper  =  rule (
125+     implementation  =  _dtrace_wrapper_impl ,
126+ )
0 commit comments