build: qcom: Set QCOM_*_PATH variables for hardware/qcom-* projects
This consolidates a bunch of one-off logic scattered throughout the
code base. Usage in Android.mk files is trivial:
At top level, use e.g. "ifeq ($(call my-dir),$(QCOM_AUDIO_PATH))".
This works for all variants, including non-variants (i.e. AOSP).
Within subdirs, use e.g. hardware/qcom/audio => $(QCOM_AUDIO_PATH)
Change-Id: Iee2497ea9a7efeb4ae9e861b84c532b19da7b69d
build: Introduce project pathmap and use it for qcom variants
The project pathmap tracks the path to the top level of a project. The
following functions are provided:
* project-set-path adds an entry.
* project-set-path-variant adds a "variant" entry.
* project-path-for retrieves an entry.
To use as a guard in Android.mk:
ifeq ($(call my-dir),$(call project-path-for,projectname))
To use for include paths in Android.mk:
LOCAL_C_INCLUDES += $(call project-path-for,projectname)/...
Set project pathmap for qcom project variants.
Change-Id: I8dceca72a1ba80fc7b1830c5ab285d444f530457
build: Set QCOM variants for non-QCOM_HARDWARE defined targets
* Nexus devices and others typically do not define the QCOM_HARDWARE
flag, so the variant path should always default to the AOSP variant.
* Unconditionally set the variant to the AOSP HAL by default.
Change-Id: I714170897128f92718af266366cfcbf3136e8981
diff --git a/core/pathmap.mk b/core/pathmap.mk
index b300ff5..699eac1 100644
--- a/core/pathmap.mk
+++ b/core/pathmap.mk
@@ -63,6 +63,36 @@
$(foreach n,$(1),$(patsubst $(n):%,%,$(filter $(n):%,$(pathmap_INCL))))
endef
+# Enter project path into pathmap
+#
+# $(1): name
+# $(2): path
+#
+define project-set-path
+$(eval pathmap_PROJ += $(1):$(2))
+endef
+
+# Enter variant project path into pathmap
+#
+# $(1): name
+# $(2): variable to check
+# $(3): base path
+#
+define project-set-path-variant
+ $(call project-set-path,$(1),$(strip \
+ $(if $($(2)), \
+ $(3)-$($(2)), \
+ $(3))))
+endef
+
+# Returns the path to the requested module's include directory,
+# relative to the root of the source tree.
+#
+# $(1): a list of modules (or other named entities) to find the projects for
+define project-path-for
+$(foreach n,$(1),$(patsubst $(n):%,%,$(filter $(n):%,$(pathmap_PROJ))))
+endef
+
#
# Many modules expect to be able to say "#include <jni.h>",
# so make it easy for them to find the correct path.