diff --git a/core/binary.mk b/core/binary.mk index b76bc3863f..048d13a84d 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -591,6 +591,51 @@ else endif endif # $(proto_sources) non-empty +########################################################### +## Compile the .dbus.xml files to c++ headers +########################################################### +dbus_if_sources := $(filter %.dbus.xml,$(my_src_files)) +ifneq ($(dbus_if_sources),) + +dbus_if_sources_full_path := $(addprefix $(LOCAL_PATH)/,$(dbus_if_sources)) +dbus_service_config := $(filter %dbus-service-config.json,$(my_src_files)) +dbus_service_config_full_path := $(addprefix $(LOCAL_PATH)/,$(dbus_service_config)) + +dbus_header_prefix := $(generated_sources_dir)/dbus-bindings/$(LOCAL_MODULE) +dbus_adaptors_header := $(dbus_header_prefix)/adaptors.h +dbus_proxies_header := $(dbus_header_prefix)/proxies.h +dbus_method_names_header := $(dbus_header_prefix)/method_names.h + +dbus_generated_source_dependencies := \ + $(dbus_if_sources_full_path) \ + $(dbus_service_config_full_path) \ + $(DBUS_GENERATOR) + +# Ensure that we only define build rules once in multilib builds. +ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined +$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined := true +$(dbus_adaptors_header) : PRIVATE_DBUS_MODULE := $(LOCAL_MODULE) +$(dbus_adaptors_header) : PRIVATE_DBUS_HEADER_DIRECTORY := $(dbus_header_prefix) +$(dbus_adaptors_header) : PRIVATE_DBUS_SERVICE_CONFIG := $(dbus_service_config_full_path) +$(dbus_adaptors_header) : PRIVATE_DBUS_ADAPTORS_HEADER := $(dbus_adaptors_header) +$(dbus_adaptors_header) : PRIVATE_DBUS_PROXIES_HEADER := $(dbus_proxies_header) +$(dbus_adaptors_header) : PRIVATE_DBUS_METHOD_NAMES_HEADER := $(dbus_method_names_header) +$(dbus_adaptors_header) : PRIVATE_DBUS_INTERFACE_DEFINITIONS := $(dbus_if_sources_full_path) +$(dbus_adaptors_header) : $(dbus_generated_source_dependencies) + $(generate-dbus-bindings) +# These are actually generated by the above recipe, but we'd like to make the +# dependency chain complete. +$(dbus_proxies_header) : $(dbus_adaptors_header) +$(dbus_method_names_header) : $(dbus_adaptors_header) +endif # $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined + +my_generated_sources += \ + $(dbus_adaptors_header) \ + $(dbus_proxies_header) \ + $(dbus_method_names_header) +endif # $(dbus_if_sources) non-empty + + ########################################################### ## YACC: Compile .y and .yy files to .cpp and the to .o. ########################################################### diff --git a/core/config.mk b/core/config.mk index 824597a970..ad883659c6 100644 --- a/core/config.mk +++ b/core/config.mk @@ -404,6 +404,7 @@ DOXYGEN:= doxygen AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX) AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX) PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX) +DBUS_GENERATOR := $(HOST_OUT_EXECUTABLES)/dbus-binding-generator SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX) MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX) MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX) diff --git a/core/definitions.mk b/core/definitions.mk index 45e6b563a9..8110518d49 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -967,6 +967,22 @@ $(hide) $(PROTOC) \ $< endef + +###################################################################### +## Commands for running protoc to compile .proto into .pb.cc and .pb.h +###################################################################### +define generate-dbus-bindings +@echo "Generating DBus bindings for $(PRIVATE_DBUS_MODULE)" +@mkdir -p $(PRIVATE_DBUS_HEADER_DIRECTORY) +$(hide) $(DBUS_GENERATOR) \ + --service-config=$(PRIVATE_DBUS_SERVICE_CONFIG) \ + --adaptor=$(PRIVATE_DBUS_ADAPTORS_HEADER) \ + --proxy=$(PRIVATE_DBUS_PROXIES_HEADER) \ + --method-names=$(PRIVATE_DBUS_METHOD_NAMES_HEADER) \ + $(PRIVATE_DBUS_INTERFACE_DEFINITIONS) +endef + + ########################################################### ## Commands for running gcc to compile a C++ file ###########################################################