Support 'cc_library' in androidbp

Change-Id: I0a0ee48aac786a422e68e14ba14fc6186296214d
diff --git a/androidbp/cmd/androidbp.go b/androidbp/cmd/androidbp.go
index 2dba6c1..4174fe5 100644
--- a/androidbp/cmd/androidbp.go
+++ b/androidbp/cmd/androidbp.go
@@ -241,22 +241,54 @@
 	return
 }
 
-func (w *androidMkWriter) handleModule(module *bpparser.Module) {
-	moduleRule := fmt.Sprintf(module.Type.Name)
-	if translation, ok := moduleTypeToRule[module.Type.Name]; ok {
-		moduleRule = translation
+func (w *androidMkWriter) mutateModule(module *bpparser.Module) (modules []*bpparser.Module) {
+	if module.Type.Name == "cc_library" {
+		modules = append(modules, &bpparser.Module{
+			Type: bpparser.Ident{
+				Name: "cc_library_shared",
+				Pos:  module.Type.Pos,
+			},
+			Properties: module.Properties,
+			LbracePos:  module.LbracePos,
+			RbracePos:  module.RbracePos,
+		})
+
+		modules = append(modules, &bpparser.Module{
+			Type: bpparser.Ident{
+				Name: "cc_library_static",
+				Pos:  module.Type.Pos,
+			},
+			Properties: module.Properties,
+			LbracePos:  module.LbracePos,
+			RbracePos:  module.RbracePos,
+		})
+	} else {
+		modules = []*bpparser.Module{module}
 	}
 
-	isHostRule := strings.Contains(moduleRule, "HOST")
-	hostSupported := w.parsePropsAndWriteModule(moduleRule, isHostRule, module)
+	return
+}
 
-	if !isHostRule && hostSupported {
-		hostModuleRule := "NO CORRESPONDING HOST RULE" + moduleRule
-		if trans, ok := targetToHostModuleRule[moduleRule]; ok {
-			hostModuleRule = trans
+func (w *androidMkWriter) handleModule(inputModule *bpparser.Module) {
+	modules := w.mutateModule(inputModule)
+
+	for _, module := range modules {
+		moduleRule := fmt.Sprintf(module.Type.Name)
+		if translation, ok := moduleTypeToRule[module.Type.Name]; ok {
+			moduleRule = translation
 		}
 
-		w.parsePropsAndWriteModule(hostModuleRule, true, module)
+		isHostRule := strings.Contains(moduleRule, "HOST")
+		hostSupported := w.parsePropsAndWriteModule(moduleRule, isHostRule, module)
+
+		if !isHostRule && hostSupported {
+			hostModuleRule := "NO CORRESPONDING HOST RULE" + moduleRule
+			if trans, ok := targetToHostModuleRule[moduleRule]; ok {
+				hostModuleRule = trans
+			}
+
+			w.parsePropsAndWriteModule(hostModuleRule, true, module)
+		}
 	}
 }
 
diff --git a/androidbp/cmd/androidbp_test.go b/androidbp/cmd/androidbp_test.go
index 4befa73..aab7e5f 100644
--- a/androidbp/cmd/androidbp_test.go
+++ b/androidbp/cmd/androidbp_test.go
@@ -85,6 +85,17 @@
 			    LOCAL_MODULE := test
 			    include $(BUILD_HOST_SHARED_LIBRARY)`,
 	},
+	// Static and Shared
+	{
+		blueprint: `cc_library { name: "test", }`,
+		androidmk: `include $(CLEAR_VARS)
+			    LOCAL_MODULE := test
+			    include $(BUILD_SHARED_LIBRARY)
+
+			    include $(CLEAR_VARS)
+			    LOCAL_MODULE := test
+			    include $(BUILD_STATIC_LIBRARY)`,
+	},
 }
 
 func TestModules(t *testing.T) {