Use manifest merger in Soong

Move the manifest merger config to Soong, and use it to merge
manifests of static dependencies of android_library and android_app
modules.

Bug: 110848854
Test: m checkbuild
Change-Id: Ib89e1f1a52a8b76157e4e0348baf42800412df0d
Merged-In: Ib89e1f1a52a8b76157e4e0348baf42800412df0d
Merged-In: I5d055ce63b8371db500f8868fb73ab3604b8c24a
diff --git a/android/makevars.go b/android/makevars.go
index 3094a48..accc4d3 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -20,6 +20,7 @@
 	"io/ioutil"
 	"os"
 	"strconv"
+	"strings"
 
 	"github.com/google/blueprint/proptools"
 )
@@ -240,8 +241,16 @@
 	return c.ctx
 }
 
+var ninjaDescaper = strings.NewReplacer("$$", "$")
+
 func (c *makeVarsContext) Eval(ninjaStr string) (string, error) {
-	return c.ctx.Eval(c.pctx, ninjaStr)
+	s, err := c.ctx.Eval(c.pctx, ninjaStr)
+	if err != nil {
+		return "", err
+	}
+	// SingletonContext.Eval returns an exapnded string that is valid for a ninja file, de-escape $$ to $ for use
+	// in a Makefile
+	return ninjaDescaper.Replace(s), nil
 }
 
 func (c *makeVarsContext) addVariableRaw(name, value string, strict, sort bool) {