[magma] Add support for libmagma-gfxstream

This change adds a 'use-magma-gfxstream' meson option to link against
libmagma from the gfxstream subproject instead of fuchsia.

Bug: b/272307395
Test: Build with -Duse-magma-gfxstream=true
Change-Id: I090eaa04b689f7c345920377a7dc56256c93a20a
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/mesa/+/795770
Reviewed-by: Craig Stout <cstout@google.com>
diff --git a/meson.build b/meson.build
index e8cfdcd..d5ad027 100644
--- a/meson.build
+++ b/meson.build
@@ -351,11 +351,16 @@
 with_backend_magma = _backend.contains('magma')
 
 if with_backend_magma
-  # If magma not found in the sysroot, assume its a subproject
-  dep_magma = dependency('libmagma_virt', required: false)
-  if not dep_magma.found()
-    fuchsia_proj = subproject('fuchsia')
-    dep_magma = fuchsia_proj.get_variable('dep_magma')
+  if get_option('magma-gfxstream')
+      goldfish_proj = subproject('goldfish-opengl')
+      dep_magma = goldfish_proj.get_variable('lib_magma_gfxstream_dep')
+  else
+    # If magma not found in the sysroot, assume it's a subproject
+    dep_magma = dependency('libmagma_virt', required: false)
+    if not dep_magma.found()
+      fuchsia_proj = subproject('fuchsia')
+      dep_magma = fuchsia_proj.get_variable('dep_magma')
+    endif
   endif
   pre_args += '-DUSE_MAGMA=1'
 else
diff --git a/meson_options.txt b/meson_options.txt
index 602e060..6a12385 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -565,3 +565,8 @@
   value : 8,
   description : 'Minimum Windows version to support. Defaults to Windows 8.'
 )
+option('magma-gfxstream',
+  type : 'boolean',
+  value : false,
+  description : 'Use the gfxstream magma backend'
+)