Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51ebac7d authored by Tom Marshall's avatar Tom Marshall
Browse files

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
parent 2d284aec
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -70,6 +70,36 @@ define include-path-for
$(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.
+9 −16
Original line number Diff line number Diff line
@@ -19,22 +19,15 @@ ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
        endif
    endif

    # This is the list of all supported QCOM variants.
    qcom_variant_list := audio camera display gps media sensors

    # Set the QCOM_*_PATH variables for each variant.
    #   $1 = Upper case name for variable name
    #   $2 = Lower case name for variable value (pathname)
    define qcom_variant_path
    $(strip \
        $(if $(TARGET_QCOM_$(1)_VARIANT), \
            hardware/qcom/$(2)-$(TARGET_QCOM_$(1)_VARIANT), \
            hardware/qcom/$(2)))
    # Populate the qcom hardware variants in the project pathmap.
    define qcom-set-path-variant
    $(call project-set-path-variant,qcom-$(2),TARGET_QCOM_$(1)_VARIANT,hardware/qcom/$(2))
    endef
    $(foreach variant, \
        $(qcom_variant_list), \
        $(eval ln:=$(shell echo $(variant) | tr [A-Z] [a-z])) \
        $(eval un:=$(shell echo $(variant) | tr [a-z] [A-Z])) \
        $(eval QCOM_$(un)_PATH:=$(call qcom_variant_path,$(un),$(ln))))
    $(call qcom-set-path-variant,AUDIO,audio)
    $(call qcom-set-path-variant,CAMERA,camera)
    $(call qcom-set-path-variant,DISPLAY,display)
    $(call qcom-set-path-variant,GPS,gps)
    $(call qcom-set-path-variant,MEDIA,media)
    $(call qcom-set-path-variant,SENSORS,sensors)

endif