diff --git a/core/binary.mk b/core/binary.mk index 080310aa2..28aa882dc 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -697,6 +697,38 @@ my_generated_sources += $(dbus_generated_headers) endif # $(dbus_definitions) non-empty +########################################################### +## AIDL: Compile .aidl files to .cpp and .h files +########################################################### +aidl_src := $(strip $(filter %.aidl,$(my_src_files))) +aidl_gen_cpp := +ifneq ($(aidl_src),) + +aidl_gen_cpp_root := $(intermediates)/aidl-generated/src +aidl_gen_include_root := $(intermediates)/aidl-generated/include + +aidl_gen_cpp := $(patsubst %.aidl,%$(LOCAL_CPP_EXTENSION),$(aidl_src)) +aidl_gen_cpp := $(addprefix $(aidl_gen_cpp_root)/,$(aidl_gen_cpp)) + +# TODO(wiley): we could pass down a flag here to only generate the server or +# client side of the binder interface. +$(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE) +$(aidl_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(aidl_gen_include_root) +$(aidl_gen_cpp) : PRIVATE_AIDL_FLAGS := $(addprefix -I,$(LOCAL_AIDL_INCLUDES)) + +# Multi-architecture builds have distinct intermediates directories. +# Define rules for both architectures. +$(aidl_gen_cpp) : $(aidl_gen_cpp_root)/%$(LOCAL_CPP_EXTENSION) : $(LOCAL_PATH)/%.aidl $(AIDL_CPP) + $(transform-aidl-to-cpp) +-include $(addsuffix .P,$(basename $(aidl_gen_cpp))) + +# Add generated headers to include path. +my_c_includes += $(aidl_gen_include_root) +# Pick up the generated C++ files later for transformation to .o files. +my_generated_sources += $(aidl_gen_cpp) + +endif # $(aidl_src) 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 2b7cb7fcd..b6a3d3f73 100644 --- a/core/config.mk +++ b/core/config.mk @@ -432,6 +432,7 @@ YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm DOXYGEN:= doxygen AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX) AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX) +AIDL_CPP := $(HOST_OUT_EXECUTABLES)/aidl-cpp$(HOST_EXECUTABLE_SUFFIX) ifeq ($(HOST_OS),linux) BREAKPAD_DUMP_SYMS := $(HOST_OUT_EXECUTABLES)/dump_syms else diff --git a/core/definitions.mk b/core/definitions.mk index f2fa8a812..7878474c1 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -973,6 +973,14 @@ $(hide) $(AIDL) -d$(patsubst %.java,%.P,$@) $(PRIVATE_AIDL_FLAGS) $< $@ endef #$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@ +define transform-aidl-to-cpp +@mkdir -p $(dir $@) +@mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR) +@echo "Generating C++ from AIDL: $(PRIVATE_MODULE) <= $<" +$(hide) $(AIDL_CPP) -d$(basename $@).P $(PRIVATE_AIDL_FLAGS) \ + $< $(PRIVATE_HEADER_OUTPUT_DIR) $@ +endef + ########################################################### ## Commands for running java-event-log-tags.py