From d6d934e35fbe3dbbeb5fc42f560dd739df1e42a6 Mon Sep 17 00:00:00 2001
From: Jakob Bornecrantz <jakob@collabora.com>
Date: Sun, 9 Feb 2020 15:36:36 +0000
Subject: [PATCH] d/rs: Meson build

---
 meson.build                            |  7 +++++++
 meson_options.txt                      |  2 +-
 src/meson.build                        |  1 +
 src/targets_enabled_drivers.h.meson_in |  2 ++
 src/xrt/drivers/meson.build            | 11 +++++++++++
 src/xrt/targets/meson.build            |  5 +++++
 6 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 6f2bc3a33..a4748cdbb 100644
--- a/meson.build
+++ b/meson.build
@@ -63,6 +63,7 @@ eigen3  = dependency('eigen3')
 libjpeg = dependency('libjpeg', required: false)
 libusb  = dependency('libusb-1.0', required: false)
 opengl  = dependency('gl', required: get_option('opengl'))
+rs      = dependency('realsense2', required: false)
 sdl2    = dependency('sdl2', required: get_option('gui'))
 udev    = dependency('libudev', required: false)
 libuvc  = dependency('libuvc', required: false)
@@ -173,6 +174,12 @@ if zlib.found() and ('auto' in drivers or 'vive' in drivers)
 	endif
 endif
 
+if rs.found() and ('auto' in drivers or 'rs' in drivers)
+	if 'rs' not in drivers
+		drivers += ['rs']
+	endif
+endif
+
 if v4l2.found() and ('auto' in drivers or 'v4l2' in drivers)
 	if 'v4l2' not in drivers
 		drivers += ['v4l2']
diff --git a/meson_options.txt b/meson_options.txt
index 5b264b247..6a474e96a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -3,7 +3,7 @@
 
 option('drivers',
 	type: 'array',
-	choices: ['auto', 'dummy', 'hdk', 'hydra', 'ns', 'ohmd', 'psmv', 'psvr', 'v4l2', 'vive'],
+	choices: ['auto', 'dummy', 'hdk', 'hydra', 'ns', 'ohmd', 'psmv', 'psvr', 'rs', 'v4l2', 'vive'],
 	value: ['auto'],
 	description: 'Set of drivers to build')
 
diff --git a/src/meson.build b/src/meson.build
index e09440c9a..b496088e9 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -10,6 +10,7 @@ conf_data.set('XRT_BUILD_DRIVER_NS', 'ns' in drivers)
 conf_data.set('XRT_BUILD_DRIVER_OHMD', 'ohmd' in drivers)
 conf_data.set('XRT_BUILD_DRIVER_PSMV', 'psmv' in drivers)
 conf_data.set('XRT_BUILD_DRIVER_PSVR', 'psvr' in drivers)
+conf_data.set('XRT_BUILD_DRIVER_RS', 'rs' in drivers)
 conf_data.set('XRT_BUILD_DRIVER_V4L2', 'v4l2' in drivers)
 conf_data.set('XRT_BUILD_DRIVER_VIVE', 'vive' in drivers)
 
diff --git a/src/targets_enabled_drivers.h.meson_in b/src/targets_enabled_drivers.h.meson_in
index 61cadd983..a3a5c8d5c 100644
--- a/src/targets_enabled_drivers.h.meson_in
+++ b/src/targets_enabled_drivers.h.meson_in
@@ -23,6 +23,8 @@
 
 #mesondefine XRT_BUILD_DRIVER_PSVR
 
+#mesondefine XRT_BUILD_DRIVER_RS
+
 #mesondefine XRT_BUILD_DRIVER_V4L2
 
 #mesondefine XRT_BUILD_DRIVER_VIVE
diff --git a/src/xrt/drivers/meson.build b/src/xrt/drivers/meson.build
index 3b4b4af24..68fa0231f 100644
--- a/src/xrt/drivers/meson.build
+++ b/src/xrt/drivers/meson.build
@@ -89,6 +89,17 @@ lib_drv_psvr = static_library(
 	build_by_default: 'psvr' in drivers,
 )
 
+lib_drv_rs = static_library(
+	'drv_rs',
+	files(
+		'realsense/rs_6dof.c',
+		'realsense/rs_interface.h',
+	),
+	include_directories: xrt_include,
+	dependencies: [aux, rs],
+	build_by_default: 'rs' in drivers,
+)
+
 lib_drv_v4l2 = static_library(
 	'drv_v4l2',
 	files(
diff --git a/src/xrt/targets/meson.build b/src/xrt/targets/meson.build
index d4b8a3500..25addf35f 100644
--- a/src/xrt/targets/meson.build
+++ b/src/xrt/targets/meson.build
@@ -40,6 +40,11 @@ if 'psvr' in drivers
 	driver_libs += [lib_drv_psvr]
 endif
 
+if 'rs' in drivers
+	driver_libs += [lib_drv_rs]
+	driver_deps += [rs]
+endif
+
 if 'v4l2' in drivers
 	driver_libs += [lib_drv_v4l2]
 	driver_deps += [v4l2]
-- 
GitLab