Merge "Install VNDK libs in /system instead of /vendor"
diff --git a/android/config.go b/android/config.go
index 661e333..5dcc59b 100644
--- a/android/config.go
+++ b/android/config.go
@@ -530,20 +530,21 @@
 func (c *deviceConfig) CoverageEnabledForPath(path string) bool {
 	coverage := false
 	if c.config.ProductVariables.CoveragePaths != nil {
-		for _, prefix := range *c.config.ProductVariables.CoveragePaths {
-			if strings.HasPrefix(path, prefix) {
-				coverage = true
-				break
-			}
+		if prefixInList(path, *c.config.ProductVariables.CoveragePaths) {
+			coverage = true
 		}
 	}
 	if coverage && c.config.ProductVariables.CoverageExcludePaths != nil {
-		for _, prefix := range *c.config.ProductVariables.CoverageExcludePaths {
-			if strings.HasPrefix(path, prefix) {
-				coverage = false
-				break
-			}
+		if prefixInList(path, *c.config.ProductVariables.CoverageExcludePaths) {
+			coverage = false
 		}
 	}
 	return coverage
 }
+
+func (c *config) IntegerOverflowDisabledForPath(path string) bool {
+	if c.ProductVariables.IntegerOverflowExcludePaths == nil {
+		return false
+	}
+	return prefixInList(path, *c.ProductVariables.IntegerOverflowExcludePaths)
+}
diff --git a/android/util.go b/android/util.go
index 8cee256..80c7870 100644
--- a/android/util.go
+++ b/android/util.go
@@ -68,6 +68,15 @@
 	return indexList(s, list) != -1
 }
 
+func prefixInList(s string, list []string) bool {
+	for _, prefix := range list {
+		if strings.HasPrefix(s, prefix) {
+			return true
+		}
+	}
+	return false
+}
+
 // checkCalledFromInit panics if a Go package's init function is not on the
 // call stack.
 func checkCalledFromInit() {
diff --git a/android/variable.go b/android/variable.go
index 7ca7a55..8462d0d 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -140,6 +140,8 @@
 	Treble                     *bool `json:",omitempty"`
 	Pdk                        *bool `json:",omitempty"`
 
+	IntegerOverflowExcludePaths *[]string `json:",omitempty"`
+
 	VendorPath *string `json:",omitempty"`
 
 	ClangTidy  *bool   `json:",omitempty"`
diff --git a/build.ninja.in b/build.ninja.in
index 8aa0f76..27f1db0 100644
--- a/build.ninja.in
+++ b/build.ninja.in
@@ -436,7 +436,7 @@
 # Variant:
 # Type:    bootstrap_core_go_binary
 # Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
-# Defined: build/blueprint/Blueprints:130:1
+# Defined: build/blueprint/Blueprints:131:1
 
 build ${g.bootstrap.buildDir}/.bootstrap/bpglob/obj/bpglob.a: $
         g.bootstrap.compile $
@@ -464,7 +464,7 @@
 # Variant:
 # Type:    bootstrap_core_go_binary
 # Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
-# Defined: build/blueprint/Blueprints:148:1
+# Defined: build/blueprint/Blueprints:149:1
 
 build ${g.bootstrap.buildDir}/.bootstrap/gotestmain/obj/gotestmain.a: $
         g.bootstrap.compile $
@@ -484,11 +484,68 @@
 default ${g.bootstrap.BinDir}/gotestmain
 
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Module:  gotestmain-tests
+# Variant:
+# Type:    bootstrap_go_package
+# Factory: github.com/google/blueprint/bootstrap.newGoPackageModuleFactory.func1
+# Defined: build/blueprint/Blueprints:156:1
+
+build $
+        ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/github.com/google/blueprint/gotestmain.a $
+        : g.bootstrap.compile $
+        ${g.bootstrap.srcDir}/build/blueprint/gotestmain/dummy.go $
+        ${g.bootstrap.srcDir}/build/blueprint/gotestmain/testmain_test.go | $
+        ${g.bootstrap.compileCmd}
+    pkgPath = github.com/google/blueprint/gotestmain
+default $
+        ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/github.com/google/blueprint/gotestmain.a
+
+build ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test.go: $
+        g.bootstrap.gotestmain $
+        ${g.bootstrap.srcDir}/build/blueprint/gotestmain/testmain_test.go | $
+        ${g.bootstrap.goTestMainCmd}
+    pkg = github.com/google/blueprint/gotestmain
+default ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test.go
+
+build ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test.a: $
+        g.bootstrap.compile $
+        ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test.go | $
+        ${g.bootstrap.compileCmd} $
+        ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/github.com/google/blueprint/gotestmain.a
+    incFlags = -I ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test
+    pkgPath = main
+default ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test.a
+
+build ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test: $
+        g.bootstrap.link $
+        ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test.a | $
+        ${g.bootstrap.linkCmd}
+    libDirFlags = -L ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test
+default ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test
+
+build ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test.passed: $
+        g.bootstrap.test $
+        ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test | $
+        ${g.bootstrap.goTestRunnerCmd}
+    pkg = github.com/google/blueprint/gotestmain
+    pkgSrcDir = ${g.bootstrap.srcDir}/build/blueprint/gotestmain
+default ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test.passed
+
+build $
+        ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/pkg/github.com/google/blueprint/gotestmain.a $
+        : g.bootstrap.compile $
+        ${g.bootstrap.srcDir}/build/blueprint/gotestmain/dummy.go | $
+        ${g.bootstrap.compileCmd}
+    pkgPath = github.com/google/blueprint/gotestmain
+default $
+        ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/pkg/github.com/google/blueprint/gotestmain.a
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 # Module:  gotestrunner
 # Variant:
 # Type:    bootstrap_core_go_binary
 # Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
-# Defined: build/blueprint/Blueprints:153:1
+# Defined: build/blueprint/Blueprints:167:1
 
 build ${g.bootstrap.buildDir}/.bootstrap/gotestrunner/obj/gotestrunner.a: $
         g.bootstrap.compile $
@@ -524,15 +581,16 @@
         ${g.bootstrap.buildDir}/.bootstrap/blueprint-proptools/pkg/github.com/google/blueprint/proptools.a $
         ${g.bootstrap.buildDir}/.bootstrap/blueprint/pkg/github.com/google/blueprint.a $
         ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap-bpdoc/pkg/github.com/google/blueprint/bootstrap/bpdoc.a $
-        ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a
-    incFlags = -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-deptools/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-pathtools/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-proptools/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap-bpdoc/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap/pkg
+        ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap/pkg/github.com/google/blueprint/bootstrap.a $
+        ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/pkg/github.com/google/blueprint/gotestmain.a
+    incFlags = -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-deptools/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-pathtools/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-proptools/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap-bpdoc/pkg -I ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap/pkg -I ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/pkg
     pkgPath = minibp
 default ${g.bootstrap.buildDir}/.bootstrap/minibp/obj/minibp.a
 
 build ${g.bootstrap.buildDir}/.bootstrap/minibp/obj/a.out: g.bootstrap.link $
         ${g.bootstrap.buildDir}/.bootstrap/minibp/obj/minibp.a | $
         ${g.bootstrap.linkCmd}
-    libDirFlags = -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-deptools/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-pathtools/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-proptools/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap-bpdoc/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap/pkg
+    libDirFlags = -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-deptools/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-pathtools/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-proptools/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap-bpdoc/pkg -L ${g.bootstrap.buildDir}/.bootstrap/blueprint-bootstrap/pkg -L ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/pkg
 default ${g.bootstrap.buildDir}/.bootstrap/minibp/obj/a.out
 
 build ${g.bootstrap.BinDir}/minibp: g.bootstrap.cp $
@@ -540,7 +598,8 @@
         ${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/test/test.passed $
         ${g.bootstrap.buildDir}/.bootstrap/blueprint-pathtools/test/test.passed $
         ${g.bootstrap.buildDir}/.bootstrap/blueprint-proptools/test/test.passed $
-        ${g.bootstrap.buildDir}/.bootstrap/blueprint/test/test.passed
+        ${g.bootstrap.buildDir}/.bootstrap/blueprint/test/test.passed $
+        ${g.bootstrap.buildDir}/.bootstrap/gotestmain-tests/test/test.passed
 default ${g.bootstrap.BinDir}/minibp
 
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
diff --git a/cc/config/global.go b/cc/config/global.go
index 4ae22c9..f4a1230 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -124,7 +124,7 @@
 	// This is used by non-NDK modules to get jni.h. export_include_dirs doesn't help
 	// with this, since there is no associated library.
 	pctx.PrefixedExistentPathsForSourcesVariable("CommonNativehelperInclude", "-I",
-		[]string{"libnativehelper/include/nativehelper"})
+		[]string{"libnativehelper/include_deprecated"})
 
 	pctx.SourcePathVariable("ClangDefaultBase", ClangDefaultBase)
 	pctx.VariableFunc("ClangBase", func(config interface{}) (string, error) {
diff --git a/cc/makevars.go b/cc/makevars.go
index 11c3162..294f3e6 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -82,6 +82,16 @@
 
 	ctx.Strict("RS_GLOBAL_INCLUDES", "${config.RsGlobalIncludes}")
 
+	nativeHelperIncludeFlags, err := ctx.Eval("${config.CommonNativehelperInclude}")
+	if err != nil {
+		panic(err)
+	}
+	nativeHelperIncludes, nativeHelperSystemIncludes := splitSystemIncludes(ctx, nativeHelperIncludeFlags)
+	if len(nativeHelperSystemIncludes) > 0 {
+		panic("native helper may not have any system includes")
+	}
+	ctx.Strict("JNI_H_INCLUDE", strings.Join(nativeHelperIncludes, " "))
+
 	includeFlags, err := ctx.Eval("${config.CommonGlobalIncludes}")
 	if err != nil {
 		panic(err)
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 49bd0f3..eccd255 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -188,7 +188,9 @@
 		}
 
 		if found, globalSanitizers = removeFromList("integer_overflow", globalSanitizers); found && s.Integer_overflow == nil {
-			s.Integer_overflow = boolPtr(true)
+			if !ctx.AConfig().IntegerOverflowDisabledForPath(ctx.ModuleDir()) {
+				s.Integer_overflow = boolPtr(true)
+			}
 		}
 
 		if len(globalSanitizers) > 0 {