Support prepended arch-specific properties

Arch-specific static libraries should be prepended so that the common
static libraries can depend on them.

Bug: 26968262
Change-Id: I40a21d18ece8f6d20824437e7180628b29ffdd04
diff --git a/cc/cc.go b/cc/cc.go
index f740ebc..a599bfb 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -306,10 +306,10 @@
 	// in their entirety.  For static library modules, all of the .o files from the intermediate
 	// directory of the dependency will be linked into this modules .a file.  For a shared library,
 	// the dependency's .a file will be linked into this module using -Wl,--whole-archive.
-	Whole_static_libs []string `android:"arch_variant"`
+	Whole_static_libs []string `android:"arch_variant,variant_prepend"`
 
 	// list of modules that should be statically linked into this module.
-	Static_libs []string `android:"arch_variant"`
+	Static_libs []string `android:"arch_variant,variant_prepend"`
 
 	// list of modules that should be dynamically linked into this module.
 	Shared_libs []string `android:"arch_variant"`
diff --git a/common/arch.go b/common/arch.go
index b92e05b..23ec550 100644
--- a/common/arch.go
+++ b/common/arch.go
@@ -621,7 +621,17 @@
 		return true, nil
 	}
 
-	err := proptools.AppendProperties(dst, src, filter)
+	order := func(property string,
+		dstField, srcField reflect.StructField,
+		dstValue, srcValue interface{}) (proptools.Order, error) {
+		if proptools.HasTag(dstField, "android", "variant_prepend") {
+			return proptools.Prepend, nil
+		} else {
+			return proptools.Append, nil
+		}
+	}
+
+	err := proptools.ExtendProperties(dst, src, filter, order)
 	if err != nil {
 		if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
 			ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())