1JSON_DUMP :=
2
3# Older versions of GNUmake do not support actual writing to file, so we sort of do what we can
4# and write out text in chunks, escaping "
5write-to-file = \
6  $(eval _args:=) \
7  $(foreach obj,$3,$(eval _args+=$(obj))$(if $(word $2,$(_args)),@printf "%s" $(subst ",\",$(_args)) >> $1 $(EOL)$(eval _args:=))) \
8  $(if $(_args),@printf "%s" $(subst ",\", $(_args)) >> $1) \
9
10define EOL
11
12
13endef
14
15# Functions to dump build information into a JSON tree.
16# This creates a [ "", "elem1", "elem2" ]
17dump-json-list = \
18	$(eval JSON_DUMP += [ "" ) \
19	$(if $(1),\
20      $(foreach _list_item,$(strip $1),$(eval JSON_DUMP += , "$(subst ",\",$(_list_item))")) \
21	) \
22	$(eval JSON_DUMP += ] )\
23
24# This creates , "name" : ["", "e1", "e2" ]
25dump-property-list = \
26    $(eval JSON_DUMP += , "$(1)" : ) \
27	$(call dump-json-list, $($(2)))\
28
29# Dumps the module
30dump-json-module = \
31    $(eval JSON_DUMP += , { "module" : "$(_emugl_MODULE) ")\
32    $(eval JSON_DUMP += ,  "path" : "$(LOCAL_PATH) ")\
33    $(eval JSON_DUMP += , "type" : "$(_emugl.$(_emugl_MODULE).type)")\
34	$(call dump-property-list,includes,LOCAL_C_INCLUDES) \
35	$(call dump-property-list,cflags,LOCAL_CFLAGS) \
36	$(call dump-property-list,libs,LOCAL_SHARED_LIBRARIES) \
37	$(call dump-property-list,staticlibs,LOCAL_STATIC_LIBRARIES) \
38	$(call dump-property-list,src,LOCAL_SRC_FILES) \
39    $(eval JSON_DUMP += } )\
40
41