Allow V8 to be built even when chromium is prebuilt.

When using a prebuilt libwebviewchromium, instead of skipping the entire
directory just include the makefiles needed to build V8 for
external/chromium-libpac to use.

Bug: 17228462
Change-Id: I0f543120265707d47674a85e059787a2c77611bd
diff --git a/Android.mk b/Android.mk
index 4871185..6249a1c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -5,18 +5,43 @@
 # This Android makefile is used to build WebView in the Android build system.
 # gyp autogenerates most of the real makefiles, which we include below.
 
-# Don't do anything if the product is using a prebuilt webviewchromium, to avoid
-# duplicate target definitions between this directory and the prebuilts.
-ifneq ($(PRODUCT_PREBUILT_WEBVIEWCHROMIUM),yes)
-
-CHROMIUM_DIR := $(call my-dir)
+LOCAL_PATH := $(call my-dir)
+CHROMIUM_DIR := $(LOCAL_PATH)
 
 # We default to release for the Android build system. Developers working on
 # WebView code can build with "make GYP_CONFIGURATION=Debug".
 GYP_CONFIGURATION := Release
 
-# Include the manually-written makefile that builds all the WebView java code.
+# If the product is using a prebuilt libwebviewchromium then we need to skip
+# including most of the makefiles to avoid duplicate target definitions. Some
+# targets are still needed, so list their makefiles explicitly.
+ifeq ($(PRODUCT_PREBUILT_WEBVIEWCHROMIUM),yes)
+GYP_MAKEFILE_STEMS := \
+	$(addprefix $(CHROMIUM_DIR)/v8/tools/gyp/, \
+		generate_trig_table.host \
+		js2c.host \
+		mksnapshot.host \
+		v8_base.host \
+		v8_libbase.host \
+		v8_nosnapshot.host \
+		v8_base.target \
+		v8_libbase.target \
+		v8_snapshot.target \
+	) \
+	$(addprefix $(CHROMIUM_DIR)/third_party/icu/, \
+		icudata.host \
+		icui18n.host \
+		icuuc.host \
+		icui18n.target \
+		icuuc.target \
+		system_icu.target \
+	)
+else
+# Not using a prebuilt; include the manually-written makefile that builds all
+# the WebView java code, and use the main autogenerated makefile.
 include $(CHROMIUM_DIR)/android_webview/Android.mk
+GYP_MAKEFILE_STEMS := $(CHROMIUM_DIR)/GypAndroid
+endif
 
 # If the gyp-generated makefile exists for the current host OS and primary
 # target architecture, we need to include it. If it doesn't exist then just do
@@ -40,7 +65,8 @@
 endif
 endif
 
-include $(CHROMIUM_DIR)/GypAndroid.$(HOST_OS)-$(TARGET_ARCH).mk
+# Include the appropriate version of each of the makefiles.
+include $(addsuffix .$(HOST_OS)-$(TARGET_ARCH).mk,$(GYP_MAKEFILE_STEMS))
 
 endif  # End primary architecture handling.
 
@@ -66,8 +92,7 @@
 endif
 endif
 
-include $(CHROMIUM_DIR)/GypAndroid.$(HOST_OS)-$(TARGET_2ND_ARCH).mk
+# Include the appropriate version of each of the makefiles.
+include $(addsuffix .$(HOST_OS)-$(TARGET_2ND_ARCH).mk,$(GYP_MAKEFILE_STEMS))
 
 endif  # End secondary architecture handling.
-
-endif