From d826264621a2c3d27228b395bc36edf5510bcc49 Mon Sep 17 00:00:00 2001
From: Colin Cross $@
is the make built-in variable for
need to change.
You need to put this after you have declared LOCAL_PATH
and
-LOCAL_MODULE
, because the $(local-intermediates-dir)
-and $(local-host-intermediates-dir)
macros use these variables
+LOCAL_MODULE
, because the $(local-generated-sources-dir)
+and $(local-host-generated-sources-dir)
macros use these variables
to determine where to put the files.
-intermediates:= $(local-intermediates-dir) +intermediates:= $(local-generated-sources-dir) GEN := $(intermediates)/chartables.c $(GEN): PRIVATE_CUSTOM_TOOL = $(HOST_OUT_EXECUTABLES)/dftables $@ $(GEN): $(HOST_OUT_EXECUTABLES)/dftables @@ -433,7 +433,7 @@ a file. Pretend that it does something useful. Note how we use a target-specific variable called PRIVATE_INPUT_FILE to store the name of the input file.-intermediates:= $(local-intermediates-dir) +intermediates:= $(local-generated-sources-dir) GEN := $(intermediates)/file.c $(GEN): PRIVATE_INPUT_FILE := $(LOCAL_PATH)/input.file $(GEN): PRIVATE_CUSTOM_TOOL = cat $(PRIVATE_INPUT_FILE) > $@ @@ -447,7 +447,7 @@ LOCAL_GENERATED_SOURCES += $(GEN) name, and use the same tool, you can combine them. (here the *.lut.h files are the generated ones, and the *.cpp files are the input files)-intermediates:= $(local-intermediates-dir) +intermediates:= $(local-generated-sources-dir) GEN := $(addprefix $(intermediates)/kjs/, \ array_object.lut.h \ bool_object.lut.h \ diff --git a/core/definitions.mk b/core/definitions.mk index eb462a37da..7c29e307eb 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -461,6 +461,51 @@ $(strip \ ) endef +########################################################### +## The generated sources directory. Placing generated +## source files directly in the intermediates directory +## causes problems for multiarch builds, where there are +## two intermediates directories for a single target. Put +## them in a separate directory, and they will be copied to +## each intermediates directory automatically. +########################################################### + +# $(1): target class, like "APPS" +# $(2): target name, like "NotePad" +# $(3): if non-empty, this is a HOST target. +# $(4): if non-empty, force the generated sources to be COMMON +define generated-sources-dir-for +$(strip \ + $(eval _idfClass := $(strip $(1))) \ + $(if $(_idfClass),, \ + $(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \ + $(eval _idfName := $(strip $(2))) \ + $(if $(_idfName),, \ + $(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \ + $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \ + $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \ + $(eval _idfIntBase := $($(_idfPrefix)_OUT_GEN_COMMON)) \ + , \ + $(eval _idfIntBase := $($(_idfPrefix)_OUT_GEN)) \ + ) \ + $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \ +) +endef + +# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE +# to determine the generated sources directory. +# +# $(1): if non-empty, force the intermediates to be COMMON +define local-generated-sources-dir +$(strip \ + $(if $(strip $(LOCAL_MODULE_CLASS)),, \ + $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \ + $(if $(strip $(LOCAL_MODULE)),, \ + $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \ + $(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1)) \ +) +endef + ########################################################### ## Convert "path/to/libXXX.so" to "-lXXX". ## Any "path/to/libXXX.a" elements pass through unchanged. diff --git a/core/envsetup.mk b/core/envsetup.mk index a348eb7dd6..4cb389bf4e 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -208,11 +208,17 @@ HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib HOST_OUT_NOTICE_FILES := $(HOST_OUT_INTERMEDIATES)/NOTICE_FILES HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj +HOST_OUT_GEN := $(HOST_OUT)/gen +HOST_OUT_COMMON_GEN := $(HOST_COMMON_OUT_ROOT)/gen + TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj TARGET_OUT_HEADERS := $(TARGET_OUT_INTERMEDIATES)/include TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj +TARGET_OUT_GEN := $(PRODUCT_OUT)/gen +TARGET_OUT_COMMON_GEN := $(TARGET_COMMON_OUT_ROOT)/gen + TARGET_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM) TARGET_OUT_EXECUTABLES := $(TARGET_OUT)/bin TARGET_OUT_OPTIONAL_EXECUTABLES := $(TARGET_OUT)/xbin