dragonboards: Create build option to use prebuilt mesa bits am: b1014352f4 am: 3168d61f2d

Original change: https://android-review.googlesource.com/c/device/linaro/dragonboard/+/2000463

Change-Id: I01f066d34fd3ba558af8d015905ab7f1e3c8f41a
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 \