Prettify soong ninja build descriptions

Descriptions currently look like:
[  0% 4/29328] cc out-soong/.intermediates/external/clang/lib/Sema/libclangSema/android_arm_armv7-a-neon_denver_static_core/obj/external/clang/lib/Sema/SemaCodeComplete.o

This is not very helpful - most of the characters are used to show the
output path, which contains useful information like target architecture,
but also contains most of the path to the source files twice, and less
useful information like the exact variant name used by soong.
Make the descriptions look like:
[  0% 3/29329] //external/clang/lib/Sema:libclangSema clang++ SemaTemplateInstantiate.cpp

This is //path/to/module:modulename tool relative/path/to/source/file

Test: builds, looks pretty
Change-Id: I3087aa7d4eb1860ef6239d77407b8b35445616d7
diff --git a/android/module.go b/android/module.go
index 90d61e2..8f8f34b 100644
--- a/android/module.go
+++ b/android/module.go
@@ -36,6 +36,7 @@
 	Rule            blueprint.Rule
 	Deps            blueprint.Deps
 	Depfile         WritablePath
+	Description     string
 	Output          WritablePath
 	Outputs         WritablePaths
 	ImplicitOutput  WritablePath
@@ -480,6 +481,23 @@
 		missingDeps:            ctx.GetMissingDependencies(),
 	}
 
+	desc := "//" + ctx.ModuleDir() + ":" + ctx.ModuleName() + " "
+	var suffix []string
+	if androidCtx.Os().Class != Device && androidCtx.Os().Class != Generic {
+		suffix = append(suffix, androidCtx.Os().String())
+	}
+	if !androidCtx.PrimaryArch() {
+		suffix = append(suffix, androidCtx.Arch().ArchType.String())
+	}
+
+	ctx.Variable(pctx, "moduleDesc", desc)
+
+	s := ""
+	if len(suffix) > 0 {
+		s = " [" + strings.Join(suffix, " ") + "]"
+	}
+	ctx.Variable(pctx, "moduleDescSuffix", s)
+
 	if a.Enabled() {
 		a.module.GenerateAndroidBuildActions(androidCtx)
 		if ctx.Failed() {
@@ -516,11 +534,12 @@
 	module          Module
 }
 
-func (a *androidModuleContext) ninjaError(outputs []string, err error) {
+func (a *androidModuleContext) ninjaError(desc string, outputs []string, err error) {
 	a.ModuleContext.Build(pctx, blueprint.BuildParams{
-		Rule:     ErrorRule,
-		Outputs:  outputs,
-		Optional: true,
+		Rule:        ErrorRule,
+		Description: desc,
+		Outputs:     outputs,
+		Optional:    true,
 		Args: map[string]string{
 			"error": err.Error(),
 		},
@@ -530,8 +549,9 @@
 
 func (a *androidModuleContext) Build(pctx blueprint.PackageContext, params blueprint.BuildParams) {
 	if a.missingDeps != nil {
-		a.ninjaError(params.Outputs, fmt.Errorf("module %s missing dependencies: %s\n",
-			a.ModuleName(), strings.Join(a.missingDeps, ", ")))
+		a.ninjaError(params.Description, params.Outputs,
+			fmt.Errorf("module %s missing dependencies: %s\n",
+				a.ModuleName(), strings.Join(a.missingDeps, ", ")))
 		return
 	}
 
@@ -552,6 +572,10 @@
 		Optional:        !params.Default,
 	}
 
+	if params.Description != "" {
+		bparams.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
+	}
+
 	if params.Depfile != nil {
 		bparams.Depfile = params.Depfile.String()
 	}
@@ -569,8 +593,9 @@
 	}
 
 	if a.missingDeps != nil {
-		a.ninjaError(bparams.Outputs, fmt.Errorf("module %s missing dependencies: %s\n",
-			a.ModuleName(), strings.Join(a.missingDeps, ", ")))
+		a.ninjaError(bparams.Description, bparams.Outputs,
+			fmt.Errorf("module %s missing dependencies: %s\n",
+				a.ModuleName(), strings.Join(a.missingDeps, ", ")))
 		return
 	}
 
@@ -624,6 +649,9 @@
 }
 
 func (a *androidBaseContextImpl) PrimaryArch() bool {
+	if len(a.config.Targets[a.target.Os.Class]) <= 1 {
+		return true
+	}
 	return a.target.Arch.ArchType == a.config.Targets[a.target.Os.Class][0].Arch.ArchType
 }
 
@@ -686,12 +714,13 @@
 		}
 
 		a.ModuleBuild(pctx, ModuleBuildParams{
-			Rule:      Cp,
-			Output:    fullInstallPath,
-			Input:     srcPath,
-			Implicits: implicitDeps,
-			OrderOnly: orderOnlyDeps,
-			Default:   !a.AConfig().EmbeddedInMake(),
+			Rule:        Cp,
+			Description: "install " + fullInstallPath.Base(),
+			Output:      fullInstallPath,
+			Input:       srcPath,
+			Implicits:   implicitDeps,
+			OrderOnly:   orderOnlyDeps,
+			Default:     !a.AConfig().EmbeddedInMake(),
 		})
 
 		a.installFiles = append(a.installFiles, fullInstallPath)
@@ -711,10 +740,11 @@
 	if !a.skipInstall(fullInstallPath) {
 
 		a.ModuleBuild(pctx, ModuleBuildParams{
-			Rule:      Symlink,
-			Output:    fullInstallPath,
-			OrderOnly: Paths{srcPath},
-			Default:   !a.AConfig().EmbeddedInMake(),
+			Rule:        Symlink,
+			Description: "install symlink " + fullInstallPath.Base(),
+			Output:      fullInstallPath,
+			OrderOnly:   Paths{srcPath},
+			Default:     !a.AConfig().EmbeddedInMake(),
 			Args: map[string]string{
 				"fromPath": srcPath.String(),
 			},