load("@rules_cc//cc:defs.bzl", "cc_library")

def rust_cxx_bridge(
        name,
        src,
        include_prefix = None,
        strip_include_prefix = None,
        deps = []):
    native.genrule(
        name = "%s/header" % name,
        srcs = [src],
        outs = [src + ".h"],
        cmd = "$(location //:codegen) --header $< > $@",
        tools = ["//:codegen"],
    )

    native.genrule(
        name = "%s/source" % name,
        srcs = [src],
        outs = [src + ".cc"],
        cmd = "$(location //:codegen) $< > $@",
        tools = ["//:codegen"],
    )

    cc_library(
        name = name,
        srcs = [":%s/source" % name],
        deps = deps + [":%s/include" % name],
    )

    cc_library(
        name = "%s/include" % name,
        hdrs = [":%s/header" % name],
        include_prefix = include_prefix,
        strip_include_prefix = strip_include_prefix,
    )

@@ -1,8 +1,66 @@
+load(%22@bazel_skylib//rules:run_binary.bzl%22, %22run_binary%22)%0A
 load(%22@r
@@ -233,38 +233,34 @@
  = %5B%5D):%0A    
-native.genrule
+run_binary
 (%0A        na
@@ -335,38 +335,40 @@
  %22.h%22%5D,%0A        
-cmd
+args
  = 
+%5B
 %22$(location //:c
@@ -367,37 +367,63 @@
 ion 
-//:codegen) --header $%3C %3E $@%22
+%25s)%22 %25 src, %22-o%22, %22$(location %25s.h)%22 %25 src, %22--header%22%5D
 ,%0A  
@@ -424,37 +424,35 @@
 %22%5D,%0A        tool
-s
  = 
-%5B
 %22//:codegen%22%5D,%0A 
@@ -439,33 +439,32 @@
 l = %22//:codegen%22
-%5D
 ,%0A    )%0A%0A    nat
@@ -464,22 +464,18 @@
     
-native.genrule
+run_binary
 (%0A  
@@ -571,14 +571,16 @@
     
-cmd
+args
  = 
+%5B
 %22$(l
@@ -591,28 +591,52 @@
 ion 
-//:codegen) $%3C %3E $@%22
+%25s)%22 %25 src, %22-o%22, %22$(location %25s.cc)%22 %25 src%5D
 ,%0A  
@@ -645,21 +645,19 @@
     tool
-s
  = 
-%5B
 %22//:code
@@ -660,17 +660,16 @@
 codegen%22
-%5D
 ,%0A    )%0A

Switch from genrule to run_binary for Bazel