Merge "Use android.InList for inList"
diff --git a/cc/builder.go b/cc/builder.go
index 279c1da..8f253ca 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -172,7 +172,7 @@
 		},
 		"windresCmd", "flags")
 
-	_ = pctx.SourcePathVariable("sAbiDumper", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/header-abi-dumper")
+	_ = pctx.SourcePathVariable("sAbiDumper", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/header-abi-dumper")
 
 	// -w has been added since header-abi-dumper does not need to produce any sort of diagnostic information.
 	sAbiDump = pctx.AndroidStaticRule("sAbiDump",
@@ -182,7 +182,7 @@
 		},
 		"cFlags", "exportDirs")
 
-	_ = pctx.SourcePathVariable("sAbiLinker", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/header-abi-linker")
+	_ = pctx.SourcePathVariable("sAbiLinker", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/header-abi-linker")
 
 	sAbiLink = pctx.AndroidStaticRule("sAbiLink",
 		blueprint.RuleParams{
@@ -193,7 +193,7 @@
 		},
 		"symbolFilter", "arch", "exportedHeaderFlags")
 
-	_ = pctx.SourcePathVariable("sAbiDiffer", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/header-abi-diff")
+	_ = pctx.SourcePathVariable("sAbiDiffer", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/header-abi-diff")
 
 	sAbiDiff = pctx.AndroidRuleFunc("sAbiDiff",
 		func(config android.Config) (blueprint.RuleParams, error) {
diff --git a/cc/vndk.go b/cc/vndk.go
index d417bea..a0d338b 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -178,7 +178,7 @@
 
 // gather list of vndk-core, vndk-sp, and ll-ndk libs
 func vndkMutator(mctx android.BottomUpMutatorContext) {
-	if m, ok := mctx.Module().(*Module); ok {
+	if m, ok := mctx.Module().(*Module); ok && m.Enabled() {
 		if lib, ok := m.linker.(*llndkStubDecorator); ok {
 			vndkLibrariesLock.Lock()
 			defer vndkLibrariesLock.Unlock()
diff --git a/cmd/sbox/sbox.go b/cmd/sbox/sbox.go
index 3b41c90..0af1886 100644
--- a/cmd/sbox/sbox.go
+++ b/cmd/sbox/sbox.go
@@ -136,14 +136,11 @@
 
 	tempDir, err := ioutil.TempDir(sandboxesRoot, "sbox")
 
-	// Rewrite output file paths to be relative to output root
-	// This facilitates matching them up against the corresponding paths in the temporary directory in case they're absolute
 	for i, filePath := range outputsVarEntries {
-		relativePath, err := filepath.Rel(outputRoot, filePath)
-		if err != nil {
-			return err
+		if !strings.HasPrefix(filePath, "__SBOX_OUT_DIR__/") {
+			return fmt.Errorf("output files must start with `__SBOX_OUT_DIR__/`")
 		}
-		outputsVarEntries[i] = relativePath
+		outputsVarEntries[i] = strings.TrimPrefix(filePath, "__SBOX_OUT_DIR__/")
 	}
 
 	allOutputs = append([]string(nil), outputsVarEntries...)
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 4f3ba93..e423ebc 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -112,9 +112,10 @@
 type taskFunc func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) generateTask
 
 type generateTask struct {
-	in  android.Paths
-	out android.WritablePaths
-	cmd string
+	in          android.Paths
+	out         android.WritablePaths
+	sandboxOuts []string
+	cmd         string
 }
 
 func (g *Module) GeneratedSourceFiles() android.Paths {
@@ -320,7 +321,7 @@
 		Inputs:          task.in,
 		Implicits:       g.deps,
 		Args: map[string]string{
-			"allouts": strings.Join(task.out.Strings(), " "),
+			"allouts": strings.Join(task.sandboxOuts, " "),
 		},
 	}
 	if Bool(g.properties.Depfile) {
@@ -346,23 +347,31 @@
 	return module
 }
 
+// replace "out" with "__SBOX_OUT_DIR__/<the value of ${out}>"
+func pathToSandboxOut(path android.Path, genDir android.Path) string {
+	relOut, err := filepath.Rel(genDir.String(), path.String())
+	if err != nil {
+		panic(fmt.Sprintf("Could not make ${out} relative: %v", err))
+	}
+	return filepath.Join("__SBOX_OUT_DIR__", relOut)
+
+}
+
 func NewGenSrcs() *Module {
 	properties := &genSrcsProperties{}
 
 	taskGenerator := func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) generateTask {
 		commands := []string{}
 		outFiles := android.WritablePaths{}
-		genPath := android.PathForModuleGen(ctx).String()
+		genDir := android.PathForModuleGen(ctx)
+		sandboxOuts := []string{}
 		for _, in := range srcFiles {
 			outFile := android.GenPathWithExt(ctx, "", in, String(properties.Output_extension))
 			outFiles = append(outFiles, outFile)
 
-			// replace "out" with "__SBOX_OUT_DIR__/<the value of ${out}>"
-			relOut, err := filepath.Rel(genPath, outFile.String())
-			if err != nil {
-				panic(fmt.Sprintf("Could not make ${out} relative: %v", err))
-			}
-			sandboxOutfile := filepath.Join("__SBOX_OUT_DIR__", relOut)
+			sandboxOutfile := pathToSandboxOut(outFile, genDir)
+			sandboxOuts = append(sandboxOuts, sandboxOutfile)
+
 			command, err := android.Expand(rawCommand, func(name string) (string, error) {
 				switch name {
 				case "in":
@@ -384,9 +393,10 @@
 		fullCommand := strings.Join(commands, " && ")
 
 		return generateTask{
-			in:  srcFiles,
-			out: outFiles,
-			cmd: fullCommand,
+			in:          srcFiles,
+			out:         outFiles,
+			sandboxOuts: sandboxOuts,
+			cmd:         fullCommand,
 		}
 	}
 
@@ -409,13 +419,17 @@
 
 	taskGenerator := func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) generateTask {
 		outs := make(android.WritablePaths, len(properties.Out))
+		sandboxOuts := make([]string, len(properties.Out))
+		genDir := android.PathForModuleGen(ctx)
 		for i, out := range properties.Out {
 			outs[i] = android.PathForModuleGen(ctx, out)
+			sandboxOuts[i] = pathToSandboxOut(outs[i], genDir)
 		}
 		return generateTask{
-			in:  srcFiles,
-			out: outs,
-			cmd: rawCommand,
+			in:          srcFiles,
+			out:         outs,
+			sandboxOuts: sandboxOuts,
+			cmd:         rawCommand,
 		}
 	}