Copy prebuilt binaries

The final name of the prebuilt binary is going to match the basename
of the return value of link(), so copy the binary to the intermediates
directory to a file name that honors the name and stem properties of
the module.

Test: manual
Change-Id: Ieed4df79b11382924ca0be8e940d3279b45f748a
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index ac05df0..976c711 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -116,7 +116,19 @@
 	// TODO(ccross): verify shared library dependencies
 	if len(p.Prebuilt.Properties.Srcs) > 0 {
 		// TODO(ccross): .toc optimization, stripping, packing
-		return p.Prebuilt.Path(ctx)
+
+		// Copy binaries to a name matching the final installed name
+		fileName := p.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
+		outputFile := android.PathForModuleOut(ctx, fileName)
+
+		ctx.ModuleBuild(pctx, android.ModuleBuildParams{
+			Rule:        android.Cp,
+			Description: "prebuilt",
+			Output:      outputFile,
+			Input:       p.Prebuilt.Path(ctx),
+		})
+
+		return outputFile
 	}
 
 	return nil