Erwin Jansen | f96db3c | 2018-10-25 23:28:54 -0700 | [diff] [blame] | 1 | JSON_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 " |
| 5 | write-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 | |
| 10 | define EOL |
| 11 | |
| 12 | |
| 13 | endef |
| 14 | |
| 15 | # Functions to dump build information into a JSON tree. |
| 16 | # This creates a [ "", "elem1", "elem2" ] |
| 17 | dump-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" ] |
| 25 | dump-property-list = \ |
| 26 | $(eval JSON_DUMP += , "$(1)" : ) \ |
| 27 | $(call dump-json-list, $($(2)))\ |
| 28 | |
| 29 | # Dumps the module |
| 30 | dump-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) \ |
Lingfeng Yang | f4d77ef | 2018-11-02 23:21:37 -0700 | [diff] [blame] | 37 | $(call dump-property-list,staticlibs,LOCAL_STATIC_LIBRARIES) \ |
Erwin Jansen | f96db3c | 2018-10-25 23:28:54 -0700 | [diff] [blame] | 38 | $(call dump-property-list,src,LOCAL_SRC_FILES) \ |
| 39 | $(eval JSON_DUMP += } )\ |
| 40 | |
| 41 | |