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

def rust_cxx_bridge(
        name,
        src,
        include_prefix = None,
        strip_include_prefix = None,
        deps = []):
    run_binary(
        name = "%s/header" % name,
        srcs = [src],
        outs = [src + ".h"],
        args = [
            "$(location %s)" % src,
            "-o",
            "$(location %s.h)" % src,
            "--header",
        ],
        tool = "//:codegen",
    )

    run_binary(
        name = "%s/source" % name,
        srcs = [src],
        outs = [src + ".cc"],
        args = [
            "$(location %s)" % src,
            "-o",
            "$(location %s.cc)" % src,
        ],
        tool = "//: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,
    )

@@ -233,34 +233,36 @@
  = %5B%5D):%0A    
-run_binary
+native.alias
 (%0A        na
@@ -298,38 +298,17 @@
     
-srcs = %5Bsrc%5D,%0A        outs
+actual
  = 
-%5B
 src 
@@ -317,181 +317,97 @@
 %22.h%22
-%5D
 ,%0A    
-    args = %5B%0A            %22$(location %25s)%22 %25 src,%0A            %22-o%22,%0A            %22$(location %25s.h)%22 %25 src,%0A            %22--header%22,%0A        %5D,%0A        tool = %22//:codegen
+)%0A%0A    native.alias(%0A        name = %22%25s/source%22 %25 name,%0A        actual = src + %22.cc
 %22,%0A 
@@ -439,38 +439,41 @@
      name = %22%25s/
-source
+generated
 %22 %25 name,%0A      
@@ -504,16 +504,53 @@
 outs = %5B
+%0A            src + %22.h%22,%0A            
 src + %22.
@@ -552,16 +552,26 @@
  + %22.cc%22
+,%0A        
 %5D,%0A     
@@ -636,16 +636,72 @@
   %22-o%22,%0A
+            %22$(location %25s.h)%22 %25 src,%0A            %22-o%22,%0A
         
@@ -835,27 +835,19 @@
  = %5B
-%22:%25s/source%22 %25 name
+src + %22.cc%22
 %5D,%0A 
@@ -970,27 +970,18 @@
  = %5B
-%22:%25s/header%22 %25 name
+src + %22.h%22
 %5D,%0A 

Combine bazel codegen steps into one run of cxxbridge