Merge "Adapt special case framework support."
diff --git a/android/variable.go b/android/variable.go
index b4ed1b7..b478389 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -43,8 +43,8 @@
 		} `android:"arch_variant"`
 
 		Malloc_not_svelte struct {
-			Cflags []string
-		}
+			Cflags []string `android:"arch_variant"`
+		} `android:"arch_variant"`
 
 		Safestack struct {
 			Cflags []string `android:"arch_variant"`
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 3dd4d11..ff8a878 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -62,7 +62,7 @@
 }
 
 func (p *prebuiltLibraryLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
-	return Flags{}
+	return flags
 }
 
 func (p *prebuiltLibraryLinker) linkerProps() []interface{} {
diff --git a/cmd/pom2bp/pom2bp.go b/cmd/pom2bp/pom2bp.go
index a66a424..a79c84f 100644
--- a/cmd/pom2bp/pom2bp.go
+++ b/cmd/pom2bp/pom2bp.go
@@ -186,6 +186,34 @@
 	return !p.IsHostModule()
 }
 
+func (p Pom) ModuleType() string {
+	if p.IsAar() {
+		return "android_library"
+	} else if p.IsHostModule() {
+		return "java_library_host"
+	} else {
+		return "java_library_static"
+	}
+}
+
+func (p Pom) ImportModuleType() string {
+	if p.IsAar() {
+		return "android_library_import"
+	} else if p.IsHostModule() {
+		return "java_import_host"
+	} else {
+		return "java_import"
+	}
+}
+
+func (p Pom) ImportProperty() string {
+	if p.IsAar() {
+		return "aars"
+	} else {
+		return "jars"
+	}
+}
+
 func (p Pom) BpName() string {
 	if p.BpTarget == "" {
 		p.BpTarget = rewriteNames.MavenToBp(p.GroupId, p.ArtifactId)
@@ -293,27 +321,43 @@
 }
 
 var bpTemplate = template.Must(template.New("bp").Parse(`
-{{if .IsAar}}android_library_import{{else if .IsDeviceModule}}java_import{{else}}java_import_host{{end}} {
+{{.ImportModuleType}} {
     name: "{{.BpName}}-nodeps",
-    {{if .IsAar}}aars{{else}}jars{{end}}: ["{{.ArtifactFile}}"],
-    sdk_version: "{{.SdkVersion}}",{{if .IsAar}}
+    {{.ImportProperty}}: ["{{.ArtifactFile}}"],
+    sdk_version: "{{.SdkVersion}}",
+    {{- if .IsAar}}
     min_sdk_version: "{{.MinSdkVersion}}",
-    static_libs: [{{range .BpAarDeps}}
-        "{{.}}",{{end}}{{range .BpExtraDeps}}
-        "{{.}}",{{end}}
-    ],{{end}}
+    static_libs: [
+        {{- range .BpAarDeps}}
+        "{{.}}",
+        {{- end}}
+        {{- range .BpExtraDeps}}
+        "{{.}}",
+        {{- end}}
+    ],
+    {{- end}}
 }
 
-{{if .IsAar}}android_library{{else if .IsDeviceModule}}java_library_static{{else}}java_library_host{{end}} {
-    name: "{{.BpName}}",{{if .IsDeviceModule}}
-    sdk_version: "{{.SdkVersion}}",{{if .IsAar}}
+{{.ModuleType}} {
+    name: "{{.BpName}}",
+    {{- if .IsDeviceModule}}
+    sdk_version: "{{.SdkVersion}}",
+    {{- if .IsAar}}
     min_sdk_version: "{{.MinSdkVersion}}",
-    manifest: "manifests/{{.BpName}}/AndroidManifest.xml",{{end}}{{end}}
+    manifest: "manifests/{{.BpName}}/AndroidManifest.xml",
+    {{- end}}
+    {{- end}}
     static_libs: [
-        "{{.BpName}}-nodeps",{{range .BpJarDeps}}
-        "{{.}}",{{end}}{{range .BpAarDeps}}
-        "{{.}}",{{end}}{{range .BpExtraDeps}}
-        "{{.}}",{{end}}
+        "{{.BpName}}-nodeps",
+         {{- range .BpJarDeps}}
+        "{{.}}",
+        {{- end}}
+        {{- range .BpAarDeps}}
+        "{{.}}",
+        {{- end}}
+        {{- range .BpExtraDeps}}
+        "{{.}}",
+        {{- end}}
     ],
     java_version: "1.7",
 }
diff --git a/ui/build/config.go b/ui/build/config.go
index 2605f5b..fdeb8f2 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -369,14 +369,14 @@
 
 func (c *configImpl) OutDir() string {
 	if outDir, ok := c.environ.Get("OUT_DIR"); ok {
-		return outDir
+		return filepath.Clean(outDir)
 	}
 	return "out"
 }
 
 func (c *configImpl) DistDir() string {
 	if distDir, ok := c.environ.Get("DIST_DIR"); ok {
-		return distDir
+		return filepath.Clean(distDir)
 	}
 	return filepath.Join(c.OutDir(), "dist")
 }
diff --git a/ui/build/kati.go b/ui/build/kati.go
index b54872c..b26d673 100644
--- a/ui/build/kati.go
+++ b/ui/build/kati.go
@@ -81,6 +81,8 @@
 		"--warn_real_to_phony",
 		"--warn_phony_looks_real",
 		"--kati_stats",
+		"--writable", config.OutDir() + "/",
+		"--writable", config.DistDir() + "/",
 		"-f", "build/make/core/main.mk",
 	}
 
@@ -94,7 +96,10 @@
 	}
 
 	if !config.BuildBrokenPhonyTargets() {
-		args = append(args, "--werror_real_to_phony", "--werror_phony_looks_real")
+		args = append(args,
+			"--werror_real_to_phony",
+			"--werror_phony_looks_real",
+			"--werror_writable")
 	}
 
 	if !config.Environment().IsFalse("KATI_EMULATE_FIND") {