Merge changes from topic 'reverse-arch-includes'

* changes:
  Enable mips32r2dsp[r2]-fp in mega device build
  Turn installation on in mega device build
  Prepend arch variant include directories
  Make generated_sources act like generated_headers
  Pass -I to yasm
  Add arm neon and mips dspr2 arch features
diff --git a/android/arch.go b/android/arch.go
index 2d0515f..e21a070 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -417,9 +417,11 @@
 		variants := []string{}
 
 		for _, archVariant := range archVariants[arch] {
+			archVariant := variantReplacer.Replace(archVariant)
 			variants = append(variants, proptools.FieldNameForProperty(archVariant))
 		}
 		for _, feature := range archFeatures[arch] {
+			feature := variantReplacer.Replace(feature)
 			variants = append(variants, proptools.FieldNameForProperty(feature))
 		}
 
@@ -876,12 +878,8 @@
 		{"mips", "mips32r2-fp", "", []string{"mips"}},
 		{"mips", "mips32r2-fp-xburst", "", []string{"mips"}},
 		//{"mips", "mips32r6", "", []string{"mips"}},
-		// mips32r2dsp[r2]-fp fails in the assembler for divdf3.c in compiler-rt:
-		// (same errors in make and soong)
-		//   Error: invalid operands `mtlo $ac0,$11'
-		//   Error: invalid operands `mthi $ac0,$12'
-		//{"mips", "mips32r2dsp-fp", "", []string{"mips"}},
-		//{"mips", "mips32r2dspr2-fp", "", []string{"mips"}},
+		{"mips", "mips32r2dsp-fp", "", []string{"mips"}},
+		{"mips", "mips32r2dspr2-fp", "", []string{"mips"}},
 		// mips64r2 is mismatching 64r2 and 64r6 libraries during linking to libgcc
 		//{"mips64", "mips64r2", "", []string{"mips64"}},
 		{"mips64", "mips64r6", "", []string{"mips64"}},
diff --git a/android/config.go b/android/config.go
index 8efa642..8be16cf 100644
--- a/android/config.go
+++ b/android/config.go
@@ -390,7 +390,12 @@
 }
 
 func (c *config) SkipDeviceInstall() bool {
-	return c.EmbeddedInMake() || Bool(c.Mega_device)
+	return c.EmbeddedInMake()
+}
+
+func (c *config) SkipMegaDeviceInstall(path string) bool {
+	return Bool(c.Mega_device) &&
+		strings.HasPrefix(path, filepath.Join(c.buildDir, "target", "product"))
 }
 
 func (c *config) SanitizeHost() []string {
diff --git a/android/module.go b/android/module.go
index d485fbc..a38c617 100644
--- a/android/module.go
+++ b/android/module.go
@@ -647,14 +647,31 @@
 	return a.module.InstallInSanitizerDir()
 }
 
+func (a *androidModuleContext) skipInstall(fullInstallPath OutputPath) bool {
+	if a.module.base().commonProperties.SkipInstall {
+		return true
+	}
+
+	if a.Device() {
+		if a.AConfig().SkipDeviceInstall() {
+			return true
+		}
+
+		if a.AConfig().SkipMegaDeviceInstall(fullInstallPath.String()) {
+			return true
+		}
+	}
+
+	return false
+}
+
 func (a *androidModuleContext) InstallFileName(installPath OutputPath, name string, srcPath Path,
 	deps ...Path) OutputPath {
 
 	fullInstallPath := installPath.Join(a, name)
 	a.module.base().hooks.runInstallHooks(a, fullInstallPath, false)
 
-	if !a.module.base().commonProperties.SkipInstall &&
-		(!a.Device() || !a.AConfig().SkipDeviceInstall()) {
+	if !a.skipInstall(fullInstallPath) {
 
 		deps = append(deps, a.installDeps...)
 
@@ -691,8 +708,7 @@
 	fullInstallPath := installPath.Join(a, name)
 	a.module.base().hooks.runInstallHooks(a, fullInstallPath, true)
 
-	if !a.module.base().commonProperties.SkipInstall &&
-		(!a.Device() || !a.AConfig().SkipDeviceInstall()) {
+	if !a.skipInstall(fullInstallPath) {
 
 		a.ModuleBuild(pctx, ModuleBuildParams{
 			Rule:      Symlink,
diff --git a/cc/cc.go b/cc/cc.go
index 6e2f6a5..bbdcf6f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -907,6 +907,8 @@
 				} else {
 					ctx.ModuleErrorf("module %q is not a gensrcs or genrule", name)
 				}
+				// Support exported headers from a generated_sources dependency
+				fallthrough
 			case genHeaderDepTag, genHeaderExportDepTag:
 				if genRule, ok := m.(genrule.SourceFileGenerator); ok {
 					depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
diff --git a/cc/compiler.go b/cc/compiler.go
index aed4480..eb30767 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -69,11 +69,11 @@
 	// If possible, don't use this.  If adding paths from the current directory use
 	// local_include_dirs, if adding paths from other modules use export_include_dirs in
 	// that module.
-	Include_dirs []string `android:"arch_variant"`
+	Include_dirs []string `android:"arch_variant,variant_prepend"`
 
 	// list of directories relative to the Blueprints file that will
 	// be added to the include path using -I
-	Local_include_dirs []string `android:"arch_variant"`
+	Local_include_dirs []string `android:"arch_variant,variant_prepend",`
 
 	// list of generated sources to compile. These are the names of gensrcs or
 	// genrule modules.
@@ -198,15 +198,20 @@
 	// Include dir cflags
 	localIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Local_include_dirs)
 	if len(localIncludeDirs) > 0 {
-		flags.GlobalFlags = append(flags.GlobalFlags, includeDirsToFlags(localIncludeDirs))
+		f := includeDirsToFlags(localIncludeDirs)
+		flags.GlobalFlags = append(flags.GlobalFlags, f)
+		flags.YasmFlags = append(flags.YasmFlags, f)
 	}
 	rootIncludeDirs := android.PathsForSource(ctx, compiler.Properties.Include_dirs)
 	if len(rootIncludeDirs) > 0 {
-		flags.GlobalFlags = append(flags.GlobalFlags, includeDirsToFlags(rootIncludeDirs))
+		f := includeDirsToFlags(rootIncludeDirs)
+		flags.GlobalFlags = append(flags.GlobalFlags, f)
+		flags.YasmFlags = append(flags.YasmFlags, f)
 	}
 
 	if !ctx.noDefaultCompilerFlags() {
 		flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String())
+		flags.YasmFlags = append(flags.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String())
 
 		if !(ctx.sdk() || ctx.vndk()) || ctx.Host() {
 			flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go
index 5d17d15..94627e7 100644
--- a/cc/config/arm_device.go
+++ b/cc/config/arm_device.go
@@ -156,20 +156,25 @@
 )
 
 func init() {
+	android.RegisterArchFeatures(android.Arm,
+		"neon")
+
 	android.RegisterArchVariants(android.Arm,
 		"armv5te",
-		"armv7_a",
-		"armv7_a_neon",
-		"cortex_a7",
-		"cortex_a8",
-		"cortex_a9",
-		"cortex_a15",
-		"cortex_a53",
-		"cortex_a53_a57",
+		"armv7-a",
+		"armv7-a-neon",
+		"cortex-a7",
+		"cortex-a8",
+		"cortex-a9",
+		"cortex-a15",
+		"cortex-a53",
+		"cortex-a53-a57",
 		"krait",
 		"kryo",
 		"denver")
 
+	android.RegisterArchVariantFeatures(android.Arm, "armv7-a-neon", "neon")
+
 	// Krait and Kryo targets are not supported by GCC, but are supported by Clang,
 	// so override the definitions when building modules with Clang.
 	replaceFirst(armClangCpuVariantCflags["krait"], "-mcpu=cortex-a15", "-mcpu=krait")
diff --git a/cc/config/mips_device.go b/cc/config/mips_device.go
index ccd60d6..42025a2 100644
--- a/cc/config/mips_device.go
+++ b/cc/config/mips_device.go
@@ -133,7 +133,11 @@
 		"mips32r2dsp_fp",
 		"mips32r2dspr2_fp",
 		"mips32r6")
-	android.RegisterArchFeatures(android.Mips, "rev6")
+	android.RegisterArchFeatures(android.Mips,
+		"dspr2",
+		"rev6")
+	android.RegisterArchVariantFeatures(android.Mips, "mips32r2dspr2_fp",
+		"dspr2")
 	android.RegisterArchVariantFeatures(android.Mips, "mips32r6",
 		"rev6")
 
diff --git a/cc/library.go b/cc/library.go
index e2ec584..86e3269 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -306,7 +306,9 @@
 func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
 	exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
 	if len(exportIncludeDirs) > 0 {
-		flags.GlobalFlags = append(flags.GlobalFlags, includeDirsToFlags(exportIncludeDirs))
+		f := includeDirsToFlags(exportIncludeDirs)
+		flags.GlobalFlags = append(flags.GlobalFlags, f)
+		flags.YasmFlags = append(flags.YasmFlags, f)
 	}
 
 	return library.baseCompiler.compilerFlags(ctx, flags)