Merge "Add build rules to generate native DBus interfaces"

This commit is contained in:
Christopher Wiley 2015-08-05 15:40:00 +00:00 committed by Gerrit Code Review
commit 5923fcd021
3 changed files with 61 additions and 0 deletions

View File

@ -569,6 +569,51 @@ 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.
###########################################################

View File

@ -399,6 +399,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)

View File

@ -968,6 +968,21 @@ $(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
###########################################################