Merge "Add Rust support to Soong."
diff --git a/apex/apex.go b/apex/apex.go
index 9e7f3a0..806158a 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -984,6 +984,8 @@
 					}
 				} else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
 					ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
+				} else if am.NoApex() && !android.InList(depName, whitelistNoApex[ctx.ModuleName()]) {
+					ctx.ModuleErrorf("tries to include no_apex module %s", depName)
 				}
 			}
 		}
@@ -1211,6 +1213,13 @@
 			optFlags = append(optFlags, "--assets_dir "+filepath.Dir(noticeFile.String()))
 		}
 
+		if !ctx.Config().UnbundledBuild() && a.installable() {
+			// Apexes which are supposed to be installed in builtin dirs(/system, etc)
+			// don't need hashtree for activation. Therefore, by removing hashtree from
+			// apex bundle (filesystem image in it, to be specific), we can save storage.
+			optFlags = append(optFlags, "--no_hashtree")
+		}
+
 		ctx.Build(pctx, android.BuildParams{
 			Rule:        apexRule,
 			Implicits:   implicitInputs,
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 387533c..0845b20 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -1851,6 +1851,36 @@
 		}
 	`)
 
+	testApexError(t, `tries to include no_apex module mylib2`, `
+		apex {
+			name: "commonapex",
+			key: "myapex.key",
+			native_shared_libs: ["mylib"],
+		}
+
+		apex_key {
+			name: "myapex.key",
+			public_key: "testkey.avbpubkey",
+			private_key: "testkey.pem",
+		}
+
+		cc_library {
+			name: "mylib",
+			srcs: ["mylib.cpp"],
+			static_libs: ["mylib2"],
+			system_shared_libs: [],
+			stl: "none",
+		}
+
+		cc_library {
+			name: "mylib2",
+			srcs: ["mylib.cpp"],
+			system_shared_libs: [],
+			stl: "none",
+			no_apex: true,
+		}
+	`)
+
 	ctx, _ := testApex(t, `
 		apex {
 			name: "myapex",
diff --git a/cc/builder.go b/cc/builder.go
index 00dc742..554706c 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -271,6 +271,8 @@
 	sAbiDump        bool
 	emitXrefs       bool
 
+	assemblerWithCpp bool
+
 	systemIncludeFlags string
 
 	groupStaticLibs bool
@@ -428,7 +430,9 @@
 
 		switch srcFile.Ext() {
 		case ".s":
-			rule = ccNoDeps
+			if !flags.assemblerWithCpp {
+				rule = ccNoDeps
+			}
 			fallthrough
 		case ".S":
 			ccCmd = "clang"
diff --git a/cc/cc.go b/cc/cc.go
index 26cec90..2ff3434 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -174,7 +174,8 @@
 	CFlagsDeps  android.Paths // Files depended on by compiler flags
 	LdFlagsDeps android.Paths // Files depended on by linker flags
 
-	GroupStaticLibs bool
+	AssemblerWithCpp bool
+	GroupStaticLibs  bool
 
 	proto            android.ProtoFlags
 	protoC           bool // Whether to use C instead of C++
@@ -1061,6 +1062,9 @@
 	if c.sabi != nil {
 		flags = c.sabi.flags(ctx, flags)
 	}
+
+	flags.AssemblerWithCpp = inList("-xassembler-with-cpp", flags.AsFlags)
+
 	// Optimization to reduce size of build.ninja
 	// Replace the long list of flags for each file with a module-local variable
 	ctx.Variable(pctx, "cflags", strings.Join(flags.CFlags, " "))
diff --git a/cc/util.go b/cc/util.go
index fb6338a..7b8ad18 100644
--- a/cc/util.go
+++ b/cc/util.go
@@ -79,7 +79,8 @@
 
 		systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
 
-		groupStaticLibs: in.GroupStaticLibs,
+		assemblerWithCpp: in.AssemblerWithCpp,
+		groupStaticLibs:  in.GroupStaticLibs,
 
 		proto:            in.proto,
 		protoC:           in.protoC,
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index a1d650a..738ef40 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -118,63 +118,19 @@
 	"ld.gold":    Forbidden,
 	"pkg-config": Forbidden,
 
-	// On Linux we'll use the toybox versions of these instead.
-	"basename": LinuxOnlyPrebuilt,
-	"cat":      LinuxOnlyPrebuilt,
-	"chmod":    LinuxOnlyPrebuilt,
-	"cmp":      LinuxOnlyPrebuilt,
-	"cp":       LinuxOnlyPrebuilt,
-	"comm":     LinuxOnlyPrebuilt,
-	"cut":      LinuxOnlyPrebuilt,
-	"date":     LinuxOnlyPrebuilt,
-	"dirname":  LinuxOnlyPrebuilt,
-	"du":       LinuxOnlyPrebuilt,
-	"echo":     LinuxOnlyPrebuilt,
-	"egrep":    LinuxOnlyPrebuilt,
-	"env":      LinuxOnlyPrebuilt,
-	"getconf":  LinuxOnlyPrebuilt,
-	"grep":     LinuxOnlyPrebuilt,
-	"head":     LinuxOnlyPrebuilt,
-	"hostname": LinuxOnlyPrebuilt,
-	"id":       LinuxOnlyPrebuilt,
-	"ln":       LinuxOnlyPrebuilt,
-	"ls":       LinuxOnlyPrebuilt,
-	"mkdir":    LinuxOnlyPrebuilt,
-	"mktemp":   LinuxOnlyPrebuilt,
-	"mv":       LinuxOnlyPrebuilt,
-	"od":       LinuxOnlyPrebuilt,
-	"paste":    LinuxOnlyPrebuilt,
-	"pgrep":    LinuxOnlyPrebuilt,
-	"pkill":    LinuxOnlyPrebuilt,
-	"ps":       LinuxOnlyPrebuilt,
-	"pwd":      LinuxOnlyPrebuilt,
-	"readlink": LinuxOnlyPrebuilt,
-	"rm":       LinuxOnlyPrebuilt,
-	"rmdir":    LinuxOnlyPrebuilt,
-	"sed":      LinuxOnlyPrebuilt,
-	"seq":      LinuxOnlyPrebuilt,
-	"setsid":   LinuxOnlyPrebuilt,
-	"sleep":    LinuxOnlyPrebuilt,
-	"sort":     LinuxOnlyPrebuilt,
-	"stat":     LinuxOnlyPrebuilt,
-	"tail":     LinuxOnlyPrebuilt,
-	"tar":      LinuxOnlyPrebuilt,
-	"tee":      LinuxOnlyPrebuilt,
-	"timeout":  LinuxOnlyPrebuilt,
-	"touch":    LinuxOnlyPrebuilt,
-	"true":     LinuxOnlyPrebuilt,
-	"uname":    LinuxOnlyPrebuilt,
-	"uniq":     LinuxOnlyPrebuilt,
-	"unix2dos": LinuxOnlyPrebuilt,
-	"wc":       LinuxOnlyPrebuilt,
-	"whoami":   LinuxOnlyPrebuilt,
-	"which":    LinuxOnlyPrebuilt,
-	"xargs":    LinuxOnlyPrebuilt,
-	"xxd":      LinuxOnlyPrebuilt,
+	// These are currently Linux-only toybox tools (but can be switched now).
+	"date": LinuxOnlyPrebuilt,
+	"stat": LinuxOnlyPrebuilt,
+
+	// These are toybox tools that only work on Linux.
+	"pgrep": LinuxOnlyPrebuilt,
+	"pkill": LinuxOnlyPrebuilt,
+	"ps":    LinuxOnlyPrebuilt,
 }
 
 func init() {
 	if runtime.GOOS == "darwin" {
+		// TODO: move Darwin off md5 and onto our md5sum prebuilt.
 		Configuration["md5"] = Allowed
 		Configuration["sw_vers"] = Allowed
 		Configuration["xcrun"] = Allowed