Merge "Remove armv5te"
diff --git a/cc/builder.go b/cc/builder.go
index de85d6e..db4cb4f 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -508,8 +508,11 @@
 		return
 	}
 
-	arCmd := gccCmd(flags.toolchain, "ar")
-	arFlags := "crsPD"
+	arCmd := "${config.ClangBin}/llvm-ar"
+	arFlags := "crsD"
+	if !ctx.Darwin() {
+		arFlags += " -format=gnu"
+	}
 	if flags.arFlags != "" {
 		arFlags += " " + flags.arFlags
 	}
diff --git a/cc/gen.go b/cc/gen.go
index e9d1e2a..be5e4fc 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -26,8 +26,8 @@
 
 func init() {
 	pctx.SourcePathVariable("lexCmd", "prebuilts/misc/${config.HostPrebuiltTag}/flex/flex-2.5.39")
-	pctx.SourcePathVariable("yaccCmd", "prebuilts/misc/${config.HostPrebuiltTag}/bison/bison")
-	pctx.SourcePathVariable("yaccDataDir", "external/bison/data")
+	pctx.SourcePathVariable("yaccCmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/bison")
+	pctx.SourcePathVariable("yaccDataDir", "prebuilts/build-tools/common/bison")
 
 	pctx.HostBinToolVariable("aidlCmd", "aidl-cpp")
 }
diff --git a/cc/makevars.go b/cc/makevars.go
index 0d2569a..5faf201 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -289,7 +289,7 @@
 	if target.Os == android.Darwin {
 		ctx.Strict(makePrefix+"AR", "${config.MacArPath}")
 	} else {
-		ctx.Strict(makePrefix+"AR", gccCmd(toolchain, "ar"))
+		ctx.Strict(makePrefix+"AR", "${config.ClangBin}/llvm-ar")
 		ctx.Strict(makePrefix+"READELF", gccCmd(toolchain, "readelf"))
 		ctx.Strict(makePrefix+"NM", gccCmd(toolchain, "nm"))
 	}
diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go
index de1fa46..7e8d989 100644
--- a/cc/ndk_prebuilt.go
+++ b/cc/ndk_prebuilt.go
@@ -164,21 +164,9 @@
 }
 
 func getNdkStlLibDir(ctx android.ModuleContext, stl string) android.SourcePath {
-	var libDir string
-	switch stl {
-	case "libstlport":
-		libDir = "cxx-stl/stlport/libs"
-	case "libc++":
-		libDir = "cxx-stl/llvm-libc++/libs"
-	}
-
-	if libDir != "" {
-		ndkSrcRoot := "prebuilts/ndk/current/sources"
-		return android.PathForSource(ctx, ndkSrcRoot).Join(ctx, libDir, ctx.Arch().Abi[0])
-	}
-
-	ctx.ModuleErrorf("Unknown NDK STL: %s", stl)
-	return android.PathForSource(ctx, "")
+	libDir := "cxx-stl/llvm-libc++/libs"
+	ndkSrcRoot := "prebuilts/ndk/current/sources"
+	return android.PathForSource(ctx, ndkSrcRoot).Join(ctx, libDir, ctx.Arch().Abi[0])
 }
 
 func (ndk *ndkPrebuiltStlLinker) link(ctx ModuleContext, flags Flags,
diff --git a/cc/stl.go b/cc/stl.go
index cafb26d..c65f1c2 100644
--- a/cc/stl.go
+++ b/cc/stl.go
@@ -24,8 +24,6 @@
 	switch stl {
 	case "ndk_libc++_shared", "ndk_libc++_static":
 		return "libc++"
-	case "ndk_libstlport_shared", "ndk_libstlport_static":
-		return "stlport"
 	case "ndk_system":
 		return "system"
 	case "":
@@ -37,9 +35,9 @@
 }
 
 type StlProperties struct {
-	// select the STL library to use.  Possible values are "libc++", "libc++_static",
-	// "stlport", "stlport_static", "ndk", "libstdc++", or "none".  Leave blank to select the
-	// default
+	// Select the STL library to use.  Possible values are "libc++",
+	// "libc++_static", "libstdc++", or "none". Leave blank to select the
+	// default.
 	Stl *string `android:"arch_variant"`
 
 	SelectedStl string `blueprint:"mutated"`
@@ -63,8 +61,7 @@
 			switch s {
 			case "":
 				return "ndk_system"
-			case "c++_shared", "c++_static",
-				"stlport_shared", "stlport_static":
+			case "c++_shared", "c++_static":
 				return "ndk_lib" + s
 			case "libc++":
 				return "ndk_libc++_shared"
@@ -132,9 +129,9 @@
 		// The system STL doesn't have a prebuilt (it uses the system's libstdc++), but it does have
 		// its own includes. The includes are handled in CCBase.Flags().
 		deps.SharedLibs = append([]string{"libstdc++"}, deps.SharedLibs...)
-	case "ndk_libc++_shared", "ndk_libstlport_shared":
+	case "ndk_libc++_shared":
 		deps.SharedLibs = append(deps.SharedLibs, stl.Properties.SelectedStl)
-	case "ndk_libc++_static", "ndk_libstlport_static":
+	case "ndk_libc++_static":
 		deps.StaticLibs = append(deps.StaticLibs, stl.Properties.SelectedStl)
 	default:
 		panic(fmt.Errorf("Unknown stl: %q", stl.Properties.SelectedStl))
@@ -168,8 +165,6 @@
 	case "ndk_libc++_shared", "ndk_libc++_static":
 		// TODO(danalbert): This really shouldn't be here...
 		flags.CppFlags = append(flags.CppFlags, "-std=c++11")
-	case "ndk_libstlport_shared", "ndk_libstlport_static":
-		// Nothing
 	case "":
 		// None or error.
 		if !ctx.toolchain().Bionic() {
diff --git a/ui/build/context.go b/ui/build/context.go
index 52a337d..0636631 100644
--- a/ui/build/context.go
+++ b/ui/build/context.go
@@ -103,6 +103,13 @@
 	return false
 }
 
+func (c ContextImpl) IsErrTerminal() bool {
+	if term, ok := os.LookupEnv("TERM"); ok {
+		return term != "dumb" && isTerminal(c.Stderr())
+	}
+	return false
+}
+
 func (c ContextImpl) TermWidth() (int, bool) {
 	return termWidth(c.Stdout())
 }
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index 96f2274..a0e1eca 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -42,6 +42,7 @@
 		config.PrebuiltBuildTool("ckati"),
 		"-f", "build/make/core/config.mk",
 		"--color_warnings",
+		"--kati_stats",
 		"dump-many-vars",
 		"MAKECMDGOALS="+strings.Join(goals, " "))
 	cmd.Environment.Set("CALLED_FROM_SETUP", "true")
@@ -51,15 +52,19 @@
 	}
 	cmd.Environment.Set("DUMP_MANY_VARS", strings.Join(vars, " "))
 	cmd.Sandbox = dumpvarsSandbox
-	// TODO: error out when Stderr contains any content
-	cmd.Stderr = ctx.Stderr()
-	output, err := cmd.Output()
+	output := bytes.Buffer{}
+	cmd.Stdout = &output
+	pipe, err := cmd.StderrPipe()
 	if err != nil {
-		return nil, err
+		ctx.Fatalln("Error getting output pipe for ckati:", err)
 	}
+	cmd.StartOrFatal()
+	// TODO: error out when Stderr contains any content
+	katiRewriteOutput(ctx, pipe)
+	cmd.WaitOrFatal()
 
 	ret := make(map[string]string, len(vars))
-	for _, line := range strings.Split(string(output), "\n") {
+	for _, line := range strings.Split(output.String(), "\n") {
 		if len(line) == 0 {
 			continue
 		}
diff --git a/ui/build/kati.go b/ui/build/kati.go
index 7bb721d..e4715bb 100644
--- a/ui/build/kati.go
+++ b/ui/build/kati.go
@@ -115,6 +115,7 @@
 func katiRewriteOutput(ctx Context, pipe io.ReadCloser) {
 	haveBlankLine := true
 	smartTerminal := ctx.IsTerminal()
+	errSmartTerminal := ctx.IsErrTerminal()
 
 	scanner := bufio.NewScanner(pipe)
 	for scanner.Scan() {
@@ -155,7 +156,7 @@
 			// that message instead of overwriting it.
 			fmt.Fprintln(ctx.Stdout())
 			haveBlankLine = true
-		} else if !smartTerminal {
+		} else if !errSmartTerminal {
 			// Most editors display these as garbage, so strip them out.
 			line = string(stripAnsiEscapes([]byte(line)))
 		}