Generate DBus proxies and adaptors separately
Enable daemons exposing an interface over DBus to easily build client libraries. Now daemons can write rules like: include $(CLEAR_VARS) LOCAL_MODULE := libdbus-binding-example-client LOCAL_DBUS_PROXY_PREFIX := dbus-example-example LOCAL_SRC_FILES := \ dbus_bindings/org.chromium.Example.Manager.dbus.xml \ dbus_bindings/dbus-service-config.json include $(BUILD_SHARED_LIBRARY) to expose a client library. While here, add support for generating independent adaptor header files on a per interface basis. Bug: 22608897 Change-Id: I011f9afc234811c31e445898321c2731c482fa77
This commit is contained in:
parent
42fa19482a
commit
529f176ee1
|
@ -621,46 +621,51 @@ 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_definitions := $(filter %.dbus.xml,$(my_src_files))
|
||||
dbus_generated_headers :=
|
||||
ifneq ($(dbus_definitions),)
|
||||
|
||||
dbus_if_sources_full_path := $(addprefix $(LOCAL_PATH)/,$(dbus_if_sources))
|
||||
dbus_definition_paths := $(addprefix $(LOCAL_PATH)/,$(dbus_definitions))
|
||||
dbus_service_config := $(filter %dbus-service-config.json,$(my_src_files))
|
||||
dbus_service_config_full_path := $(addprefix $(LOCAL_PATH)/,$(dbus_service_config))
|
||||
dbus_service_config_path := $(addprefix $(LOCAL_PATH)/,$(dbus_service_config))
|
||||
|
||||
dbus_header_prefix := $(generated_sources_dir)/dbus_bindings
|
||||
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_gen_dir := $(generated_sources_dir)/dbus_bindings
|
||||
|
||||
dbus_generated_source_dependencies := \
|
||||
$(dbus_if_sources_full_path) \
|
||||
$(dbus_service_config_full_path) \
|
||||
$(DBUS_GENERATOR)
|
||||
ifdef LOCAL_DBUS_PROXY_PREFIX
|
||||
dbus_header_dir := $(dbus_gen_dir)/include/$(LOCAL_DBUS_PROXY_PREFIX)
|
||||
dbus_headers := dbus-proxies.h
|
||||
else
|
||||
dbus_header_dir := $(dbus_gen_dir)
|
||||
dbus_headers := $(patsubst %.dbus.xml,%.h,$(dbus_definitions))
|
||||
endif
|
||||
dbus_generated_headers := $(addprefix $(dbus_header_dir)/,$(dbus_headers))
|
||||
|
||||
# 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)
|
||||
|
||||
$(dbus_generated_headers): PRIVATE_MODULE := $(LOCAL_MODULE)
|
||||
$(dbus_generated_headers): PRIVATE_DBUS_SERVICE_CONFIG := $(dbus_service_config_path)
|
||||
$(dbus_generated_headers) : $(dbus_service_config_path) $(DBUS_GENERATOR)
|
||||
ifdef LOCAL_DBUS_PROXY_PREFIX
|
||||
$(dbus_generated_headers) : $(dbus_definition_paths)
|
||||
$(generate-dbus-proxies)
|
||||
|
||||
# Auto-export the generated dbus proxy directory.
|
||||
my_export_c_include_dirs += $(dbus_gen_dir)/include
|
||||
my_c_includes += $(dbus_gen_dir)/include
|
||||
else
|
||||
$(dbus_generated_headers) : $(dbus_header_dir)/%.h : $(LOCAL_PATH)/%.dbus.xml
|
||||
$(generate-dbus-adaptors)
|
||||
|
||||
my_export_c_include_dirs += $(dbus_header_dir)
|
||||
my_c_includes += $(dbus_header_dir)
|
||||
endif # $(LOCAL_DBUS_PROXY_PREFIX)
|
||||
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
|
||||
my_generated_sources += $(dbus_generated_headers)
|
||||
|
||||
endif # $(dbus_definitions) non-empty
|
||||
|
||||
|
||||
###########################################################
|
||||
|
@ -1208,7 +1213,7 @@ $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
|
|||
export_includes := $(intermediates)/export_includes
|
||||
$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs)
|
||||
# Make sure .pb.h are already generated before any dependent source files get compiled.
|
||||
$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers)
|
||||
$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers) $(dbus_generated_headers)
|
||||
@echo Export includes file: $< -- $@
|
||||
$(hide) mkdir -p $(dir $@) && rm -f $@
|
||||
ifdef my_export_c_include_dirs
|
||||
|
|
|
@ -180,6 +180,7 @@ LOCAL_DPI_VARIANTS:=
|
|||
LOCAL_DPI_FILE_STEM:=
|
||||
LOCAL_SANITIZE:=
|
||||
LOCAL_SANITIZE_RECOVER:=
|
||||
LOCAL_DBUS_PROXY_PREFIX:=
|
||||
|
||||
# arch specific variables
|
||||
LOCAL_SRC_FILES_$(TARGET_ARCH):=
|
||||
|
|
|
@ -970,17 +970,27 @@ endef
|
|||
|
||||
|
||||
######################################################################
|
||||
## Commands for running protoc to compile .proto into .pb.cc and .pb.h
|
||||
## Commands for generating DBus adaptors from .dbus.xml files.
|
||||
######################################################################
|
||||
define generate-dbus-bindings
|
||||
@echo "Generating DBus bindings for $(PRIVATE_DBUS_MODULE)"
|
||||
@mkdir -p $(PRIVATE_DBUS_HEADER_DIRECTORY)
|
||||
define generate-dbus-adaptors
|
||||
@echo "Generating DBus adaptors for $(PRIVATE_MODULE)"
|
||||
@mkdir -p $(dir $@)
|
||||
$(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)
|
||||
--adaptor=$@ \
|
||||
$<
|
||||
endef
|
||||
|
||||
######################################################################
|
||||
## Commands for generating DBus proxies from .dbus.xml files.
|
||||
######################################################################
|
||||
define generate-dbus-proxies
|
||||
@echo "Generating DBus proxies for $(PRIVATE_MODULE)"
|
||||
@mkdir -p $(dir $@)
|
||||
$(hide) $(DBUS_GENERATOR) \
|
||||
--service-config=$(PRIVATE_DBUS_SERVICE_CONFIG) \
|
||||
--proxy=$@ \
|
||||
$<
|
||||
endef
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue