Merge "Add CC_WRAPPER support"
diff --git a/Android.bp b/Android.bp
index 355dfd2..3d5144c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -10,32 +10,11 @@
 //    2) Build again
 //
 
-subdirs = ["third_party/zip"]
-
-bootstrap_go_binary {
-    name: "soong_build",
-    deps: [
-        "blueprint",
-        "blueprint-bootstrap",
-        "soong",
-        "soong-android",
-        "soong-env",
-    ],
-    srcs: [
-        "cmd/soong_build/main.go",
-    ],
-    primaryBuilder: true,
-}
-
-bootstrap_go_binary {
-    name: "soong_env",
-    deps: [
-        "soong-env",
-    ],
-    srcs: [
-        "cmd/soong_env/soong_env.go",
-    ],
-}
+subdirs = [
+    "androidmk",
+    "cmd/*",
+    "third_party/zip",
+]
 
 bootstrap_go_package {
     name: "soong-env",
@@ -46,16 +25,6 @@
 }
 
 
-blueprint_go_binary {
-    name: "soong_glob",
-    deps: [
-        "soong-glob",
-    ],
-    srcs: [
-        "cmd/soong_glob/soong_glob.go",
-    ],
-}
-
 bootstrap_go_package {
     name: "soong-glob",
     pkgPath: "android/soong/glob",
@@ -198,23 +167,6 @@
     pluginFor: ["soong_build"],
 }
 
-blueprint_go_binary {
-    name: "zip2zip",
-    deps: ["android-archive-zip"],
-    srcs: [
-        "cmd/zip2zip/zip2zip.go",
-    ],
-}
-
-blueprint_go_binary {
-    name: "soong_zip",
-    deps: ["android-archive-zip"],
-    srcs: [
-        "cmd/soong_zip/soong_zip.go",
-        "cmd/soong_zip/rate_limit.go",
-    ],
-}
-
 bootstrap_go_package {
     name: "soong-java",
     pkgPath: "android/soong/java",
@@ -238,40 +190,6 @@
 }
 
 //
-// androidmk Android.mk to Blueprints translator
-//
-
-blueprint_go_binary {
-    name: "androidmk",
-    srcs: [
-        "androidmk/cmd/androidmk/android.go",
-        "androidmk/cmd/androidmk/androidmk.go",
-        "androidmk/cmd/androidmk/values.go",
-    ],
-    testSrcs: [
-        "androidmk/cmd/androidmk/androidmk_test.go",
-    ],
-    deps: [
-        "androidmk-parser",
-        "blueprint-parser",
-    ],
-}
-
-bootstrap_go_package {
-    name: "androidmk-parser",
-    pkgPath: "android/soong/androidmk/parser",
-    srcs: [
-        "androidmk/parser/ast.go",
-        "androidmk/parser/make_strings.go",
-        "androidmk/parser/parser.go",
-        "androidmk/parser/scope.go",
-    ],
-    testSrcs: [
-        "androidmk/parser/make_strings_test.go",
-    ],
-}
-
-//
 // C static libraries extracted from the gcc toolchain
 //
 
diff --git a/androidmk/Android.bp b/androidmk/Android.bp
new file mode 100644
index 0000000..67baf0a
--- /dev/null
+++ b/androidmk/Android.bp
@@ -0,0 +1,48 @@
+// Copyright 2015 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.
+
+//
+// androidmk Android.mk to Blueprints translator
+//
+
+blueprint_go_binary {
+    name: "androidmk",
+    srcs: [
+        "cmd/androidmk/android.go",
+        "cmd/androidmk/androidmk.go",
+        "cmd/androidmk/values.go",
+    ],
+    testSrcs: [
+        "cmd/androidmk/androidmk_test.go",
+    ],
+    deps: [
+        "androidmk-parser",
+        "blueprint-parser",
+    ],
+}
+
+bootstrap_go_package {
+    name: "androidmk-parser",
+    pkgPath: "android/soong/androidmk/parser",
+    srcs: [
+        "parser/ast.go",
+        "parser/make_strings.go",
+        "parser/parser.go",
+        "parser/scope.go",
+    ],
+    testSrcs: [
+        "parser/make_strings_test.go",
+    ],
+}
+
diff --git a/cc/androidmk.go b/cc/androidmk.go
index d4965d8..831c0fb 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -100,8 +100,7 @@
 			fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DIRS :=", strings.Join(exportedIncludes, " "))
 		}
 
-		fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
-		fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)$(LOCAL_MODULE_SUFFIX)")
+		fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
 
 		fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
 
@@ -141,12 +140,10 @@
 
 func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
 	ctx.subAndroidMk(ret, benchmark.binaryDecorator)
-	ctx.subAndroidMk(ret, benchmark.baseInstaller)
 }
 
 func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
 	ctx.subAndroidMk(ret, test.binaryDecorator)
-	ctx.subAndroidMk(ret, test.baseInstaller)
 	if Bool(test.Properties.Test_per_src) {
 		ret.SubName = "_" + test.binaryDecorator.Properties.Stem
 	}
@@ -191,6 +188,7 @@
 		path := installer.path.RelPathString()
 		dir, file := filepath.Split(path)
 		stem := strings.TrimSuffix(file, filepath.Ext(file))
+		fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
 		fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
 		fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
 		if len(installer.Properties.Symlinks) > 0 {
diff --git a/cc/cc.go b/cc/cc.go
index 801768d..274f4fd 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -873,6 +873,9 @@
 	if c.installer == nil {
 		return false
 	}
+	if c.sanitize != nil && c.sanitize.inData() {
+		return true
+	}
 	return c.installer.inData()
 }
 
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 8023933..de19b82 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -353,9 +353,6 @@
 			if c.isDependencyRoot() && c.sanitize.Sanitizer(t) {
 				modules := mctx.CreateVariations(t.String())
 				modules[0].(*Module).sanitize.SetSanitizer(t, true)
-				if mctx.AConfig().EmbeddedInMake() && !c.Host() {
-					modules[0].(*Module).sanitize.Properties.InData = true
-				}
 			} else if c.sanitize.Properties.SanitizeDep {
 				if c.Host() {
 					modules := mctx.CreateVariations(t.String())
diff --git a/cc/test.go b/cc/test.go
index 6ffa178..27b45d7 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -181,7 +181,6 @@
 	testDecorator
 	*binaryDecorator
 	*baseCompiler
-	*baseInstaller
 	Properties TestBinaryProperties
 }
 
@@ -209,14 +208,15 @@
 }
 
 func (test *testBinary) install(ctx ModuleContext, file android.Path) {
-	test.baseInstaller.dir = filepath.Join("nativetest", ctx.ModuleName())
-	test.baseInstaller.dir64 = filepath.Join("nativetest64", ctx.ModuleName())
-	test.baseInstaller.install(ctx, file)
+	test.binaryDecorator.baseInstaller.dir = filepath.Join("nativetest", ctx.ModuleName())
+	test.binaryDecorator.baseInstaller.dir64 = filepath.Join("nativetest64", ctx.ModuleName())
+	test.binaryDecorator.baseInstaller.install(ctx, file)
 }
 
 func NewTest(hod android.HostOrDeviceSupported) *Module {
 	module, binary := NewBinary(hod)
 	module.multilib = android.MultilibBoth
+	binary.baseInstaller = NewTestInstaller()
 
 	test := &testBinary{
 		testDecorator: testDecorator{
@@ -224,7 +224,6 @@
 		},
 		binaryDecorator: binary,
 		baseCompiler:    NewBaseCompiler(),
-		baseInstaller:   NewTestInstaller(),
 	}
 	test.testDecorator.Properties.Gtest = true
 	module.compiler = test
@@ -275,7 +274,6 @@
 
 type benchmarkDecorator struct {
 	*binaryDecorator
-	*baseInstaller
 }
 
 func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
@@ -294,18 +292,18 @@
 }
 
 func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) {
-	benchmark.baseInstaller.dir = filepath.Join("nativetest", ctx.ModuleName())
-	benchmark.baseInstaller.dir64 = filepath.Join("nativetest64", ctx.ModuleName())
-	benchmark.baseInstaller.install(ctx, file)
+	benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("nativetest", ctx.ModuleName())
+	benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("nativetest64", ctx.ModuleName())
+	benchmark.binaryDecorator.baseInstaller.install(ctx, file)
 }
 
 func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
 	module, binary := NewBinary(hod)
 	module.multilib = android.MultilibBoth
+	binary.baseInstaller = NewTestInstaller()
 
 	benchmark := &benchmarkDecorator{
 		binaryDecorator: binary,
-		baseInstaller:   NewTestInstaller(),
 	}
 	module.linker = benchmark
 	module.installer = benchmark
diff --git a/cmd/soong_build/Android.bp b/cmd/soong_build/Android.bp
new file mode 100644
index 0000000..d9daafc
--- /dev/null
+++ b/cmd/soong_build/Android.bp
@@ -0,0 +1,29 @@
+// Copyright 2015 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.
+
+bootstrap_go_binary {
+    name: "soong_build",
+    deps: [
+        "blueprint",
+        "blueprint-bootstrap",
+        "soong",
+        "soong-android",
+        "soong-env",
+    ],
+    srcs: [
+        "main.go",
+    ],
+    primaryBuilder: true,
+}
+
diff --git a/cmd/soong_env/Android.bp b/cmd/soong_env/Android.bp
new file mode 100644
index 0000000..b0d827c
--- /dev/null
+++ b/cmd/soong_env/Android.bp
@@ -0,0 +1,24 @@
+// Copyright 2015 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.
+
+bootstrap_go_binary {
+    name: "soong_env",
+    deps: [
+        "soong-env",
+    ],
+    srcs: [
+        "soong_env.go",
+    ],
+}
+
diff --git a/cmd/soong_glob/Android.bp b/cmd/soong_glob/Android.bp
new file mode 100644
index 0000000..bd8a4a2
--- /dev/null
+++ b/cmd/soong_glob/Android.bp
@@ -0,0 +1,23 @@
+// Copyright 2015 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.
+
+blueprint_go_binary {
+    name: "soong_glob",
+    deps: [
+        "soong-glob",
+    ],
+    srcs: [
+        "soong_glob.go",
+    ],
+}
diff --git a/cmd/soong_zip/Android.bp b/cmd/soong_zip/Android.bp
new file mode 100644
index 0000000..10896ce
--- /dev/null
+++ b/cmd/soong_zip/Android.bp
@@ -0,0 +1,22 @@
+// Copyright 2016 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.
+
+blueprint_go_binary {
+    name: "soong_zip",
+    deps: ["android-archive-zip"],
+    srcs: [
+        "soong_zip.go",
+        "rate_limit.go",
+    ],
+}
diff --git a/cmd/zip2zip/Android.bp b/cmd/zip2zip/Android.bp
new file mode 100644
index 0000000..8cac003
--- /dev/null
+++ b/cmd/zip2zip/Android.bp
@@ -0,0 +1,22 @@
+// Copyright 2016 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.
+
+blueprint_go_binary {
+    name: "zip2zip",
+    deps: ["android-archive-zip"],
+    srcs: [
+        "zip2zip.go",
+    ],
+}
+
diff --git a/root.bp b/root.bp
index c4f2d57..c42dd58 100644
--- a/root.bp
+++ b/root.bp
@@ -12,6 +12,7 @@
     "build/tools/*",
     "dalvik",
     "external/*",
+    "frameworks/av",
     "frameworks/base",
     "frameworks/native",
     "hardware/*",