build: support compiling .mm on host

libchrome uses .mm (Objective-C++) files to bridge C++ code with
OS X Frameworks. This adds support for compiling .mm to .o by just
using the existing C++ support.

Bug: 24168923
Change-Id: Ia65357e2e2584dfffcb6796e214fe6b27635c3a6
diff --git a/core/binary.mk b/core/binary.mk
index 7aa9937..093cc38 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -927,6 +927,20 @@
 endif
 
 ###########################################################
+## ObjC++: Compile .mm files to .o
+###########################################################
+
+objcpp_sources := $(filter %.mm,$(my_src_files))
+objcpp_objects := $(addprefix $(intermediates)/,$(objcpp_sources:.mm=.o))
+
+ifneq ($(strip $(objcpp_objects)),)
+$(objcpp_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.mm $(yacc_cpps) $(proto_generated_headers) \
+    $(my_additional_dependencies)
+	$(transform-$(PRIVATE_HOST)mm-to-o)
+-include $(objcpp_objects:%.o=%.P)
+endif
+
+###########################################################
 ## AS: Compile .S files to .o.
 ###########################################################
 
@@ -1039,6 +1053,7 @@
     $(c_objects) \
     $(gen_c_objects) \
     $(objc_objects) \
+    $(objcpp_objects) \
     $(yacc_objects) \
     $(lex_objects) \
     $(proto_generated_objects) \
diff --git a/core/definitions.mk b/core/definitions.mk
index f56a49b..cb7932e 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1198,6 +1198,14 @@
 $(transform-d-to-p)
 endef
 
+###########################################################
+## Commands for running gcc to compile a host Objective-C++ file
+###########################################################
+
+define transform-host-mm-to-o
+$(transform-host-cpp-to-o)
+endef
+
 
 ###########################################################
 ## Rules to compile a single C/C++ source with ../ in the path