meson: add support for valijson library vendoring

Abuse the meson subproject command to download valijson and build
against that when valijson is not found in the usual places.  This
enables the building and running of the unit tests without needing to
install valijson.

This is abuse because the subproject command will always fail - meson
only supports other meson projects as subprojects but it will download
the project, and since we don't actually build valijson but just use
headers this isn't a problem.

Change-Id: I2595b3deec73ac503934b91bdf52f72399032bcb
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/meson.build b/meson.build
index 0adcb30..6f68902 100644
--- a/meson.build
+++ b/meson.build
@@ -49,6 +49,14 @@
     meson.project_name(),
 )
 threads = dependency('threads')
+if cpp.has_header('valijson/validator.hpp')
+    valijson = declare_dependency()
+else
+    subproject('valijson', required: false)
+    valijson = declare_dependency(
+        include_directories: 'subprojects/valijson/include'
+    )
+endif
 
 install_data('blacklist.json')
 
diff --git a/src/meson.build b/src/meson.build
index 8218a15..2702d6c 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -10,6 +10,7 @@
         boost,
         nlohmann_json,
         sdbusplus,
+        valijson,
     ],
     implicit_include_directories: false,
     include_directories: '../include',
@@ -27,6 +28,7 @@
         nlohmann_json,
         sdbusplus,
         threads,
+        valijson,
     ],
     implicit_include_directories: false,
     include_directories: '../include',
diff --git a/subprojects/valijson.wrap b/subprojects/valijson.wrap
new file mode 100644
index 0000000..736d202
--- /dev/null
+++ b/subprojects/valijson.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+revision = c2f22fddf599d04dc33fcd7ed257c698a05345d9
+url = https://github.com/tristanpenman/valijson.git
diff --git a/test/meson.build b/test/meson.build
index 83bab53..e8683d3 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -12,6 +12,7 @@
             gtest,
             nlohmann_json,
             sdbusplus,
+            valijson,
         ],
         implicit_include_directories: false,
         include_directories: '../include',