[automerger skipped] Merge "Fix python proto srczip argument order" into qt-dev
am: cdec2035fd -s ours
am skip reason: change_id I62a998f1ad1e3b45f590babbf39330955d368373 with SHA1 09364fd955 is in history

Change-Id: I426b4288a5e74b35b42e3b36e36e29869f0aaba7
diff --git a/android/androidmk.go b/android/androidmk.go
index bd49e4c..42e1439 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -38,13 +38,15 @@
 }
 
 type AndroidMkData struct {
-	Class      string
-	SubName    string
-	DistFile   OptionalPath
-	OutputFile OptionalPath
-	Disabled   bool
-	Include    string
-	Required   []string
+	Class           string
+	SubName         string
+	DistFile        OptionalPath
+	OutputFile      OptionalPath
+	Disabled        bool
+	Include         string
+	Required        []string
+	Host_required   []string
+	Target_required []string
 
 	Custom func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData)
 
@@ -200,6 +202,8 @@
 	}
 
 	data.Required = append(data.Required, amod.commonProperties.Required...)
+	data.Host_required = append(data.Host_required, amod.commonProperties.Host_required...)
+	data.Target_required = append(data.Target_required, amod.commonProperties.Target_required...)
 
 	// Make does not understand LinuxBionic
 	if amod.Os() == LinuxBionic {
@@ -267,10 +271,7 @@
 	fmt.Fprintln(&data.preamble, "LOCAL_MODULE :=", name+data.SubName)
 	fmt.Fprintln(&data.preamble, "LOCAL_MODULE_CLASS :=", data.Class)
 	fmt.Fprintln(&data.preamble, "LOCAL_PREBUILT_MODULE_FILE :=", data.OutputFile.String())
-
-	if len(data.Required) > 0 {
-		fmt.Fprintln(&data.preamble, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
-	}
+	WriteRequiredModulesSettings(&data.preamble, data)
 
 	archStr := amod.Arch().ArchType.String()
 	host := false
@@ -360,3 +361,15 @@
 
 	fmt.Fprintln(w, "include "+data.Include)
 }
+
+func WriteRequiredModulesSettings(w io.Writer, data AndroidMkData) {
+	if len(data.Required) > 0 {
+		fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(data.Required, " "))
+	}
+	if len(data.Host_required) > 0 {
+		fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=", strings.Join(data.Host_required, " "))
+	}
+	if len(data.Target_required) > 0 {
+		fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=", strings.Join(data.Target_required, " "))
+	}
+}
diff --git a/android/config.go b/android/config.go
index 2e0750b..0c9f957 100644
--- a/android/config.go
+++ b/android/config.go
@@ -501,6 +501,22 @@
 	return String(c.productVariables.Platform_sdk_codename)
 }
 
+func (c *config) PlatformSecurityPatch() string {
+	return String(c.productVariables.Platform_security_patch)
+}
+
+func (c *config) PlatformPreviewSdkVersion() string {
+	return String(c.productVariables.Platform_preview_sdk_version)
+}
+
+func (c *config) PlatformMinSupportedTargetSdkVersion() string {
+	return String(c.productVariables.Platform_min_supported_target_sdk_version)
+}
+
+func (c *config) PlatformBaseOS() string {
+	return String(c.productVariables.Platform_base_os)
+}
+
 func (c *config) MinSupportedSdkVersion() int {
 	return 16
 }
@@ -567,7 +583,7 @@
 	if defaultCert != "" {
 		return PathForSource(ctx, filepath.Dir(defaultCert))
 	} else {
-		return PathForSource(ctx, "build/target/product/security")
+		return PathForSource(ctx, "build/make/target/product/security")
 	}
 }
 
@@ -584,7 +600,7 @@
 func (c *config) ApexKeyDir(ctx ModuleContext) SourcePath {
 	// TODO(b/121224311): define another variable such as TARGET_APEX_KEY_OVERRIDE
 	defaultCert := String(c.productVariables.DefaultAppCertificate)
-	if defaultCert == "" || filepath.Dir(defaultCert) == "build/target/product/security" {
+	if defaultCert == "" || filepath.Dir(defaultCert) == "build/make/target/product/security" {
 		// When defaultCert is unset or is set to the testkeys path, use the APEX keys
 		// that is under the module dir
 		return pathForModuleSrc(ctx)
diff --git a/android/defs.go b/android/defs.go
index cd8b4e3..4890c66 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -20,7 +20,7 @@
 )
 
 var (
-	pctx = NewPackageContext("android/soong/common")
+	pctx = NewPackageContext("android/soong/android")
 
 	cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks",
 		Config.CpPreserveSymlinksFlags)
diff --git a/android/module.go b/android/module.go
index 201c27a..93966e1 100644
--- a/android/module.go
+++ b/android/module.go
@@ -133,6 +133,8 @@
 	InstallInRecovery() bool
 
 	RequiredModuleNames() []string
+	HostRequiredModuleNames() []string
+	TargetRequiredModuleNames() []string
 
 	// android.ModuleContext methods
 	// These are duplicated instead of embedded so that can eventually be wrapped to take an
@@ -269,6 +271,12 @@
 	// names of other modules to install if this module is installed
 	Required []string `android:"arch_variant"`
 
+	// names of other modules to install on host if this module is installed
+	Host_required []string `android:"arch_variant"`
+
+	// names of other modules to install on target if this module is installed
+	Target_required []string `android:"arch_variant"`
+
 	// relative path to a file to include in the list of notices for the device
 	Notice *string `android:"path"`
 
@@ -1459,6 +1467,14 @@
 	return ctx.module.base().commonProperties.Required
 }
 
+func (ctx *androidModuleContext) HostRequiredModuleNames() []string {
+	return ctx.module.base().commonProperties.Host_required
+}
+
+func (ctx *androidModuleContext) TargetRequiredModuleNames() []string {
+	return ctx.module.base().commonProperties.Target_required
+}
+
 func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) Paths {
 	ret, err := ctx.GlobWithDeps(globPattern, excludes)
 	if err != nil {
diff --git a/android/paths.go b/android/paths.go
index cdcb719..8cc7057 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -217,13 +217,41 @@
 	return ret
 }
 
-// PathsForModuleSrc returns Paths rooted from the module's local source
-// directory
+// PathsForModuleSrc returns Paths rooted from the module's local source directory.  It expands globs and references
+// to SourceFileProducer modules using the ":name" syntax.  Properties passed as the paths argument must have been
+// annotated with struct tag `android:"path"` so that dependencies on SourceFileProducer modules will have already
+// been handled by the path_properties mutator.  If ctx.Config().AllowMissingDependencies() is true, then any missing
+// SourceFileProducer dependencies will cause the module to be marked as having missing dependencies.
 func PathsForModuleSrc(ctx ModuleContext, paths []string) Paths {
 	return PathsForModuleSrcExcludes(ctx, paths, nil)
 }
 
+// PathsForModuleSrcExcludes returns Paths rooted from the module's local source directory, excluding paths listed in
+// the excludes arguments.  It expands globs and references to SourceFileProducer modules in both paths and excludes
+// using the ":name" syntax.  Properties passed as the paths or excludes argument must have been annotated with struct
+// tag `android:"path"` so that dependencies on SourceFileProducer modules will have already been handled by the
+// path_properties mutator.  If ctx.Config().AllowMissingDependencies() is true, then any missing SourceFileProducer
+// dependencies will cause the module to be marked as having missing dependencies.
 func PathsForModuleSrcExcludes(ctx ModuleContext, paths, excludes []string) Paths {
+	ret, missingDeps := PathsAndMissingDepsForModuleSrcExcludes(ctx, paths, excludes)
+	if ctx.Config().AllowMissingDependencies() {
+		ctx.AddMissingDependencies(missingDeps)
+	} else {
+		for _, m := range missingDeps {
+			ctx.ModuleErrorf(`missing dependency on %q, is the property annotated with android:"path"?`, m)
+		}
+	}
+	return ret
+}
+
+// PathsAndMissingDepsForModuleSrcExcludes returns Paths rooted from the module's local source directory, excluding
+// paths listed in the excludes arguments, and a list of missing dependencies.  It expands globs and references to
+// SourceFileProducer modules in both paths and excludes using the ":name" syntax.  Properties passed as the paths or
+// excludes argument must have been annotated with struct tag `android:"path"` so that dependencies on
+// SourceFileProducer modules will have already been handled by the path_properties mutator.  If
+// ctx.Config().AllowMissingDependencies() is true, then any missing SourceFileProducer dependencies will be returned,
+// and they will NOT cause the module to be marked as having missing dependencies.
+func PathsAndMissingDepsForModuleSrcExcludes(ctx ModuleContext, paths, excludes []string) (Paths, []string) {
 	prefix := pathForModuleSrc(ctx).String()
 
 	var expandedExcludes []string
@@ -231,15 +259,13 @@
 		expandedExcludes = make([]string, 0, len(excludes))
 	}
 
+	var missingExcludeDeps []string
+
 	for _, e := range excludes {
 		if m := SrcIsModule(e); m != "" {
 			module := ctx.GetDirectDepWithTag(m, SourceDepTag)
 			if module == nil {
-				if ctx.Config().AllowMissingDependencies() {
-					ctx.AddMissingDependencies([]string{m})
-				} else {
-					ctx.ModuleErrorf(`missing dependency on %q, is the property annotated with android:"path"?`, m)
-				}
+				missingExcludeDeps = append(missingExcludeDeps, m)
 				continue
 			}
 			if srcProducer, ok := module.(SourceFileProducer); ok {
@@ -253,24 +279,23 @@
 	}
 
 	if paths == nil {
-		return nil
+		return nil, missingExcludeDeps
 	}
 
+	var missingDeps []string
+
 	expandedSrcFiles := make(Paths, 0, len(paths))
 	for _, s := range paths {
 		srcFiles, err := expandOneSrcPath(ctx, s, expandedExcludes)
 		if depErr, ok := err.(missingDependencyError); ok {
-			if ctx.Config().AllowMissingDependencies() {
-				ctx.AddMissingDependencies(depErr.missingDeps)
-			} else {
-				ctx.ModuleErrorf(`%s, is the property annotated with android:"path"?`, depErr.Error())
-			}
+			missingDeps = append(missingDeps, depErr.missingDeps...)
 		} else if err != nil {
 			reportPathError(ctx, err)
 		}
 		expandedSrcFiles = append(expandedSrcFiles, srcFiles...)
 	}
-	return expandedSrcFiles
+
+	return expandedSrcFiles, append(missingDeps, missingExcludeDeps...)
 }
 
 type missingDependencyError struct {
diff --git a/android/paths_test.go b/android/paths_test.go
index 2e0e0e8..b52d713 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -714,6 +714,8 @@
 		Exclude_srcs []string `android:"path"`
 
 		Src *string `android:"path"`
+
+		Module_handles_missing_deps bool
 	}
 
 	src string
@@ -733,7 +735,12 @@
 }
 
 func (p *pathForModuleSrcTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
-	srcs := PathsForModuleSrcExcludes(ctx, p.props.Srcs, p.props.Exclude_srcs)
+	var srcs Paths
+	if p.props.Module_handles_missing_deps {
+		srcs, p.missingDeps = PathsAndMissingDepsForModuleSrcExcludes(ctx, p.props.Srcs, p.props.Exclude_srcs)
+	} else {
+		srcs = PathsForModuleSrcExcludes(ctx, p.props.Srcs, p.props.Exclude_srcs)
+	}
 	p.srcs = srcs.Strings()
 
 	for _, src := range srcs {
@@ -748,7 +755,9 @@
 		}
 	}
 
-	p.missingDeps = ctx.GetMissingDependencies()
+	if !p.props.Module_handles_missing_deps {
+		p.missingDeps = ctx.GetMissingDependencies()
+	}
 }
 
 type pathForModuleSrcTestCase struct {
@@ -957,6 +966,13 @@
 			exclude_srcs: [":b"],
 			src: ":c",
 		}
+
+		test {
+			name: "bar",
+			srcs: [":d"],
+			exclude_srcs: [":e"],
+			module_handles_missing_deps: true,
+		}
 	`
 
 	mockFS := map[string][]byte{
@@ -974,17 +990,26 @@
 	foo := ctx.ModuleForTests("foo", "").Module().(*pathForModuleSrcTestModule)
 
 	if g, w := foo.missingDeps, []string{"a", "b", "c"}; !reflect.DeepEqual(g, w) {
-		t.Errorf("want missing deps %q, got %q", w, g)
+		t.Errorf("want foo missing deps %q, got %q", w, g)
 	}
 
 	if g, w := foo.srcs, []string{}; !reflect.DeepEqual(g, w) {
-		t.Errorf("want srcs %q, got %q", w, g)
+		t.Errorf("want foo srcs %q, got %q", w, g)
 	}
 
 	if g, w := foo.src, ""; g != w {
-		t.Errorf("want src %q, got %q", w, g)
+		t.Errorf("want foo src %q, got %q", w, g)
 	}
 
+	bar := ctx.ModuleForTests("bar", "").Module().(*pathForModuleSrcTestModule)
+
+	if g, w := bar.missingDeps, []string{"d", "e"}; !reflect.DeepEqual(g, w) {
+		t.Errorf("want bar missing deps %q, got %q", w, g)
+	}
+
+	if g, w := bar.srcs, []string{}; !reflect.DeepEqual(g, w) {
+		t.Errorf("want bar srcs %q, got %q", w, g)
+	}
 }
 
 func ExampleOutputPath_ReplaceExtension() {
diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go
index 2a3e07e..3cadaeb 100644
--- a/android/prebuilt_etc.go
+++ b/android/prebuilt_etc.go
@@ -17,7 +17,6 @@
 import (
 	"fmt"
 	"io"
-	"strings"
 )
 
 // TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
@@ -157,7 +156,7 @@
 			fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", "$(OUT_DIR)/"+p.installDirPath.RelPathString())
 			fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", p.outputFilePath.Base())
 			fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !p.Installable())
-			fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(data.Required, " "))
+			WriteRequiredModulesSettings(w, data)
 			if p.additionalDependencies != nil {
 				fmt.Fprint(w, "LOCAL_ADDITIONAL_DEPENDENCIES :=")
 				for _, path := range *p.additionalDependencies {
diff --git a/android/prebuilt_etc_test.go b/android/prebuilt_etc_test.go
index e0ade7e..fbdbc97 100644
--- a/android/prebuilt_etc_test.go
+++ b/android/prebuilt_etc_test.go
@@ -150,13 +150,17 @@
 
 	data := AndroidMkData{}
 	data.Required = append(data.Required, "modA", "moduleB")
+	data.Host_required = append(data.Host_required, "hostModA", "hostModB")
+	data.Target_required = append(data.Target_required, "targetModA")
 
 	expected := map[string]string{
-		"LOCAL_MODULE":                "foo",
-		"LOCAL_MODULE_CLASS":          "ETC",
-		"LOCAL_MODULE_OWNER":          "abc",
-		"LOCAL_INSTALLED_MODULE_STEM": "foo.conf",
-		"LOCAL_REQUIRED_MODULES":      "modA moduleB",
+		"LOCAL_MODULE":                  "foo",
+		"LOCAL_MODULE_CLASS":            "ETC",
+		"LOCAL_MODULE_OWNER":            "abc",
+		"LOCAL_INSTALLED_MODULE_STEM":   "foo.conf",
+		"LOCAL_REQUIRED_MODULES":        "modA moduleB",
+		"LOCAL_HOST_REQUIRED_MODULES":   "hostModA hostModB",
+		"LOCAL_TARGET_REQUIRED_MODULES": "targetModA",
 	}
 
 	mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
diff --git a/android/variable.go b/android/variable.go
index 56ca666..16d7b13 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -85,10 +85,12 @@
 		// are used for dogfooding and performance testing, and should be as similar to user builds
 		// as possible.
 		Debuggable struct {
-			Cflags   []string
-			Cppflags []string
-			Init_rc  []string
-			Required []string
+			Cflags          []string
+			Cppflags        []string
+			Init_rc         []string
+			Required        []string
+			Host_required   []string
+			Target_required []string
 		}
 
 		// eng is true for -eng builds, and can be used to turn on additionaly heavyweight debugging
@@ -137,14 +139,18 @@
 	BuildNumberFromFile *string `json:",omitempty"`
 	DateFromFile        *string `json:",omitempty"`
 
-	Platform_version_name             *string  `json:",omitempty"`
-	Platform_sdk_version              *int     `json:",omitempty"`
-	Platform_sdk_codename             *string  `json:",omitempty"`
-	Platform_sdk_final                *bool    `json:",omitempty"`
-	Platform_version_active_codenames []string `json:",omitempty"`
-	Platform_version_future_codenames []string `json:",omitempty"`
-	Platform_vndk_version             *string  `json:",omitempty"`
-	Platform_systemsdk_versions       []string `json:",omitempty"`
+	Platform_version_name                     *string  `json:",omitempty"`
+	Platform_sdk_version                      *int     `json:",omitempty"`
+	Platform_sdk_codename                     *string  `json:",omitempty"`
+	Platform_sdk_final                        *bool    `json:",omitempty"`
+	Platform_version_active_codenames         []string `json:",omitempty"`
+	Platform_version_future_codenames         []string `json:",omitempty"`
+	Platform_vndk_version                     *string  `json:",omitempty"`
+	Platform_systemsdk_versions               []string `json:",omitempty"`
+	Platform_security_patch                   *string  `json:",omitempty"`
+	Platform_preview_sdk_version              *string  `json:",omitempty"`
+	Platform_min_supported_target_sdk_version *string  `json:",omitempty"`
+	Platform_base_os                          *string  `json:",omitempty"`
 
 	DeviceName              *string  `json:",omitempty"`
 	DeviceArch              *string  `json:",omitempty"`
@@ -297,9 +303,15 @@
 
 func (v *productVariables) SetDefaultConfig() {
 	*v = productVariables{
-		Platform_sdk_version:              intPtr(26),
-		Platform_version_active_codenames: []string{"P"},
-		Platform_version_future_codenames: []string{"P"},
+		BuildNumberFromFile: stringPtr("123456789"),
+
+		Platform_version_name:             stringPtr("Q"),
+		Platform_sdk_version:              intPtr(28),
+		Platform_sdk_codename:             stringPtr("Q"),
+		Platform_sdk_final:                boolPtr(false),
+		Platform_version_active_codenames: []string{"Q"},
+		Platform_version_future_codenames: []string{"Q"},
+		Platform_vndk_version:             stringPtr("Q"),
 
 		HostArch:                   stringPtr("x86_64"),
 		HostSecondaryArch:          stringPtr("x86"),
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go
index 52bcf9c..e0932af 100644
--- a/androidmk/cmd/androidmk/android.go
+++ b/androidmk/cmd/androidmk/android.go
@@ -126,6 +126,8 @@
 			"LOCAL_CONLYFLAGS":                    "conlyflags",
 			"LOCAL_CPPFLAGS":                      "cppflags",
 			"LOCAL_REQUIRED_MODULES":              "required",
+			"LOCAL_HOST_REQUIRED_MODULES":         "host_required",
+			"LOCAL_TARGET_REQUIRED_MODULES":       "target_required",
 			"LOCAL_OVERRIDES_MODULES":             "overrides",
 			"LOCAL_LDLIBS":                        "host_ldlibs",
 			"LOCAL_CLANG_CFLAGS":                  "clang_cflags",
@@ -144,6 +146,7 @@
 			"LOCAL_RENDERSCRIPT_FLAGS":    "renderscript.flags",
 
 			"LOCAL_JAVA_RESOURCE_DIRS":    "java_resource_dirs",
+			"LOCAL_JAVA_RESOURCE_FILES":   "java_resources",
 			"LOCAL_JAVACFLAGS":            "javacflags",
 			"LOCAL_ERROR_PRONE_FLAGS":     "errorprone.javacflags",
 			"LOCAL_DX_FLAGS":              "dxflags",
diff --git a/androidmk/cmd/androidmk/androidmk_test.go b/androidmk/cmd/androidmk/androidmk_test.go
index f2dc6ff..34e673c 100644
--- a/androidmk/cmd/androidmk/androidmk_test.go
+++ b/androidmk/cmd/androidmk/androidmk_test.go
@@ -577,6 +577,10 @@
 			include $(CLEAR_VARS)
 			LOCAL_SRC_FILES := $(call all-java-files-under, src gen)
 			include $(BUILD_STATIC_JAVA_LIBRARY)
+
+			include $(CLEAR_VARS)
+			LOCAL_JAVA_RESOURCE_FILES := foo bar
+			include $(BUILD_STATIC_JAVA_LIBRARY)
 		`,
 		expected: `
 			java_library {
@@ -604,6 +608,13 @@
 					"gen/**/*.java",
 				],
 			}
+
+			java_library {
+				java_resources: [
+					"foo",
+					"bar",
+				],
+			}
 		`,
 	},
 	{
diff --git a/apex/apex.go b/apex/apex.go
index 665e363..004de86 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -119,7 +119,7 @@
 )
 
 func init() {
-	pctx.Import("android/soong/common")
+	pctx.Import("android/soong/android")
 	pctx.Import("android/soong/java")
 	pctx.HostBinToolVariable("apexer", "apexer")
 	// ART minimal builds (using the master-art manifest) do not have the "frameworks/base"
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 3c80376..fce2135 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -148,7 +148,7 @@
 
 	ctx.MockFileSystem(map[string][]byte{
 		"Android.bp":                                        []byte(bp),
-		"build/target/product/security":                     nil,
+		"build/make/target/product/security":                nil,
 		"apex_manifest.json":                                nil,
 		"AndroidManifest.xml":                               nil,
 		"system/sepolicy/apex/myapex-file_contexts":         nil,
diff --git a/bpf/bpf.go b/bpf/bpf.go
index 073f62d..13468c7 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -91,7 +91,7 @@
 			},
 		})
 
-		bpf.objs = append(bpf.objs, obj)
+		bpf.objs = append(bpf.objs, obj.WithoutRel())
 	}
 }
 
diff --git a/cc/builder.go b/cc/builder.go
index c64243f..65369d6 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -150,8 +150,8 @@
 
 	clangTidy = pctx.AndroidStaticRule("clangTidy",
 		blueprint.RuleParams{
-			Command:     "rm -f $out && CLANG_TIDY=${config.ClangBin}/clang-tidy ${config.ClangTidyShellPath} $tidyFlags $in -- $cFlags && touch $out",
-			CommandDeps: []string{"${config.ClangBin}/clang-tidy", "${config.ClangTidyShellPath}"},
+			Command:     "rm -f $out && ${config.ClangBin}/clang-tidy $tidyFlags $in -- $cFlags && touch $out",
+			CommandDeps: []string{"${config.ClangBin}/clang-tidy"},
 		},
 		"cFlags", "tidyFlags")
 
@@ -709,7 +709,7 @@
 }
 
 func SourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceDump android.Path,
-	baseName, exportedHeaderFlags string, isLlndk, isVndkExt bool) android.OptionalPath {
+	baseName, exportedHeaderFlags string, isLlndk, isNdk, isVndkExt bool) android.OptionalPath {
 
 	outputFile := android.PathForModuleOut(ctx, baseName+".abidiff")
 	libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
@@ -719,9 +719,14 @@
 	if exportedHeaderFlags == "" {
 		localAbiCheckAllowFlags = append(localAbiCheckAllowFlags, "-advice-only")
 	}
-	if isLlndk {
-		localAbiCheckAllowFlags = append(localAbiCheckAllowFlags, "-consider-opaque-types-different")
+	if isLlndk || isNdk {
 		createReferenceDumpFlags = "--llndk"
+		if isLlndk {
+			// TODO(b/130324828): "-consider-opaque-types-different" should apply to
+			// both LLNDK and NDK shared libs. However, a known issue in header-abi-diff
+			// breaks libaaudio. Remove the if-guard after the issue is fixed.
+			localAbiCheckAllowFlags = append(localAbiCheckAllowFlags, "-consider-opaque-types-different")
+		}
 	}
 	if isVndkExt {
 		localAbiCheckAllowFlags = append(localAbiCheckAllowFlags, "-allow-extensions")
diff --git a/cc/config/global.go b/cc/config/global.go
index 07ef9d0..8fc9ff2 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -201,7 +201,6 @@
 	})
 	pctx.StaticVariable("ClangPath", "${ClangBase}/${HostPrebuiltTag}/${ClangVersion}")
 	pctx.StaticVariable("ClangBin", "${ClangPath}/bin")
-	pctx.StaticVariable("ClangTidyShellPath", "build/soong/scripts/clang-tidy.sh")
 
 	pctx.VariableFunc("ClangShortVersion", func(ctx android.PackageVarContext) string {
 		if override := ctx.Config().Getenv("LLVM_RELEASE_VERSION"); override != "" {
diff --git a/cc/config/vndk.go b/cc/config/vndk.go
index 542f737..e754ad5 100644
--- a/cc/config/vndk.go
+++ b/cc/config/vndk.go
@@ -65,6 +65,7 @@
 	"android.hardware.neuralnetworks@1.0",
 	"android.hardware.neuralnetworks@1.1",
 	"android.hardware.neuralnetworks@1.2",
+	"android.hardware.nfc@1.0",
 	"android.hardware.nfc@1.1",
 	"android.hardware.nfc@1.2",
 	"android.hardware.oemlock@1.0",
@@ -110,8 +111,11 @@
 	"libdumpstateutil",
 	"libexpat",
 	"libfmq",
+	"libgatekeeper",
 	"libgui",
 	"libhidlcache",
+	"libkeymaster_messages",
+	"libkeymaster_portable",
 	"libmedia_helper",
 	"libmedia_omx",
 	"libmemtrack",
@@ -122,7 +126,9 @@
 	"libsoftkeymasterdevice",
 	"libsqlite",
 	"libssl",
+	"libstagefright_amrnb_common",
 	"libstagefright_bufferqueue_helper",
+	"libstagefright_enc_common",
 	"libstagefright_flacdec",
 	"libstagefright_foundation",
 	"libstagefright_omx",
@@ -150,8 +156,10 @@
 	"libstagefright_soft_vpxenc",
 	"libstagefright_xmlparser",
 	"libsysutils",
+	"libtinyxml2",
 	"libui",
 	"libvorbisidec",
 	"libxml2",
+	"libyuv",
 	"libziparchive",
 }
diff --git a/cc/library.go b/cc/library.go
index cf20747..a594b91 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -804,7 +804,7 @@
 		refAbiDumpFile := getRefAbiDumpFile(ctx, vndkVersion, fileName)
 		if refAbiDumpFile != nil {
 			library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
-				refAbiDumpFile, fileName, exportedHeaderFlags, ctx.isLlndk(), ctx.isVndkExt())
+				refAbiDumpFile, fileName, exportedHeaderFlags, ctx.isLlndk(), ctx.isNdk(), ctx.isVndkExt())
 		}
 	}
 }
diff --git a/cc/makevars.go b/cc/makevars.go
index aa6fdea..dc91525 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -75,7 +75,6 @@
 	ctx.Strict("LLVM_OBJCOPY", "${config.ClangBin}/llvm-objcopy")
 	ctx.Strict("LLVM_STRIP", "${config.ClangBin}/llvm-strip")
 	ctx.Strict("PATH_TO_CLANG_TIDY", "${config.ClangBin}/clang-tidy")
-	ctx.Strict("PATH_TO_CLANG_TIDY_SHELL", "${config.ClangTidyShellPath}")
 	ctx.StrictSorted("CLANG_CONFIG_UNKNOWN_CFLAGS", strings.Join(config.ClangUnknownCflags, " "))
 
 	ctx.Strict("RS_LLVM_PREBUILTS_VERSION", "${config.RSClangVersion}")
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index 9265bff..e39bae5 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -63,7 +63,7 @@
 	android.RegisterModuleType("preprocessed_ndk_headers", preprocessedNdkHeadersFactory)
 	android.RegisterSingletonType("ndk", NdkSingleton)
 
-	pctx.Import("android/soong/common")
+	pctx.Import("android/soong/android")
 }
 
 func getNdkInstallBase(ctx android.PathContext) android.OutputPath {
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index 74f7f27..0ecf566 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -172,6 +172,26 @@
 	return module
 }
 
+// vndk_prebuilt_shared installs Vendor Native Development kit (VNDK) snapshot
+// shared libraries for system build. Example:
+//
+//    vndk_prebuilt_shared {
+//        name: "libfoo",
+//        version: "27.1.0",
+//        vendor_available: true,
+//        vndk: {
+//            enabled: true,
+//        },
+//        export_include_dirs: ["include/external/libfoo/vndk_include"],
+//        arch: {
+//            arm64: {
+//                srcs: ["arm/lib64/libfoo.so"],
+//            },
+//            arm: {
+//                srcs: ["arm/lib/libfoo.so"],
+//            },
+//        },
+//    }
 func vndkPrebuiltSharedFactory() android.Module {
 	module := vndkPrebuiltSharedLibrary()
 	return module.Init()
diff --git a/cmd/pom2bp/pom2bp.go b/cmd/pom2bp/pom2bp.go
index a399b28..c2ad944 100644
--- a/cmd/pom2bp/pom2bp.go
+++ b/cmd/pom2bp/pom2bp.go
@@ -328,6 +328,9 @@
     {{- if .IsAar}}
     min_sdk_version: "{{.MinSdkVersion}}",
     static_libs: [
+        {{- range .BpJarDeps}}
+        "{{.}}",
+        {{- end}}
         {{- range .BpAarDeps}}
         "{{.}}",
         {{- end}}
@@ -349,7 +352,7 @@
     {{- end}}
     static_libs: [
         "{{.BpName}}-nodeps",
-         {{- range .BpJarDeps}}
+        {{- range .BpJarDeps}}
         "{{.}}",
         {{- end}}
         {{- range .BpAarDeps}}
diff --git a/cmd/soong_env/soong_env.go b/cmd/soong_env/soong_env.go
index 933e525..d305d83 100644
--- a/cmd/soong_env/soong_env.go
+++ b/cmd/soong_env/soong_env.go
@@ -15,7 +15,7 @@
 // soong_glob is the command line tool that checks if the list of files matching a glob has
 // changed, and only updates the output file list if it has changed.  It is used to optimize
 // out build.ninja regenerations when non-matching files are added.  See
-// android/soong/common/glob.go for a longer description.
+// android/soong/android/glob.go for a longer description.
 package main
 
 import (
diff --git a/genrule/genrule.go b/genrule/genrule.go
index e259b1d..87e6747 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -189,6 +189,8 @@
 	}
 
 	if len(g.properties.Tools) > 0 {
+		seenTools := make(map[string]bool)
+
 		ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
 			switch tag := ctx.OtherModuleDependencyTag(module).(type) {
 			case hostToolDependencyTag:
@@ -220,11 +222,25 @@
 				if path.Valid() {
 					g.deps = append(g.deps, path.Path())
 					addLocationLabel(tag.label, []string{path.Path().String()})
+					seenTools[tag.label] = true
 				} else {
 					ctx.ModuleErrorf("host tool %q missing output file", tool)
 				}
 			}
 		})
+
+		// If AllowMissingDependencies is enabled, the build will not have stopped when
+		// AddFarVariationDependencies was called on a missing tool, which will result in nonsensical
+		// "cmd: unknown location label ..." errors later.  Add a dummy file to the local label.  The
+		// command that uses this dummy file will never be executed because the rule will be replaced with
+		// an android.Error rule reporting the missing dependencies.
+		if ctx.Config().AllowMissingDependencies() {
+			for _, tool := range g.properties.Tools {
+				if !seenTools[tool] {
+					addLocationLabel(tool, []string{"***missing tool " + tool + "***"})
+				}
+			}
+		}
 	}
 
 	if ctx.Failed() {
@@ -239,9 +255,24 @@
 
 	var srcFiles android.Paths
 	for _, in := range g.properties.Srcs {
-		paths := android.PathsForModuleSrcExcludes(ctx, []string{in}, g.properties.Exclude_srcs)
-		srcFiles = append(srcFiles, paths...)
-		addLocationLabel(in, paths.Strings())
+		paths, missingDeps := android.PathsAndMissingDepsForModuleSrcExcludes(ctx, []string{in}, g.properties.Exclude_srcs)
+		if len(missingDeps) > 0 {
+			if !ctx.Config().AllowMissingDependencies() {
+				panic(fmt.Errorf("should never get here, the missing dependencies %q should have been reported in DepsMutator",
+					missingDeps))
+			}
+
+			// If AllowMissingDependencies is enabled, the build will not have stopped when
+			// the dependency was added on a missing SourceFileProducer module, which will result in nonsensical
+			// "cmd: label ":..." has no files" errors later.  Add a dummy file to the local label.  The
+			// command that uses this dummy file will never be executed because the rule will be replaced with
+			// an android.Error rule reporting the missing dependencies.
+			ctx.AddMissingDependencies(missingDeps)
+			addLocationLabel(in, []string{"***missing srcs " + in + "***"})
+		} else {
+			srcFiles = append(srcFiles, paths...)
+			addLocationLabel(in, paths.Strings())
+		}
 	}
 
 	task := g.taskGenerator(ctx, String(g.properties.Cmd), srcFiles)
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index 5cb51b8..0b6952f 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -17,11 +17,13 @@
 import (
 	"io/ioutil"
 	"os"
+	"reflect"
 	"strings"
 	"testing"
 
 	"android/soong/android"
-	"reflect"
+
+	"github.com/google/blueprint/proptools"
 )
 
 var buildDir string
@@ -123,6 +125,8 @@
 		name string
 		prop string
 
+		allowMissingDependencies bool
+
 		err    string
 		expect string
 	}{
@@ -425,6 +429,30 @@
 			`,
 			err: "must have at least one output file",
 		},
+		{
+			name: "srcs allow missing dependencies",
+			prop: `
+				srcs: [":missing"],
+				out: ["out"],
+				cmd: "cat $(location :missing) > $(out)",
+			`,
+
+			allowMissingDependencies: true,
+
+			expect: "cat ***missing srcs :missing*** > __SBOX_OUT_FILES__",
+		},
+		{
+			name: "tool allow missing dependencies",
+			prop: `
+				tools: [":missing"],
+				out: ["out"],
+				cmd: "$(location :missing) > $(out)",
+			`,
+
+			allowMissingDependencies: true,
+
+			expect: "***missing tool :missing*** > __SBOX_OUT_FILES__",
+		},
 	}
 
 	for _, test := range testcases {
@@ -435,7 +463,10 @@
 			bp += test.prop
 			bp += "}\n"
 
+			config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(test.allowMissingDependencies)
+
 			ctx := testContext(config, bp, nil)
+			ctx.SetAllowMissingDependencies(test.allowMissingDependencies)
 
 			_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
 			if errs == nil {
@@ -460,8 +491,8 @@
 			}
 
 			gen := ctx.ModuleForTests("gen", "").Module().(*Module)
-			if gen.rawCommand != "'"+test.expect+"'" {
-				t.Errorf("want %q, got %q", test.expect, gen.rawCommand)
+			if g, w := gen.rawCommand, "'"+test.expect+"'"; w != g {
+				t.Errorf("want %q, got %q", w, g)
 			}
 		})
 	}
diff --git a/java/androidmk.go b/java/androidmk.go
index 6ec72e0..d2e0f2e 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -38,7 +38,7 @@
 		}
 		fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
 		fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
-		fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
+		android.WriteRequiredModulesSettings(w, data)
 		fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
 	}
 }
diff --git a/java/app_test.go b/java/app_test.go
index 1f6297c..a084c9c 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -712,7 +712,7 @@
 				}
 			`,
 			certificateOverride: "",
-			expected:            "build/target/product/security/testkey.x509.pem build/target/product/security/testkey.pk8",
+			expected:            "build/make/target/product/security/testkey.x509.pem build/make/target/product/security/testkey.pk8",
 		},
 		{
 			name: "module certificate property",
@@ -741,7 +741,7 @@
 				}
 			`,
 			certificateOverride: "",
-			expected:            "build/target/product/security/expiredkey.x509.pem build/target/product/security/expiredkey.pk8",
+			expected:            "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
 		},
 		{
 			name: "certificate overrides",
@@ -910,7 +910,7 @@
 		{
 			variantName: "android_common",
 			apkPath:     "/target/product/test_device/system/app/foo/foo.apk",
-			signFlag:    "build/target/product/security/expiredkey.x509.pem build/target/product/security/expiredkey.pk8",
+			signFlag:    "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
 			overrides:   []string{"baz"},
 			aaptFlag:    "",
 		},
@@ -924,7 +924,7 @@
 		{
 			variantName: "baz_android_common",
 			apkPath:     "/target/product/test_device/system/app/baz/baz.apk",
-			signFlag:    "build/target/product/security/expiredkey.x509.pem build/target/product/security/expiredkey.pk8",
+			signFlag:    "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
 			overrides:   []string{"baz", "foo"},
 			aaptFlag:    "--rename-manifest-package org.dandroid.bp",
 		},
diff --git a/java/builder.go b/java/builder.go
index 3da8348..338cd52 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -142,7 +142,7 @@
 )
 
 func init() {
-	pctx.Import("android/soong/common")
+	pctx.Import("android/soong/android")
 	pctx.Import("android/soong/java/config")
 }
 
diff --git a/java/config/kotlin.go b/java/config/kotlin.go
index 2af7b3c..7cea042 100644
--- a/java/config/kotlin.go
+++ b/java/config/kotlin.go
@@ -27,6 +27,10 @@
 func init() {
 	pctx.SourcePathVariable("KotlincCmd", "external/kotlinc/bin/kotlinc")
 	pctx.SourcePathVariable("KotlinCompilerJar", "external/kotlinc/lib/kotlin-compiler.jar")
+	pctx.SourcePathVariable("KotlinPreloaderJar", "external/kotlinc/lib/kotlin-preloader.jar")
+	pctx.SourcePathVariable("KotlinReflectJar", "external/kotlinc/lib/kotlin-reflect.jar")
+	pctx.SourcePathVariable("KotlinScriptRuntimeJar", "external/kotlinc/lib/kotlin-script-runtime.jar")
+	pctx.SourcePathVariable("KotlinTrove4jJar", "external/kotlinc/lib/trove4j.jar")
 	pctx.SourcePathVariable("KotlinKaptJar", "external/kotlinc/lib/kotlin-annotation-processing.jar")
 	pctx.SourcePathVariable("KotlinStdlibJar", KotlinStdlibJar)
 
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index a23b477..e857fe8 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -57,6 +57,7 @@
 	dir          android.OutputPath
 	symbolsDir   android.OutputPath
 	images       map[android.ArchType]android.OutputPath
+	zip          android.WritablePath
 }
 
 type bootImage struct {
@@ -187,6 +188,8 @@
 
 	profile := bootImageProfileRule(ctx, image, missingDeps)
 
+	var allFiles android.Paths
+
 	if !global.DisablePreopt {
 		targets := ctx.Config().Targets[android.Android]
 		if ctx.Config().SecondArchIsTranslated() {
@@ -194,15 +197,27 @@
 		}
 
 		for _, target := range targets {
-			buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
+			files := buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
+			allFiles = append(allFiles, files.Paths()...)
 		}
 	}
 
+	if image.zip != nil {
+		rule := android.NewRuleBuilder()
+		rule.Command().
+			Tool(ctx.Config().HostToolPath(ctx, "soong_zip")).
+			FlagWithOutput("-o ", image.zip).
+			FlagWithArg("-C ", image.dir.String()).
+			FlagWithInputList("-f ", allFiles, " -f ")
+
+		rule.Build(pctx, ctx, "zip_"+image.name, "zip "+image.name+" image")
+	}
+
 	return image
 }
 
 func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
-	arch android.ArchType, profile android.Path, missingDeps []string) {
+	arch android.ArchType, profile android.Path, missingDeps []string) android.WritablePaths {
 
 	global := dexpreoptGlobalConfig(ctx)
 
@@ -290,6 +305,8 @@
 	var vdexInstalls android.RuleBuilderInstalls
 	var unstrippedInstalls android.RuleBuilderInstalls
 
+	var zipFiles android.WritablePaths
+
 	// dex preopt on the bootclasspath produces multiple files.  The first dex file
 	// is converted into to 'name'.art (to match the legacy assumption that 'name'.art
 	// exists), and the rest are converted to 'name'-<jar>.art.
@@ -308,6 +325,8 @@
 
 		extraFiles = append(extraFiles, art, oat, vdex, unstrippedOat)
 
+		zipFiles = append(zipFiles, art, oat, vdex)
+
 		// Install the .oat and .art files.
 		rule.Install(art, filepath.Join(installDir, art.Base()))
 		rule.Install(oat, filepath.Join(installDir, oat.Base()))
@@ -331,6 +350,8 @@
 	image.installs[arch] = rule.Installs()
 	image.vdexInstalls[arch] = vdexInstalls
 	image.unstrippedInstalls[arch] = unstrippedInstalls
+
+	return zipFiles
 }
 
 const failureMessage = `ERROR: Dex2oat failed to compile a boot image.
@@ -443,6 +464,7 @@
 		ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String())
 		ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_FILES", strings.Join(image.dexPaths.Strings(), " "))
 		ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(image.dexLocations, " "))
+		ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+image.name, image.zip.String())
 
 		var imageNames []string
 		for _, current := range append(d.otherImages, image) {
@@ -452,6 +474,8 @@
 				ctx.Strict("DEXPREOPT_IMAGE_"+current.name+"_"+arch.String(), current.images[arch].String())
 				ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.installs[arch].String())
 				ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.unstrippedInstalls[arch].String())
+				if current.zip != nil {
+				}
 			}
 		}
 		ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(imageNames, " "))
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index 409b4b1..b30bd00 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -111,6 +111,7 @@
 		dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_bootjars")
 		symbolsDir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "dex_bootjars_unstripped")
 		images := make(map[android.ArchType]android.OutputPath)
+		zip := dir.Join(ctx, "boot.zip")
 
 		for _, target := range ctx.Config().Targets[android.Android] {
 			images[target.Arch.ArchType] = dir.Join(ctx,
@@ -125,6 +126,7 @@
 			dir:          dir,
 			symbolsDir:   symbolsDir,
 			images:       images,
+			zip:          zip,
 		}
 	}).(bootImageConfig)
 }
diff --git a/java/gen.go b/java/gen.go
index 500d887..7c57a46 100644
--- a/java/gen.go
+++ b/java/gen.go
@@ -23,8 +23,9 @@
 func init() {
 	pctx.HostBinToolVariable("aidlCmd", "aidl")
 	pctx.HostBinToolVariable("syspropCmd", "sysprop_java")
-	pctx.SourcePathVariable("logtagsCmd", "build/tools/java-event-log-tags.py")
-	pctx.SourcePathVariable("mergeLogtagsCmd", "build/tools/merge-event-log-tags.py")
+	pctx.SourcePathVariable("logtagsCmd", "build/make/tools/java-event-log-tags.py")
+	pctx.SourcePathVariable("mergeLogtagsCmd", "build/make/tools/merge-event-log-tags.py")
+	pctx.SourcePathVariable("logtagsLib", "build/make/tools/event_log_tags.py")
 }
 
 var (
@@ -38,13 +39,13 @@
 	logtags = pctx.AndroidStaticRule("logtags",
 		blueprint.RuleParams{
 			Command:     "$logtagsCmd -o $out $in",
-			CommandDeps: []string{"$logtagsCmd"},
+			CommandDeps: []string{"$logtagsCmd", "$logtagsLib"},
 		})
 
 	mergeLogtags = pctx.AndroidStaticRule("mergeLogtags",
 		blueprint.RuleParams{
 			Command:     "$mergeLogtagsCmd -o $out $in",
-			CommandDeps: []string{"$mergeLogtagsCmd"},
+			CommandDeps: []string{"$mergeLogtagsCmd", "$logtagsLib"},
 		})
 
 	sysprop = pctx.AndroidStaticRule("sysprop",
diff --git a/java/java_test.go b/java/java_test.go
index 4158621..e8b23d6 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -163,8 +163,8 @@
 		"prebuilts/sdk/Android.bp":                    []byte(`prebuilt_apis { name: "sdk", api_dirs: ["14", "28", "current"],}`),
 
 		// For framework-res, which is an implicit dependency for framework
-		"AndroidManifest.xml":                   nil,
-		"build/target/product/security/testkey": nil,
+		"AndroidManifest.xml":                        nil,
+		"build/make/target/product/security/testkey": nil,
 
 		"build/soong/scripts/jar-wrapper.sh": nil,
 
diff --git a/java/kotlin.go b/java/kotlin.go
index 81b89f9..54c6b0e 100644
--- a/java/kotlin.go
+++ b/java/kotlin.go
@@ -27,16 +27,22 @@
 
 var kotlinc = pctx.AndroidGomaStaticRule("kotlinc",
 	blueprint.RuleParams{
-		Command: `rm -rf "$classesDir" "$srcJarDir" "$kotlinBuildFile" && mkdir -p "$classesDir" "$srcJarDir" && ` +
+		Command: `rm -rf "$classesDir" "$srcJarDir" "$kotlinBuildFile" "$emptyDir" && ` +
+			`mkdir -p "$classesDir" "$srcJarDir" "$emptyDir" && ` +
 			`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
 			`${config.GenKotlinBuildFileCmd} $classpath $classesDir $out.rsp $srcJarDir/list > $kotlinBuildFile &&` +
 			`${config.KotlincCmd} ${config.JavacHeapFlags} $kotlincFlags ` +
-			`-jvm-target $kotlinJvmTarget -Xbuild-file=$kotlinBuildFile && ` +
+			`-jvm-target $kotlinJvmTarget -Xbuild-file=$kotlinBuildFile -kotlin-home $emptyDir && ` +
 			`${config.SoongZipCmd} -jar -o $out -C $classesDir -D $classesDir && ` +
 			`rm -rf "$srcJarDir"`,
 		CommandDeps: []string{
 			"${config.KotlincCmd}",
 			"${config.KotlinCompilerJar}",
+			"${config.KotlinPreloaderJar}",
+			"${config.KotlinReflectJar}",
+			"${config.KotlinScriptRuntimeJar}",
+			"${config.KotlinStdlibJar}",
+			"${config.KotlinTrove4jJar}",
 			"${config.GenKotlinBuildFileCmd}",
 			"${config.SoongZipCmd}",
 			"${config.ZipSyncCmd}",
@@ -44,7 +50,7 @@
 		Rspfile:        "$out.rsp",
 		RspfileContent: `$in`,
 	},
-	"kotlincFlags", "classpath", "srcJars", "srcJarDir", "classesDir", "kotlinJvmTarget", "kotlinBuildFile")
+	"kotlincFlags", "classpath", "srcJars", "srcJarDir", "classesDir", "kotlinJvmTarget", "kotlinBuildFile", "emptyDir")
 
 // kotlinCompile takes .java and .kt sources and srcJars, and compiles the .kt sources into a classes jar in outputFile.
 func kotlinCompile(ctx android.ModuleContext, outputFile android.WritablePath,
@@ -68,6 +74,7 @@
 			"classesDir":      android.PathForModuleOut(ctx, "kotlinc", "classes").String(),
 			"srcJarDir":       android.PathForModuleOut(ctx, "kotlinc", "srcJars").String(),
 			"kotlinBuildFile": android.PathForModuleOut(ctx, "kotlinc-build.xml").String(),
+			"emptyDir":        android.PathForModuleOut(ctx, "kotlinc", "empty").String(),
 			// http://b/69160377 kotlinc only supports -jvm-target 1.6 and 1.8
 			"kotlinJvmTarget": "1.8",
 		},
diff --git a/phony/phony.go b/phony/phony.go
index ed6a2fe..305a434 100644
--- a/phony/phony.go
+++ b/phony/phony.go
@@ -28,7 +28,9 @@
 
 type phony struct {
 	android.ModuleBase
-	requiredModuleNames []string
+	requiredModuleNames       []string
+	hostRequiredModuleNames   []string
+	targetRequiredModuleNames []string
 }
 
 func PhonyFactory() android.Module {
@@ -40,8 +42,12 @@
 
 func (p *phony) GenerateAndroidBuildActions(ctx android.ModuleContext) {
 	p.requiredModuleNames = ctx.RequiredModuleNames()
-	if len(p.requiredModuleNames) == 0 {
-		ctx.PropertyErrorf("required", "phony must not have empty required dependencies in order to be useful(and therefore permitted).")
+	p.hostRequiredModuleNames = ctx.HostRequiredModuleNames()
+	p.targetRequiredModuleNames = ctx.TargetRequiredModuleNames()
+	if len(p.requiredModuleNames) == 0 &&
+		len(p.hostRequiredModuleNames) == 0 && len(p.targetRequiredModuleNames) == 0 {
+		ctx.PropertyErrorf("required", "phony must not have empty required dependencies "+
+			"in order to be useful(and therefore permitted).")
 	}
 }
 
@@ -54,7 +60,18 @@
 			if p.Host() {
 				fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
 			}
-			fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(p.requiredModuleNames, " "))
+			if len(p.requiredModuleNames) > 0 {
+				fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=",
+					strings.Join(p.requiredModuleNames, " "))
+			}
+			if len(p.hostRequiredModuleNames) > 0 {
+				fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=",
+					strings.Join(p.hostRequiredModuleNames, " "))
+			}
+			if len(p.targetRequiredModuleNames) > 0 {
+				fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=",
+					strings.Join(p.targetRequiredModuleNames, " "))
+			}
 			fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
 		},
 	}
diff --git a/python/builder.go b/python/builder.go
index e3b490c..36baecd 100644
--- a/python/builder.go
+++ b/python/builder.go
@@ -73,7 +73,7 @@
 
 func init() {
 	pctx.Import("github.com/google/blueprint/bootstrap")
-	pctx.Import("android/soong/common")
+	pctx.Import("android/soong/android")
 
 	pctx.HostBinToolVariable("parCmd", "soong_zip")
 	pctx.HostBinToolVariable("mergeParCmd", "merge_zips")
diff --git a/scripts/clang-tidy.sh b/scripts/clang-tidy.sh
deleted file mode 100755
index 04d0bdd..0000000
--- a/scripts/clang-tidy.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash -e
-
-# Copyright 2018 Google Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Wrapper script to remove clang compiler flags rejected by clang-tidy.
-# Inputs:
-#  Environment:
-#   CLANG_TIDY: path to the real clang-tidy program
-
-# clang-tidy doesn't recognize every flag that clang compiler does.
-# It gives clang-diagnostic-unused-command-line-argument warnings
-# to -Wa,* flags.
-# The -flto flags caused clang-tidy to ignore the -I flags,
-# see https://bugs.llvm.org/show_bug.cgi?id=38332.
-# -fsanitize and -fwhole-program-vtables need -flto.
-args=("${@}")
-n=${#args[@]}
-for ((i=0; i<$n; ++i)); do
-  case ${args[i]} in
-    -Wa,*|-flto|-flto=*|-fsanitize=*|-fsanitize-*|-fwhole-program-vtables)
-      unset args[i]
-      ;;
-  esac
-done
-${CLANG_TIDY} "${args[@]}"
diff --git a/scripts/setup_go_workspace_for_soong.sh b/scripts/setup_go_workspace_for_soong.sh
index 6374aae..479d09c 100755
--- a/scripts/setup_go_workspace_for_soong.sh
+++ b/scripts/setup_go_workspace_for_soong.sh
@@ -349,6 +349,7 @@
   "${ANDROID_PATH}/external/golang-protobuf|${OUTPUT_PATH}/src/github.com/golang/protobuf"
   "${ANDROID_PATH}/external/llvm/soong|${OUTPUT_PATH}/src/android/soong/llvm"
   "${ANDROID_PATH}/external/clang/soong|${OUTPUT_PATH}/src/android/soong/clang"
+  "${ANDROID_PATH}/external/robolectric-shadows/soong|${OUTPUT_PATH}/src/android/soong/robolectric"
 )
 
 main "$@"
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index a7aff59..af89c24 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -135,8 +135,8 @@
 		"prebuilts/sdk/Android.bp":                                            []byte(`prebuilt_apis { name: "sdk", api_dirs: ["28", "current"],}`),
 
 		// For framework-res, which is an implicit dependency for framework
-		"AndroidManifest.xml":                   nil,
-		"build/target/product/security/testkey": nil,
+		"AndroidManifest.xml":                        nil,
+		"build/make/target/product/security/testkey": nil,
 
 		"build/soong/scripts/jar-wrapper.sh": nil,