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/cc/builder.go b/cc/builder.go
index 8a0c7f4..a4fda5b 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -45,7 +45,6 @@
 			Deps:        blueprint.DepsGCC,
 			Command:     "$relPwd ${config.CcWrapper}$ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
 			CommandDeps: []string{"$ccCmd"},
-			Description: "cc $out",
 		},
 		"ccCmd", "cFlags")
 
@@ -54,7 +53,6 @@
 			Command: "$ldCmd ${crtBegin} @${out}.rsp " +
 				"${libFlags} ${crtEnd} -o ${out} ${ldFlags}",
 			CommandDeps:    []string{"$ldCmd"},
-			Description:    "ld $out",
 			Rspfile:        "${out}.rsp",
 			RspfileContent: "${in}",
 		},
@@ -64,7 +62,6 @@
 		blueprint.RuleParams{
 			Command:     "$ldCmd -nostdlib -Wl,-r ${in} -o ${out} ${ldFlags}",
 			CommandDeps: []string{"$ldCmd"},
-			Description: "partialLd $out",
 		},
 		"ldCmd", "ldFlags")
 
@@ -72,7 +69,6 @@
 		blueprint.RuleParams{
 			Command:        "rm -f ${out} && $arCmd $arFlags $out @${out}.rsp",
 			CommandDeps:    []string{"$arCmd"},
-			Description:    "ar $out",
 			Rspfile:        "${out}.rsp",
 			RspfileContent: "${in}",
 		},
@@ -82,7 +78,6 @@
 		blueprint.RuleParams{
 			Command:     "rm -f ${out} && ${config.MacArPath} $arFlags $out $in",
 			CommandDeps: []string{"${config.MacArPath}"},
-			Description: "ar $out",
 		},
 		"arFlags")
 
@@ -90,7 +85,6 @@
 		blueprint.RuleParams{
 			Command:     "cp -f ${inAr} ${out}.tmp && ${config.MacArPath} $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}",
 			CommandDeps: []string{"${config.MacArPath}", "${inAr}"},
-			Description: "ar $out",
 		},
 		"arFlags", "inAr")
 
@@ -98,14 +92,12 @@
 		blueprint.RuleParams{
 			Command:     "${config.MacStripPath} -u -r -o $out $in",
 			CommandDeps: []string{"${config.MacStripPath}"},
-			Description: "strip $out",
 		})
 
 	prefixSymbols = pctx.AndroidStaticRule("prefixSymbols",
 		blueprint.RuleParams{
 			Command:     "$objcopyCmd --prefix-symbols=${prefix} ${in} ${out}",
 			CommandDeps: []string{"$objcopyCmd"},
-			Description: "prefixSymbols $out",
 		},
 		"objcopyCmd", "prefix")
 
@@ -117,14 +109,12 @@
 			Deps:        blueprint.DepsGCC,
 			Command:     "CROSS_COMPILE=$crossCompile $stripPath ${args} -i ${in} -o ${out} -d ${out}.d",
 			CommandDeps: []string{"$stripPath"},
-			Description: "strip $out",
 		},
 		"args", "crossCompile")
 
 	emptyFile = pctx.AndroidStaticRule("emptyFile",
 		blueprint.RuleParams{
-			Command:     "rm -f $out && touch $out",
-			Description: "empty file $out",
+			Command: "rm -f $out && touch $out",
 		})
 
 	_ = pctx.SourcePathVariable("copyGccLibPath", "build/soong/scripts/copygcclib.sh")
@@ -135,7 +125,6 @@
 			Deps:        blueprint.DepsGCC,
 			Command:     "$copyGccLibPath $out $ccCmd $cFlags -print-file-name=${libName}",
 			CommandDeps: []string{"$copyGccLibPath", "$ccCmd"},
-			Description: "copy gcc $out",
 		},
 		"ccCmd", "cFlags", "libName")
 
@@ -155,7 +144,6 @@
 		blueprint.RuleParams{
 			Command:     "rm -f $out && ${config.ClangBin}/clang-tidy $tidyFlags $in -- $cFlags && touch $out",
 			CommandDeps: []string{"${config.ClangBin}/clang-tidy"},
-			Description: "tidy $out",
 		},
 		"cFlags", "tidyFlags")
 
@@ -165,7 +153,6 @@
 		blueprint.RuleParams{
 			Command:     "$yasmCmd $asFlags -o $out $in",
 			CommandDeps: []string{"$yasmCmd"},
-			Description: "yasm $out",
 		},
 		"asFlags")
 
@@ -175,7 +162,6 @@
 		blueprint.RuleParams{
 			Command:     "rm -f $out && $sAbiDumper -o ${out} $in $exportDirs -- $cFlags -Wno-packed -Qunused-arguments -isystem ${config.RSIncludePath}",
 			CommandDeps: []string{"$sAbiDumper"},
-			Description: "header-abi-dumper $in -o $out $exportDirs",
 		},
 		"cFlags", "exportDirs")
 
@@ -185,7 +171,6 @@
 		blueprint.RuleParams{
 			Command:        "$sAbiLinker -o ${out} $symbolFile -arch $arch -api $api $exportedHeaderFlags @${out}.rsp ",
 			CommandDeps:    []string{"$sAbiLinker"},
-			Description:    "header-abi-linker $in -o $out",
 			Rspfile:        "${out}.rsp",
 			RspfileContent: "${in}",
 		},
@@ -197,7 +182,6 @@
 		blueprint.RuleParams{
 			Command:     "$sAbiDiffer -advice-only -o ${out} -new $in -old $referenceDump",
 			CommandDeps: []string{"$sAbiDiffer"},
-			Description: "header-abi-diff -o ${out} -new $in -old $referenceDump",
 		},
 		"referenceDump")
 )
@@ -323,10 +307,11 @@
 
 		if srcFile.Ext() == ".asm" {
 			ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-				Rule:      yasm,
-				Output:    objFile,
-				Input:     srcFile,
-				OrderOnly: deps,
+				Rule:        yasm,
+				Description: "yasm " + srcFile.Rel(),
+				Output:      objFile,
+				Input:       srcFile,
+				OrderOnly:   deps,
 				Args: map[string]string{
 					"asFlags": flags.yasmFlags,
 				},
@@ -367,7 +352,11 @@
 			default:
 				panic("unrecoginzied ccCmd")
 			}
+		}
 
+		ccDesc := ccCmd
+
+		if flags.clang {
 			ccCmd = "${config.ClangBin}/" + ccCmd
 		} else {
 			ccCmd = gccCmd(flags.toolchain, ccCmd)
@@ -382,6 +371,7 @@
 
 		ctx.ModuleBuild(pctx, android.ModuleBuildParams{
 			Rule:            cc,
+			Description:     ccDesc + " " + srcFile.Rel(),
 			Output:          objFile,
 			ImplicitOutputs: implicitOutputs,
 			Input:           srcFile,
@@ -397,9 +387,10 @@
 			tidyFiles = append(tidyFiles, tidyFile)
 
 			ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-				Rule:   clangTidy,
-				Output: tidyFile,
-				Input:  srcFile,
+				Rule:        clangTidy,
+				Description: "clang-tidy " + srcFile.Rel(),
+				Output:      tidyFile,
+				Input:       srcFile,
 				// We must depend on objFile, since clang-tidy doesn't
 				// support exporting dependencies.
 				Implicit: objFile,
@@ -415,10 +406,11 @@
 			sAbiDumpFiles = append(sAbiDumpFiles, sAbiDumpFile)
 
 			ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-				Rule:     sAbiDump,
-				Output:   sAbiDumpFile,
-				Input:    srcFile,
-				Implicit: objFile,
+				Rule:        sAbiDump,
+				Description: "header-abi-dumper " + srcFile.Rel(),
+				Output:      sAbiDumpFile,
+				Input:       srcFile,
+				Implicit:    objFile,
 				Args: map[string]string{
 					"cFlags":     moduleCflags,
 					"exportDirs": flags.sAbiFlags,
@@ -452,10 +444,11 @@
 	}
 
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:      ar,
-		Output:    outputFile,
-		Inputs:    objFiles,
-		Implicits: deps,
+		Rule:        ar,
+		Description: "static link " + outputFile.Base(),
+		Output:      outputFile,
+		Inputs:      objFiles,
+		Implicits:   deps,
 		Args: map[string]string{
 			"arFlags": arFlags,
 			"arCmd":   arCmd,
@@ -477,24 +470,27 @@
 		dummyAr := android.PathForModuleOut(ctx, "dummy"+staticLibraryExtension)
 
 		ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-			Rule:      emptyFile,
-			Output:    dummy,
-			Implicits: deps,
+			Rule:        emptyFile,
+			Description: "empty object file",
+			Output:      dummy,
+			Implicits:   deps,
 		})
 
 		ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-			Rule:   darwinAr,
-			Output: dummyAr,
-			Input:  dummy,
+			Rule:        darwinAr,
+			Description: "empty static archive",
+			Output:      dummyAr,
+			Input:       dummy,
 			Args: map[string]string{
 				"arFlags": arFlags,
 			},
 		})
 
 		ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-			Rule:   darwinAppendAr,
-			Output: outputFile,
-			Input:  dummy,
+			Rule:        darwinAppendAr,
+			Description: "static link " + outputFile.Base(),
+			Output:      outputFile,
+			Input:       dummy,
 			Args: map[string]string{
 				"arFlags": "d",
 				"inAr":    dummyAr.String(),
@@ -519,10 +515,11 @@
 		}
 
 		build := android.ModuleBuildParams{
-			Rule:      darwinAr,
-			Output:    out,
-			Inputs:    l,
-			Implicits: deps,
+			Rule:        darwinAr,
+			Description: "static link " + out.Base(),
+			Output:      out,
+			Inputs:      l,
+			Implicits:   deps,
 			Args: map[string]string{
 				"arFlags": arFlags,
 			},
@@ -592,10 +589,11 @@
 	}
 
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:      ld,
-		Output:    outputFile,
-		Inputs:    objFiles,
-		Implicits: deps,
+		Rule:        ld,
+		Description: "link " + outputFile.Base(),
+		Output:      outputFile,
+		Inputs:      objFiles,
+		Implicits:   deps,
 		Args: map[string]string{
 			"ldCmd":    ldCmd,
 			"crtBegin": crtBegin.String(),
@@ -618,10 +616,11 @@
 		linkedDumpDep = symbolFile.Path()
 	}
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:     sAbiLink,
-		Output:   outputFile,
-		Inputs:   sAbiDumps,
-		Implicit: linkedDumpDep,
+		Rule:        sAbiLink,
+		Description: "header-abi-linker " + outputFile.Base(),
+		Output:      outputFile,
+		Inputs:      sAbiDumps,
+		Implicit:    linkedDumpDep,
 		Args: map[string]string{
 			"symbolFile": symbolFileStr,
 			"arch":       ctx.Arch().ArchType.Name,
@@ -636,10 +635,11 @@
 	baseName string) android.OptionalPath {
 	outputFile := android.PathForModuleOut(ctx, baseName+".abidiff")
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:     sAbiDiff,
-		Output:   outputFile,
-		Input:    inputDump,
-		Implicit: referenceDump,
+		Rule:        sAbiDiff,
+		Description: "header-abi-diff " + outputFile.Base(),
+		Output:      outputFile,
+		Input:       inputDump,
+		Implicit:    referenceDump,
 		Args: map[string]string{
 			"referenceDump": referenceDump.String(),
 		},
@@ -654,9 +654,10 @@
 	crossCompile := gccCmd(flags.toolchain, "")
 
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:   toc,
-		Output: outputFile,
-		Input:  inputFile,
+		Rule:        toc,
+		Description: "generate toc " + inputFile.Base(),
+		Output:      outputFile,
+		Input:       inputFile,
 		Args: map[string]string{
 			"crossCompile": crossCompile,
 		},
@@ -675,9 +676,10 @@
 	}
 
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:   partialLd,
-		Output: outputFile,
-		Inputs: objFiles,
+		Rule:        partialLd,
+		Description: "link " + outputFile.Base(),
+		Output:      outputFile,
+		Inputs:      objFiles,
 		Args: map[string]string{
 			"ldCmd":   ldCmd,
 			"ldFlags": flags.ldFlags,
@@ -692,9 +694,10 @@
 	objcopyCmd := gccCmd(flags.toolchain, "objcopy")
 
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:   prefixSymbols,
-		Output: outputFile,
-		Input:  inputFile,
+		Rule:        prefixSymbols,
+		Description: "prefix symbols " + outputFile.Base(),
+		Output:      outputFile,
+		Input:       inputFile,
 		Args: map[string]string{
 			"objcopyCmd": objcopyCmd,
 			"prefix":     prefix,
@@ -718,9 +721,10 @@
 	}
 
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:   strip,
-		Output: outputFile,
-		Input:  inputFile,
+		Rule:        strip,
+		Description: "strip " + outputFile.Base(),
+		Output:      outputFile,
+		Input:       inputFile,
 		Args: map[string]string{
 			"crossCompile": crossCompile,
 			"args":         args,
@@ -732,9 +736,10 @@
 	outputFile android.WritablePath) {
 
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:   darwinStrip,
-		Output: outputFile,
-		Input:  inputFile,
+		Rule:        darwinStrip,
+		Description: "strip " + outputFile.Base(),
+		Output:      outputFile,
+		Input:       inputFile,
 	})
 }
 
@@ -756,8 +761,9 @@
 	flags builderFlags, outputFile android.WritablePath) {
 
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
-		Rule:   copyGccLib,
-		Output: outputFile,
+		Rule:        copyGccLib,
+		Description: "copy gcc library " + libName,
+		Output:      outputFile,
 		Args: map[string]string{
 			"ccCmd":   gccCmd(flags.toolchain, "gcc"),
 			"cFlags":  flags.globalFlags,