Autogenerate the CMake build

Adds a GNUMakefile that will generate the cmake files based upon the
android makefiles. This will make it easier to keep the makefiles in
sync. If the makefiles change, we will have to run make in this
directory.

It relies on the following:

- The android.mk files are using the emugl dependency mechanism
- You are in the emulator repo (as we need the emulator build.mk files)
- We translate the emugl -> json representation.
- We write the json representation to disk
- We have a python script that transforms the json to cmake

It is all driven by GNUmake, so all you have to do is type make to
regenerate the files. SOONG does not use GNUMakefiles so we should be
able to co-exist.

Change-Id: I6f9ae22397bcf9987699b946aa14921b00fc94b0
diff --git a/json-dump.mk b/json-dump.mk
new file mode 100644
index 0000000..8abc9e7
--- /dev/null
+++ b/json-dump.mk
@@ -0,0 +1,40 @@
+JSON_DUMP :=
+
+# Older versions of GNUmake do not support actual writing to file, so we sort of do what we can
+# and write out text in chunks, escaping "
+write-to-file = \
+  $(eval _args:=) \
+  $(foreach obj,$3,$(eval _args+=$(obj))$(if $(word $2,$(_args)),@printf "%s" $(subst ",\",$(_args)) >> $1 $(EOL)$(eval _args:=))) \
+  $(if $(_args),@printf "%s" $(subst ",\", $(_args)) >> $1) \
+
+define EOL
+
+
+endef
+
+# Functions to dump build information into a JSON tree.
+# This creates a [ "", "elem1", "elem2" ]
+dump-json-list = \
+	$(eval JSON_DUMP += [ "" ) \
+	$(if $(1),\
+      $(foreach _list_item,$(strip $1),$(eval JSON_DUMP += , "$(subst ",\",$(_list_item))")) \
+	) \
+	$(eval JSON_DUMP += ] )\
+
+# This creates , "name" : ["", "e1", "e2" ] 
+dump-property-list = \
+    $(eval JSON_DUMP += , "$(1)" : ) \
+	$(call dump-json-list, $($(2)))\
+
+# Dumps the module
+dump-json-module = \
+    $(eval JSON_DUMP += , { "module" : "$(_emugl_MODULE) ")\
+    $(eval JSON_DUMP += ,  "path" : "$(LOCAL_PATH) ")\
+    $(eval JSON_DUMP += , "type" : "$(_emugl.$(_emugl_MODULE).type)")\
+	$(call dump-property-list,includes,LOCAL_C_INCLUDES) \
+	$(call dump-property-list,cflags,LOCAL_CFLAGS) \
+	$(call dump-property-list,libs,LOCAL_SHARED_LIBRARIES) \
+	$(call dump-property-list,src,LOCAL_SRC_FILES) \
+    $(eval JSON_DUMP += } )\
+
+		
\ No newline at end of file