Move prebuilt mutators earlier

Move the prebuilt mutators from postdeps to predeps mutators.  This
ensures that the decisions on whether the source or prebuilt will
be used can be made earlier, which simplifies the apex and dexpreopt
code, allowing it to directly depend on the correct module.

This requires some mutators that previously ran before the prebuilt
mutator and now run after the prebuilt mutator be aware of prebuilts.
In particular, the cc.linkageTransitionMutator and
rust.libraryTransitionMutator now have to manually disable prebuilts
when they don't produce a static or shared variant that the source
module produces, and some mutators have to ignore PrebuiltDepTag
dependencies when propagating transitions.

The apexTransitionMutator also needs to temporarily use an interface
on the dependency tag to correctly resolve some dependencies that
exist before the apex variation is created onto the correct variation.
This will shortly be replaced with depending on the apex itself instead,
and then walking the dependencies of the apex to find the necessary
module.

Bug: 372543712
Test: go test ./...
Change-Id: If125ea981be87673bae3bd0a7e3b2c16c337e8f7
diff --git a/cc/library.go b/cc/library.go
index 789190c..dce3b92 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -2229,6 +2229,9 @@
 }
 
 func (linkageTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
+	if ctx.DepTag() == android.PrebuiltDepTag {
+		return sourceVariation
+	}
 	return ""
 }
 
@@ -2285,11 +2288,13 @@
 			library.setStatic()
 			if !library.buildStatic() {
 				library.disablePrebuilt()
+				ctx.Module().(*Module).Prebuilt().SetUsePrebuilt(false)
 			}
 		} else if variation == "shared" {
 			library.setShared()
 			if !library.buildShared() {
 				library.disablePrebuilt()
+				ctx.Module().(*Module).Prebuilt().SetUsePrebuilt(false)
 			}
 		}
 	} else if library, ok := ctx.Module().(LinkableInterface); ok && library.CcLibraryInterface() {
@@ -2402,6 +2407,9 @@
 }
 
 func (versionTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
+	if ctx.DepTag() == android.PrebuiltDepTag {
+		return sourceVariation
+	}
 	return ""
 }