Fix rebuilding of snapshot.cc

Use the build rule for generated source. Depending on the binary and not the
module name.

Bug: 2504831
Change-Id: I977df96a6e4a98fb87defa80fc98702a5eacec9f
diff --git a/Android.libv8.mk b/Android.libv8.mk
index ecaf762..850df3a 100644
--- a/Android.libv8.mk
+++ b/Android.libv8.mk
@@ -31,7 +31,6 @@
 	@echo "Copying $@"
 	$(copy-file-to-target)
 
-LOCAL_GENERATED_SOURCES :=
 # Generate libraries.cc
 GEN1 := $(intermediates)/libraries.cc $(intermediates)/libraries-empty.cc
 $(GEN1): SCRIPT := $(intermediates)/js2c.py
@@ -46,15 +45,11 @@
 # Generate snapshot.cc
 ifeq ($(ENABLE_V8_SNAPSHOT),true)
 SNAP_GEN := $(intermediates)/snapshot.cc
-$(SNAP_GEN): MKSNAPSHOT := $(HOST_OUT_EXECUTABLES)/mksnapshot
-# mksnapshot is the module name. This dependency rule makes sure that mksnapshot
-# is built before calling the following rule.
-$(SNAP_GEN): mksnapshot
-	@echo "Generating snapshot.cc"
-	@mkdir -p $(dir $@)
-	@echo $(MKSNAPSHOT) $(SNAP_GEN)
-	$(MKSNAPSHOT) $(SNAP_GEN)
-LOCAL_GENERATED_SOURCES += $(intermediates)/snapshot.cc
+MKSNAPSHOT := $(HOST_OUT_EXECUTABLES)/mksnapshot
+$(SNAP_GEN): PRIVATE_CUSTOM_TOOL = $(MKSNAPSHOT) $(SNAP_GEN)
+$(SNAP_GEN): $(MKSNAPSHOT)
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(SNAP_GEN)
 else
 LOCAL_SRC_FILES += \
   src/snapshot-empty.cc