dragonboards: Create build option to use prebuilt mesa bits

Enables the build to utilize prebuilt mesa binaries found in the
20220303 linaro-vendor-package.

Also provides a TARGET_BUILD_MESA build option such that
building with the aosp/master or aosp/upstream-main branches of
external/mesa3d are still possible by setting:
  TARGET_BUILD_MESA=true

Change-Id: Ibeee5cd578df6e8462427d0f3757007ed30c6148
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index 2f3be01..87cde99 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -42,10 +42,14 @@
 BOARD_USES_DRM_HWCOMPOSER := true
 BOARD_GPU_DRIVERS := freedreno
 TARGET_USES_HWC2 := true
+
+ifeq ($(TARGET_BUILD_MESA),true)
 BOARD_MESA3D_USES_MESON_BUILD := true
 BOARD_MESA3D_GALLIUM_DRIVERS := freedreno
 BOARD_MESA3D_VULKAN_DRIVERS := freedreno
-
+else
+BOARD_USE_CUSTOMIZED_MESA := true
+endif
 
 # WiFi
 WPA_SUPPLICANT_VERSION := VER_0_8_X
diff --git a/device-common.mk b/device-common.mk
index ee24e4f..6601cda 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -53,7 +53,6 @@
 
 PRODUCT_SOONG_NAMESPACES += \
     device/linaro/dragonboard \
-    external/mesa3d \
     vendor/linaro/linux-firmware/$(EXPECTED_LINARO_VENDOR_VERSION) \
     vendor/linaro/db845c/$(EXPECTED_LINARO_VENDOR_VERSION) \
     vendor/linaro/rb5/$(EXPECTED_LINARO_VENDOR_VERSION)
diff --git a/full.mk b/full.mk
index a87cb1c..96c3f9f 100644
--- a/full.mk
+++ b/full.mk
@@ -39,7 +39,10 @@
 # Display
 PRODUCT_PACKAGES += \
     android.hardware.drm@1.3-service.clearkey \
-    android.hardware.drm@1.3-service.widevine \
+    android.hardware.drm@1.3-service.widevine
+
+# Mesa
+PRODUCT_PACKAGES += \
     libGLES_mesa \
     libEGL_mesa \
     libGLESv1_CM_mesa \
@@ -47,6 +50,12 @@
     libgallium_dri \
     libglapi
 
+TARGET_BUILD_MESA ?= false
+ifeq ($(TARGET_BUILD_MESA), true)
+   PRODUCT_SOONG_NAMESPACES += \
+       external/mesa3d
+endif
+
 PRODUCT_PROPERTY_OVERRIDES += \
     ro.hardware.gralloc=minigbm_msm \
     ro.hardware.hwcomposer=drm \