Implement bp2build converter for rust_proc_macro

Test: WIP
Bug: 297356482
Change-Id: I17d1a0a95d4a67ccbc9b2d74e49bcacd6ff4d26b
diff --git a/rust/library.go b/rust/library.go
index da386b3..da2209a 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -800,49 +800,29 @@
 }
 
 type rustLibraryAttributes struct {
-	Srcs           bazel.LabelListAttribute
-	Compile_data   bazel.LabelListAttribute
-	Crate_name     bazel.StringAttribute
-	Edition        bazel.StringAttribute
-	Crate_features bazel.StringListAttribute
-	Deps           bazel.LabelListAttribute
-	Rustc_flags    bazel.StringListAttribute
+	Srcs            bazel.LabelListAttribute
+	Compile_data    bazel.LabelListAttribute
+	Crate_name      bazel.StringAttribute
+	Edition         bazel.StringAttribute
+	Crate_features  bazel.StringListAttribute
+	Deps            bazel.LabelListAttribute
+	Rustc_flags     bazel.StringListAttribute
+	Proc_macro_deps bazel.LabelListAttribute
 }
 
 func libraryBp2build(ctx android.TopDownMutatorContext, m *Module) {
 	lib := m.compiler.(*libraryDecorator)
-
-	var srcs bazel.LabelList
-	var compileData bazel.LabelList
-	var rustcFLags []string
-
-	// This is a workaround by assuming the conventions that rust crate repos are structured
-	//  while waiting for the sandboxing work to complete.
-	// TODO: When crate_root prop is set which enforces inputs sandboxing,
-	// always use `srcs` and `compile_data` props to generate `srcs` and `compile_data` attributes
-	// instead of using globs.
-	if lib.baseCompiler.Properties.Srcs[0] == "src/lib.rs" {
-		srcs = android.BazelLabelForModuleSrc(ctx, []string{"src/**/*.rs"})
-		compileData = android.BazelLabelForModuleSrc(
-			ctx,
-			[]string{
-				"src/**/*.proto",
-				"examples/**/*.rs",
-				"**/*.md",
-			},
-		)
-	} else {
-		srcs = android.BazelLabelForModuleSrc(ctx, lib.baseCompiler.Properties.Srcs)
-	}
-
-	for _, cfg := range lib.baseCompiler.Properties.Cfgs {
-		rustcFLags = append(rustcFLags, fmt.Sprintf("--cfg=%s", cfg))
-	}
-
+	srcs, compileData := srcsAndCompileDataAttrs(ctx, *lib.baseCompiler)
 	deps := android.BazelLabelForModuleDeps(ctx, append(
 		lib.baseCompiler.Properties.Rustlibs,
 		lib.baseCompiler.Properties.Rlibs...,
 	))
+	procMacroDeps := android.BazelLabelForModuleDeps(ctx, lib.baseCompiler.Properties.Proc_macros)
+
+	var rustcFLags []string
+	for _, cfg := range lib.baseCompiler.Properties.Cfgs {
+		rustcFLags = append(rustcFLags, fmt.Sprintf("--cfg=%s", cfg))
+	}
 
 	attrs := &rustLibraryAttributes{
 		Srcs: bazel.MakeLabelListAttribute(
@@ -863,6 +843,9 @@
 		Deps: bazel.MakeLabelListAttribute(
 			deps,
 		),
+		Proc_macro_deps: bazel.MakeLabelListAttribute(
+			procMacroDeps,
+		),
 		Rustc_flags: bazel.StringListAttribute{
 			Value: append(
 				rustcFLags,